molecupy.structures.molecules
(Atomic Structures)¶
Contains classes for simple structures made of atoms.
-
class
molecupy.structures.molecules.
AtomicStructure
(*atoms)[source]¶ The base class for all structures which are composed of atoms.
Parameters: atoms – A sequence of Atom
objects.-
atoms
(atom_type='localised')[source]¶ Returns the atoms in this structure as a
set
.Parameters: atom_type (str) – The kind of atom to return. "all"
will return all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms.Return type: set
-
remove_atom
(atom)[source]¶ Removes an atom from the structure.
Parameters: atom (Atom) – The atom to add.
-
mass
(atom_type='localised')[source]¶ Returns the mass of the structure by summing the mass of all its atoms.
Parameters: atom_type (str) – The kind of atom to use. "all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms.Return type: float
-
formula
(atom_type='localised', include_hydrogens=False)[source]¶ Retrurns the formula (count of each atom) of the structure.
Parameters: - atom_type (str) – The kind of atom to use.
"all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms. - include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: Counter
- atom_type (str) – The kind of atom to use.
-
contacts_with
(other_atomic_structure, distance=4, include_hydrogens=True)[source]¶ Returns the set of all ‘contacts’ with another atomic structure, where a contact is defined as any atom-atom pair with an inter-atomic distance less than or equal to some number of Angstroms.
If the other atomic structure has atoms which are also in this atomic structure, those atoms will not be counted as part of the other structure.
Parameters: - other_structure (AtomicStructure) – The other atomic structure to compare to.
- distance – The distance to use (default is 4).
- include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: set
offrozenset
contacts.
-
internal_contacts
(distance=4, include_hydrogens=True)[source]¶ Returns the set of all atomic contacts within the atoms of an atomic structure, where a contact is defined as any atom-atom pair with an inter-atomic distance less than or equal to four Angstroms.
Contacts between atoms covalently bonded to each other will be ignored, as will contacts between atoms separated by just two covalent bonds.
Parameters: - distance – The distance to use (default is 4).
- include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: set
offrozenset
contacts.
-
predict_bind_site
(distance=5, include_hydrogens=True)[source]¶ Attempts to predict the residues that might make up the atomic structure’s binding site by using atomic distances.
Parameters: - distance – The distance to use (default is 5s).
- include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: BindSite
orNone
-
translate
(x, y, z)[source]¶ Translates the structure in space.
Parameters: - x – The distance in Angstroms to move in the x-direction.
- y – The distance in Angstroms to move in the y-direction.
- z – The distance in Angstroms to move in the z-direction.
-
rotate
(axis, angle)[source]¶ Rotates the structure around an axis.
Parameters: - axis (str) – The axis to rotate around - must be
"x"
,"y"
or"z"
. - angle – The angle, in degrees, to rotate by. Rotation is clockwise.
- axis (str) – The axis to rotate around - must be
-
radius_of_gyration
()[source]¶ The radius of gyration of an atomic structure is a measure of how extended it is. It is the root mean square deviation of the atoms from the structure’s center of mass.
Return type: float
-
get_atom_by_id
(atom_id)[source]¶ Retrurns the first atom that matches a given atom ID.
Parameters: atom_id (int) – The atom ID to search by. Return type: Atom
orNone
-
get_atoms_by_element
(element, atom_type='localised')[source]¶ Retruns all the atoms a given element.
Parameters: - element (str) – The element to search by.
- atom_type (str) – The kind of atom to use.
"all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms. - include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: set
ofAtom
objects.
-
get_atom_by_element
(element, atom_type='localised')[source]¶ Retrurns the first atom that matches a given element.
Parameters: - element (str) – The element to search by.
- atom_type (str) – The kind of atom to use.
"all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms. - include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: Atom
orNone
-
get_atoms_by_name
(atom_name, atom_type='localised')[source]¶ Retruns all the atoms a given name.
Parameters: - atom_name (str) – The name to search by.
- atom_type (str) – The kind of atom to use.
"all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms. - include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: set
ofAtom
objects.
-
get_atom_by_name
(atom_name, atom_type='localised')[source]¶ Retrurns the first atom that matches a given name.
Parameters: - atom_name (str) – The name to search by.
- atom_type (str) – The kind of atom to use.
"all"
will use all atoms,"localised"
just standard Atoms and"ghost"
will just return genericGhostAtom
atoms. - include_hydrogens (bool) – determines whether hydrogen atoms should be included.
Return type: Atom
orNone
-
-
class
molecupy.structures.molecules.
SmallMolecule
(molecule_id, molecule_name, *atoms)[source]¶ Base class:
AtomicStructure
Represents the ligands, solvent molecules, and other non-polymeric molecules in a structure.
Parameters: - molecule_id (str) – The molecule’s ID.
- molecule_name (str) – The molecule’s name.
- atoms – The molecule’s atoms.
-
molecule_name
(molecule_name=None)[source]¶ Returns or sets the molecule’s name.
Parameters: name (str) – If given, the molecule’s name will be set to this. Return type: str
-
class
molecupy.structures.molecules.
Residue
(residue_id, residue_name, *atoms)[source]¶ Base class:
AtomicStructure
A Residue on a chain.
Parameters: - residue_id (str) – The residue’s ID.
- residue_name (str) – The residue’s name.
- atoms – The residue’s atoms.
-
residue_name
(residue_name=None)[source]¶ Returns or sets the residue’s name.
Parameters: name (str) – If given, the residue’s name will be set to this. Return type: str
-
is_missing
()[source]¶ Returns
True
if the residue was not observed in the experiment (and is therefore made up entirely of atoms with no coordinates).Return type: bool
-
downstream_residue
()[source]¶ Returns the residue connected to this residue’s carboxy end.
Return type: Residue
-
upstream_residue
()[source]¶ Returns the residue connected to this residue’s amino end.
Return type: Residue
-
connect_to
(downstream_residue)[source]¶ Connects this residue to a downstream residue.
Parameters: downstream_residue (Residue) – The other residue.