pygen_structures.charmm_containers module¶
Module which stores classes intended to deal with CHARMM forcefield data.
-
class
pygen_structures.charmm_containers.CHARMMParameterFile(bonds: (<class 'set'>, None) = None, angles: (<class 'set'>, None) = None, dihedrals: (<class 'set'>, None) = None, impropers: (<class 'set'>, None) = None, cross_maps: (<class 'set'>, None) = None)¶ Bases:
objectA parser for CHARMM PRM files. Used for checking that parameters exist for generated structures.
This class does not contain the values for the parameters, but does ensure that the parameters themselves are present.
- Parameters
bonds – set of tuples containing 2
atom_typeangles – set of tuples containing 3
atom_typedihedrals – set of tuples containing 4
atom_typeimpropers – set of tuples containing 4
atom_typecross_maps – set of tuples containing 8
atom_type
-
check_parameters(molecule) → bool¶ Check a finalized
Moleculeto verify that all the parameters in theCHARMMParameterFileexist for that molecule, returningTrueif all parameters are present, otherwiseFalse
-
classmethod
from_file(prm_path: str)¶ Instantiate the class from a CHARMM PRM file.
- Parameters
prm_path – path to the .prm/.str file.
-
get_unmatched(molecule) → Dict[str, Set[Tuple[str]]]¶ Check a finalized
Moleculeto verify that all the parameters in theCHARMMParameterFileexist for that molecule, returning necessary parameters which are missing.- Parameters
molecule – the
Molecule- Returns
dict of parameter type (i.e. ‘bonds’/’angles’) to a set of tuples containing unmatched
atom_typetuples.
-
read_file(prm_path: str) → None¶ Read in data from a CHARMM PRM file.
- Parameters
prm_path – path to .prm/.str file
-
class
pygen_structures.charmm_containers.CHARMMPatchResidueDefinition(name: str = 'Unset', atoms: (<class 'list'>, None) = None, bonds: (<class 'list'>, None) = None, impropers: (<class 'list'>, None) = None, cross_maps: (<class 'list'>, None) = None, ics: (<class 'list'>, None) = None, rtf_file_name: (<class 'str'>, None) = None, deletions: (<class 'set'>, None) = None, n_residues: int = 1)¶ Bases:
pygen_structures.charmm_containers.CHARMMResidueDataDefinition of a CHARMM patch residue. As CHARMM patches can apply to multiple residues, these are more complicated to represent than the residues they are applied to.
atoms,bonds,impropers,cross_mapsandicsaren_residueslong lists of the atoms, bonds, impropers, cross_maps and ics for each residue. This enables these to be zipped together with the actual residues the patch is to apply them to.Atoms, due to their simplicity, are kept as the form they are stored in the residue: - (
atom_name,atom_type,charge)In the other representations, atoms are stored as atom references. These are tuples of
(residue_index: int, atom_name: str), whereresidue_indexis a placeholder for the order given in the patch. - e.g. 2SG1 ->(1, 'SG1')- “BOND 1SG1 2SG1” ->((0, 'SG1'), (1, 'SG1'))This is to account for new bonds/impropers/crossmaps/ics which involve atoms in different residues.
- Parameters
name – patch name, from PRES record
atoms – an
n_residueslong list of lists containing(atom_name, atom_type, partial_charge)bonds – an
n_residueslong list of lists containing tuples of 2 atom references, from BOND/DOUB records. Bonds in DOUB records appear twice.impropers – an
n_residueslong list of lists containing tuples of 4 atom references from IMPR recordscross_maps – an
n_residueslong list of lists containing tuples of 8 atom references from CMAP recordsics – an
n_residueslong list of lists containing lists of information present in IC records. The first 4 items are atom references, the last 5 are floats containing bond and angle information. Where angle i-j-k-l is an improper, the third atom name is prefaced with “*”. The floats are: the bond length, i-j the angle, i-j-k the dihedral (or improper) i-j-k-l the angle j-k-l the bond length k-ldeletions – set of atom names which are to be deleted from the residue
-
apply(*residues)¶ Applies the CHARMM patch to an actual residue (or collection of actual residues).
Atoms to be deleted are removed from the applicable residues, with now-dangling bonds/impropers/cross-maps/ICs to these residues also removed.
New atoms, bonds, impropers, cross_maps and ics are then appended to the relevant residue.
Bonds are added to the residue which contains the first atom, all other multi-atom data is added to the residue which contains the second atom. This is to account for the fact that the other connections can feature atoms in the residue before and after in the first and last positions - in bonds, these tend do be in the first position.
-
classmethod
from_block(block: str)¶ Generate the class from a PRES block in an RTF file. This is probably the most useful constructor.
- Parameters
block – a multi-line string containing the PRES block.
- Returns
An instance of the class
-
is_applicable_to(residue) → Union[None, List[int]]¶ Work out the positions where the patch can be applied to the residue. If the patch can be applied, return a list of positions where the patch can be applied, otherwise return
None.- Parameters
residue – The
CHARMMResiduethe patch is to be applied to- Returns
A list of indices where the residue could be supplied to the patch, if applicable. Otherwise
None.
-
class
pygen_structures.charmm_containers.CHARMMResidue(name: str = 'Unset', atoms: (<class 'list'>, None) = None, bonds: (<class 'list'>, None) = None, impropers: (<class 'list'>, None) = None, cross_maps: (<class 'list'>, None) = None, ics: (<class 'list'>, None) = None, rtf_file_name: (<class 'str'>, None) = None, first: (<class 'str'>, None) = None, last: (<class 'str'>, None) = None, index: int = 0)¶ Bases:
pygen_structures.charmm_containers.CHARMMResidueDataAn actual CHARMM residue, in a molecule. This has an associated index. The atoms are unchanged from the residue definition (see
CHARMMResidueDefinition), but rather than referring toatom_name, thebonds,impropers,cross_mapsandicsnow refer toatom_ids, which are unique atoms rather than general abstract atoms definitions.- An
atom_idtakes the following form: (residue_index: int, atom_name: str)
- Parameters
first – default patch if residue is first in chain. If None, this defaults to the default first patch of the
CHARMMResidueTopologyFilethe residue definition is in.last – default patch if residue is last in the chain. Treated much the same way as
first.index – the
residue_index.
-
classmethod
from_residue_definition(residue_definition: pygen_structures.charmm_containers.CHARMMResidueDefinition, index: int, last_index: (<class 'int'>, None) = None, next_index: (<class 'int'>, None) = None)¶ Generate a
CHARMMResiduefrom the residue definition. This is probably the most useful constructor.- Parameters
residue_definition –
CHARMMResidueDefinitionto clone.index – the
residue_indexof the created residue.last_index – the
residue_indexof the previous residue in the chain. Used for connections where atoms start with ‘-‘. Default: index - 1last_index – the
residue_indexof the next residue in the chain. Used for connections where atoms start with ‘+’. Default: index - 1
- Returns
the created residue.
- An
-
class
pygen_structures.charmm_containers.CHARMMResidueData(name: str = 'Unset', atoms: (<class 'list'>, None) = None, bonds: (<class 'list'>, None) = None, impropers: (<class 'list'>, None) = None, cross_maps: (<class 'list'>, None) = None, ics: (<class 'list'>, None) = None, rtf_file_name: (<class 'str'>, None) = None)¶ Bases:
objectBase class for CHARMM residue data. Holds information present in a residue topology file (RTF) section.
-
class
pygen_structures.charmm_containers.CHARMMResidueDefinition(name: str = 'Unset', atoms: (<class 'list'>, None) = None, bonds: (<class 'list'>, None) = None, impropers: (<class 'list'>, None) = None, cross_maps: (<class 'list'>, None) = None, ics: (<class 'list'>, None) = None, rtf_file_name: (<class 'str'>, None) = None, first: (<class 'str'>, None) = None, last: (<class 'str'>, None) = None)¶ Bases:
pygen_structures.charmm_containers.CHARMMResidueDataDefinition of a CHARMM residue. This is a general representation, and doesn’t have an associated index.
- Parameters
name – residue name, from RESI record
atoms – list of (atom_name, atom_type, partial_charge), from ATOM records
bonds – lists of tuples of 2
atom_name, from BOND/DOUB records. Bonds in DOUB records appear twice.impropers – lists of tuples of 4
atom_namefrom IMPR recordscross_maps – lists of tuples of 8
atom_namefrom CMAP recordsics – list of information present in IC records. The first 4 items are
atom_name, the last 5 are floats containing bond length/angle information. Where angle i-j-k-l is an improper, the thirdatom_nameis prefaced with “*”. The floats are: the bond length, i-j the angle, i-j-k the dihedral (or improper) i-j-k-l the angle j-k-l the bond length k-lfirst – default patch if residue is first in the chain. If
None, this defaults to the default first patch of theCHARMMResidueTopologyFilethis residue definition is in.last – default patch if residue is last in the chain. Treated much the same way as
first.
-
classmethod
from_block(block: str)¶ Generate the class from a RESI block in an RTF file. This is probably the most useful constructor.
- Parameters
block – a multiline string containing the RESI block.
- Returns
an instance of the class
-
to_fragment_mol() → rdkit.Chem.rdchem.RWMol¶ Generate a
Structure and return the RDKit ``Molgenerated. :return: RDKitRWMol
-
to_residue(index: int, last_index: (<class 'int'>, None) = None, next_index: (<class 'int'>, None) = None)¶ Generate a
CHARMMResiduefrom the residue definition.- Parameters
index – the
residue_indexof the created residue.last_index – the
residue_indexof the previous residue.index – the
residue_indexof the next residue.
- Returns
the created residue
- Return type
-
to_smarts()¶ Generate a
Structure, grab the RDKitMol, and callMolToSMARTSafter removing hydrogen atoms.- Returns
the SMARTS string.
-
to_structure() → pygen_structures.mol_containers.structure.Structure¶ Returns the residue as a
Structureobject. These can be used for pattern matching of residues.- Returns
the generated
Structure
-
class
pygen_structures.charmm_containers.CHARMMResidueTopologyFile(file_name: (<class 'str'>, None) = None, residues: (<class 'dict'>, None) = None, patches: (<class 'dict'>, None) = None, masses: (<class 'dict'>, None) = None, first: (<class 'str'>, None) = None, last: (<class 'str'>, None) = None)¶ Bases:
objectA class which reads and stores patch residues and residues from a CHARMM RTF or STR file.
- Parameters
file_name – the name of the RTF file.
residues – a mapping of residue names to the
CHARMMResidueDefinitionwhich represents them.patches – a mapping of patch residue names to the
CHARMMPatchResidueDefinitionwhich represents them.masses – a mapping of
atom_typeto mass.first – the name of the patch applied to the first residue in a chain.
last – the name of the patch applied to the last residue in a chain.
-
add_patch_definition(patch: pygen_structures.charmm_containers.CHARMMPatchResidueDefinition) → None¶ Add a
CHARMMPatchResidueDefinitionto the patches- Parameters
patch – a
CHARMMPatchResidueDefinition
-
add_residue_definition(residue: pygen_structures.charmm_containers.CHARMMResidueDefinition) → None¶ Add a
CHARMMResidueDefinitionto the residues- Parameters
residue – a
CHARMMResidueDefinition
-
classmethod
from_file(rtf_path: str)¶ Instantiate the class from a CHARMM RTF file.
- Parameters
rtf_path – path to .rtf/.str file
-
read_file(rtf_path: str, update_default_patches=False) → None¶ Read in a CHARMM RTF (or STR) file and add the patches and residues, updating the default patches if requested.
- Parameters
rtf_path – path to the .rtf/.str file
update_default_patches – bool flag, updates
firstandlastif True.