molsystem package¶
Submodules¶
molsystem.atoms module¶
A dictionary-like object for holding atoms
For efficiency the atom-data is stored as arrays – numpy if possible, python lists otherwise, along with metadata to define the attributes (“columns”).
In some ways this a bit like pandas; however, we also need more control than a simple pandas dataframe provides….
molsystem.bonds module¶
A dictionary-like object for holding bonds
Based on tables in an SQLite database.
molsystem.cell module¶
-
class
molsystem.cell.
Cell
(a, b, c, alpha, beta, gamma)[source]¶ Bases:
object
A class to handle cell parameters and their transformations.
-
property
a
¶ The length of the first cell vector.
-
property
alpha
¶ The angle between b and c.
-
property
b
¶ The length of the second cell vector.
-
property
beta
¶ The angle between a and c.
-
property
c
¶ The length of the third cell vector.
-
equal
(other, tol=1e-06)[source]¶ Check if we are equal to another iterable to within a tolerance.
- Parameters
other (iterable) – The other object to check against
tol (float = 1.0e-06) – The tolerance for comparing floating point numbers.
- Returns
equals – Boolean indicating whether the two are equal.
- Return type
bool
-
property
gamma
¶ The angle between a and b.
-
property
parameters
¶ The cell parameters as a list.
-
to_cartesians
(uvw, as_array=False)[source]¶ Convert fraction coordinates to Cartesians
see https://en.wikipedia.org/wiki/Fractional_coordinates for a description.
- Parameters
uvw ([N][3*float] or ndarray) – The fractional coordinates.
- Returns
xyz – The Cartesian coordinates.
- Return type
[N][float*3] or ndarray
-
to_cartesians_transform
(as_array=False)[source]¶ Matrix to convert fractional coordinates to Cartesian.
see https://en.wikipedia.org/wiki/Fractional_coordinates for a description.
- Parameters
as_array (bool = False) – Whether to return a numpy array or Python lists
- Returns
transform – The transformation matrix
- Return type
[N][float*3] or ndarray
-
to_fractionals
(xyz, as_array=False)[source]¶ Convert Cartesian coordinates to fractional.
see https://en.wikipedia.org/wiki/Fractional_coordinates for a description.
- Parameters
xyz ([N][3*float] or ndarray) – The Cartesian coordinates.
- Returns
uvw – The ractional coordinates.
- Return type
[N][float*3] or ndarray
-
to_fractionals_transform
(as_array=False)[source]¶ Matrix to convert Cartesian coordinates to fractional.
see https://en.wikipedia.org/wiki/Fractional_coordinates for a description.
- Parameters
as_array (bool = False) – Whether to return a numpy array or Python lists
- Returns
transform – The transformation matrix
- Return type
[N][float*3] or ndarray
-
property
volume
¶ The volume of the cell.
-
property
molsystem.cell_parameters module¶
molsystem.cif module¶
Functions for handling CIF files
-
class
molsystem.cif.
CIFMixin
[source]¶ Bases:
object
A mixin for handling CIF files.
-
from_cif_text
(text, configuration=None)[source]¶ Create the system from a CIF file..
- Parameters
text (str) – The text from the CIF file
configuration (int = None) – The configuration to use, defaults to the current configuration.
- Returns
- Return type
None
-
molsystem.column module¶
molsystem.elemental_data module¶
Tabulated data about the elements.
molsystem.frozencolumn module¶
molsystem.molfile module¶
Functions for handling MDL molfiles
-
class
molsystem.molfile.
MolFileMixin
[source]¶ Bases:
object
A mixin for handling MDL Molfiles.
-
from_molfile_text
(data, configuration=None)[source]¶ Create the system from an MDL Molfile, version 3
- Parameters
data (str) – The complete text of the Molfile.
configuration (int = None) – The configuration to use, defaults to the current configuration.
-
to_molfile_text
(configuration=None, title=None, comment='Exported from SEAMM')[source]¶ Create the text of the Molfile from the system.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
title (str = None) – The title for the structure, by default the system name.
comment (str = 'Exported from SEAMM') – Comment line
- Returns
text – The text of the file.
- Return type
str
-
molsystem.pdb module¶
Functions for handling PDB files
To Do¶
Need to understand more fully the PDB/mmcif format and the how to carry the information about residues, chains, hetero groups, waters, etc. At the moment this is ignoring much of the information, and putting residue, chain, etc information directly on atoms.
I think we should use templates and subsets, but am not (yet) sure.
Presumably this metadata is most useful for setting up complicated simulations.
File Format¶
For complete documentation, see http://www.wwpdb.org/documentation/file-format-content/format33/v3.3.html
Order of records:
RECORD TYPE EXISTENCE CONDITIONS IF OPTIONAL
--------------------------------------------------------------------------------------
HEADER Mandatory
OBSLTE Optional Mandatory in entries that have been
replaced by a newer entry.
TITLE Mandatory
SPLIT Optional Mandatory when large macromolecular
complexes are split into multiple PDB
entries.
CAVEAT Optional Mandatory when there are outstanding errors
such as chirality.
COMPND Mandatory
SOURCE Mandatory
KEYWDS Mandatory
EXPDTA Mandatory
NUMMDL Optional Mandatory for NMR ensemble entries.
MDLTYP Optional Mandatory for NMR minimized average
Structures or when the entire polymer
chain contains C alpha or P atoms only.
AUTHOR Mandatory
REVDAT Mandatory
SPRSDE Optional Mandatory for a replacement entry.
JRNL Optional Mandatory for a publication describes
the experiment.
REMARK 0 Optional Mandatory for a re-refined structure
REMARK 1 Optional
REMARK 2 Mandatory
REMARK 3 Mandatory
REMARK N Optional Mandatory under certain conditions.
DBREF Optional Mandatory for all polymers.
DBREF1/DBREF2 Optional Mandatory when certain sequence database
accession and/or sequence numbering
does not fit preceding DBREF format.
SEQADV Optional Mandatory if sequence conflict exists.
SEQRES Mandatory Mandatory if ATOM records exist.
MODRES Optional Mandatory if modified group exists in the
coordinates.
HET Optional Mandatory if a non-standard group other
than water appears in the coordinates.
HETNAM Optional Mandatory if a non-standard group other
than water appears in the coordinates.
HETSYN Optional
FORMUL Optional Mandatory if a non-standard group or
water appears in the coordinates.
HELIX Optional
SHEET Optional
SSBOND Optional Mandatory if a disulfide bond is present.
LINK Optional Mandatory if non-standard residues appear
in a polymer
CISPEP Optional
SITE Optional
CRYST1 Mandatory
ORIGX1 ORIGX2 ORIGX3 Mandatory
SCALE1 SCALE2 SCALE3 Mandatory
MTRIX1 MTRIX2 MTRIX3 Optional Mandatory if the complete asymmetric unit
must be generated from the given coordinates
using non-crystallographic symmetry.
MODEL Optional Mandatory if more than one model
is present in the entry.
ATOM Optional Mandatory if standard residues exist.
ANISOU Optional
TER Optional Mandatory if ATOM records exist.
HETATM Optional Mandatory if non-standard group exists.
ENDMDL Optional Mandatory if MODEL appears.
CONECT Optional Mandatory if non-standard group appears
and if LINK or SSBOND records exist.
MASTER Mandatory
END Mandatory
Description of HETATM records:
COLUMNS DATA TYPE FIELD DEFINITION
-----------------------------------------------------------------------
1 - 6 Record name "HETATM"
7 - 11 Integer serial Atom serial number.
13 - 16 Atom name Atom name.
17 Character altLoc Alternate location indicator.
18 - 20 Residue name resName Residue name.
22 Character chainID Chain identifier.
23 - 26 Integer resSeq Residue sequence number.
27 AChar iCode Code for insertion of residues.
31 - 38 Real(8.3) x Orthogonal coordinates for X.
39 - 46 Real(8.3) y Orthogonal coordinates for Y.
47 - 54 Real(8.3) z Orthogonal coordinates for Z.
55 - 60 Real(6.2) occupancy Occupancy.
61 - 66 Real(6.2) tempFactor Temperature factor.
77 - 78 LString(2) element Element symbol; right-justified.
79 - 80 LString(2) charge Charge on the atom.
Description of CONECT records:
COLUMNS DATA TYPE FIELD DEFINITION
-------------------------------------------------------------------------
1 - 6 Record name "CONECT"
7 - 11 Integer serial Atom serial number
12 - 16 Integer serial Serial number of bonded atom
17 - 21 Integer serial Serial number of bonded atom
22 - 26 Integer serial Serial number of bonded atom
27 - 31 Integer serial Serial number of bonded atom
-
class
molsystem.pdb.
PDBMixin
[source]¶ Bases:
object
A mixin for handling PDB files.
-
from_pdb_text
(data, configuration=None)[source]¶ Create the system from a PDF file.
- Parameters
data (str) – The complete text of the Molfile.
configuration (int = None) – The configuration to use, defaults to the current configuration.
-
to_pdb_text
(configuration=None, title=None, comment='Exported from SEAMM')[source]¶ Create the text of the PDB file from the system.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
title (str = None) – The title for the structure, by default the system name.
comment (str = 'Exported from SEAMM') – Comment line
- Returns
text – The text of the file.
- Return type
str
-
molsystem.system module¶
A dictionary-like object for holding a system
molsystem.systems module¶
A dictionary-like object for holding systems
-
class
molsystem.systems.
Systems
[source]¶ Bases:
collections.abc.MutableMapping
-
copy_system
(other, name=None, filename=None, temporary=False, force=False)[source]¶ Create a copy of a system, optionally with a given name and filename.
-
create_system
(name, filename=None, temporary=False, force=False)[source]¶ Create a system with a given name, and optionally a filename.
-
molsystem.table module¶
molsystem.template module¶
A dictionary-like object for holding templates
molsystem.templateatoms module¶
A dictionary-like object for holding atoms for the templates
molsystem.templatebonds module¶
molsystem.topology module¶
Topological methods for the system
-
class
molsystem.topology.
TopologyMixin
[source]¶ Bases:
object
A mixin for handling topology.
-
bonded_neighbors
(configuration=None, as_indices=False, first_index=0)[source]¶ The atoms bonded to each atom in the system.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
as_indices (bool = False) – Whether to return 0-based indices (True) or atom ids (False)
first_index (int = 0) – The smallest index, e.g. 0 or 1
- Returns
neighbors – list of atom ids for each atom id
- Return type
{int: [int]} or [[int]] for indices
-
create_molecule_subsets
(configuration=None)[source]¶ Create a subset for each molecule in a configuration.
By default they all reference an empty template ‘all’ of type ‘molecule’.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
- Returns
The ids of the subsets, one per molecule.
- Return type
[int]
-
create_molecule_templates
(configuration=None, create_subsets=True)[source]¶ Create a template for each unique molecule in a configuration.
By default also create subsets linking each template to the atoms of the molecules in the system.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
create_subsets (bool = True) – If true, create subsets linking the templates to the molecules.
- Returns
The ids of the templates, or if create_subsets is True a two-element list containing the list of templates and list of subsets.
- Return type
[int] or [[int], [int]]
-
find_molecules
(configuration=None, as_indices=False)[source]¶ Find the separate molecules in a system.
- Parameters
configuration (int = None) – The configuration to use, defaults to the current configuration.
as_indices (bool = False) – Whether to return 0-based indices (True) or atom ids (False)
- Returns
molecules – A list of lists of atom ids or indices for the molecules
- Return type
[[int]*n_molecules]
-
Module contents¶
molsystem A general implementation for molecular and periodic systems.