- class openff.pablo.ResidueDefinition(residue_name: str | None, description: str, linking_bond: BondDefinition | None, crosslink: BondDefinition | None, atoms: tuple[AtomDefinition, ...], bonds: tuple[BondDefinition, ...], virtual_sites: tuple[str, ...])[source]
Bases:
objectDescription of a residue from the Chemical Component Dictionary (CCD).
Attributes
The 3-letter residue code used in PDB files, or
Noneif only used anonymously.A longer description of the residue
Description of how this residue may bond to its neighbours in a polymer
Optional description of a crosslink between this residue and another.
The atom definitions that make up this residue.
The bond definitions that make up this residue
Atom names that represent virtual sites.
Constructor Methods
Create an anoymous
ResidueDefinitionfrom anopenff.toolkit.Molecule.Create an anonymous residue definition from an SDF file of a single molecule
Create an anonymous
ResidueDefinitionfrom a SMILES string.Create an anonymous
ResidueDefinitionfrom a partially mapped SMILES.Create a linking
ResidueDefinitionfrom anopenff.toolkit.MoleculeCreate a
ResidueDefinitionfrom anopenff.toolkit.Molecule.Create a
ResidueDefinitionfrom a mapped SMILES string.Instance and Static Methods
Iterator over atoms bonded to the one with the given canonical name.
All bonds to the given atom, ordered with
atom1as the given atom.Return a copy of
selfwith protonnameabstracted.Return a copy of
selfwithheavy_atom_nameprotonated byproton_name.Perform a SMARTS reaction on some residue definitions
Return a copy of
selfwith the specified attributes replaced.Create a
Moleculerepresenting the complete, unlinked residue.Compute all combinations of the specified protonation variants
Return a copy of self with the given synonyms added
Properties
Map from each atoms' name and synonyms to the atom definition.
Trueif atom names may be used for matching,Falseotherwise.The number of non-leaving atoms in the residue.
The number of atoms that a matching residue without any linkages has.
Map from each atoms' name and synonyms to the atom definition.
- classmethod anon_from_molecule(molecule: Molecule, description: str | None = None, virtual_sites: Collection[str] = ()) Self[source]
Create an anoymous
ResidueDefinitionfrom anopenff.toolkit.Molecule.- Parameters:
molecule¶ – The
Moleculeobject. Leaving atoms are identified from the atom metadata; atom’s whose metadata includes a truthy value for the key"leaving_atom"are marked as leaving atoms.description¶ – An optional string describing the residue. Taken from
molecule"description"property ifNone. Seeopenff.pablo.ResidueDefinition.descriptionvirtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sites
- classmethod anon_from_sdf(file: str | Path | TextIO, description: str | None = None) Self[source]
Create an anonymous residue definition from an SDF file of a single molecule
- classmethod anon_from_smiles(smiles: str, leaving_atoms: Collection[int] = (), virtual_sites: Collection[str] = (), description: str | None = None) Self[source]
Create an anonymous
ResidueDefinitionfrom a SMILES string.- Parameters:
smiles¶ – The SMILES string.
leaving_atoms¶ – SMILES string mapping numbers for atoms that should be marked as leaving atoms.
description¶ – An optional string describing the residue. See
openff.pablo.ResidueDefinition.descriptionvirtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sites
- classmethod anon_from_smiles_marked_leaving(smiles: str, *, virtual_sites: Collection[str] = (), description: str | None = None) Self[source]
Create an anonymous
ResidueDefinitionfrom a partially mapped SMILES.The mapped atoms are treated as leaving atoms.
- Parameters:
smiles¶ – The SMILES string. Leaving atoms should be mapped. All other atoms must not be.
virtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sitesdescription¶ – An optional string describing the residue. See
openff.pablo.ResidueDefinition.description
- atoms: tuple[AtomDefinition, ...]
The atom definitions that make up this residue.
Atoms may be marked as leaving only if they are associated with a linking or crosslinking bond; see the API documentation for those fields. All atoms must have unique canonical names.
- atoms_bonded_to(atom_name: str) Iterator[str][source]
Iterator over atoms bonded to the one with the given canonical name.
- bonds: tuple[BondDefinition, ...]
The bond definitions that make up this residue
- bonds_to(atom_name: str) Iterator[BondDefinition][source]
All bonds to the given atom, ordered with
atom1as the given atom.
- property canonical_name_to_atom: dict[str, AtomDefinition]
Map from each atoms’ name and synonyms to the atom definition.
- crosslink: BondDefinition | None
Optional description of a crosslink between this residue and another.
A crosslink is a bond between this residue and another. Crosslinks differ from linking bonds primarily because they may occur between residues that are do not appear sequentially in the PDB file. Crosslinks cannot occur within a residue; use a bond or residue variant instead.
If the residue does not form cross links,
None. Otherwise, aBondDefinition. Theatom1andatom2attributes give the canonical atom names of the atoms that form the crosslink.atom1is the name of the atom in this residue, andatom2is in the other residue. Any atoms that the bond between residues replaces should be marked asatom.leaving=True; there must be either zero or one leaving fragments for each atom in a linking bond for the residue definition to validate, and there must be exactly one for a bond to form.A crosslink will be formed between two residues if and only if all of the below are true:
The two residues’
crosslinkattributes are identical except that their atom names are reversedAll leaving atoms associated with each residues’
crosslink.atom1attribute are absent in that residue. Leaving atoms are those that have theAtomDefinition.leavingattribute set toTrue. A leaving atom is associated with atom a if it is bonded to a, or it is bonded to a leaving atom associated with a.There is at least one leaving atom associated with each cross-linking atom
The charge of linking atoms is not modified; any change in valence is accounted for via the removal of leaving atoms.
- deprotonated_at(name: str) Self[source]
Return a copy of
selfwith protonnameabstracted.The hydrogen with canonical name
nameis removed, and the formal charge of the atom bonded to it is decremented. If the named atom is not hydrogen, is missing, or is bonded to a number of other atoms other than 1,PabloErroris raised.
- description: str
A longer description of the residue
- classmethod from_capped_molecule(molecule: Molecule, residue_name: str, leaving_atom_indices: Collection[int], linking_bond: BondDefinition, crosslink: BondDefinition | None = None, virtual_sites: Collection[str] = (), description: str | None = None) Self[source]
Create a linking
ResidueDefinitionfrom anopenff.toolkit.Molecule- Parameters:
residue_name¶ – The 3-letter code used to identify the residue in a PDB file. See
openff.pablo.ResidueDefinition.residue_namemolecule¶ – The
Moleculeobject. Canonical names are taken from the atom names in this object. Synonyms are never set.leaving_atom_indices¶ – Indices of atoms within the
moleculeargument that should be marked as leaving atoms. Seeopenff.pablo.residue.AtomDefinition.leavinglinking_bond¶ – The bond linking this residue to its neighbours in a polymer. See
openff.pablo.ResidueDefinition.linking_bondcrosslink¶ – See
openff.pablo.ResidueDefinition.crosslinkdescription¶ – An optional string describing the residue. See
openff.pablo.ResidueDefinition.descriptionvirtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sites
- classmethod from_molecule(molecule: Molecule, residue_name: str | None = None, description: str | None = None, linking_bond: BondDefinition | None = None, crosslink: BondDefinition | None = None, virtual_sites: Collection[str] = ()) Self[source]
Create a
ResidueDefinitionfrom anopenff.toolkit.Molecule.- Parameters:
molecule¶ – The
Moleculeobject. Canonical names are taken from the atom names in this object. Leaving atoms are identified from the atom metadata; atom’s whose metadata includes a truthy value for the key"leaving_atom"are marked as leaving atoms. Synonyms are never set.residue_name¶ – The 3-letter code used to identify the residue in a PDB file. If
None, takes name from atom’s"residue_name"metadata entry, or raisesValueErrorif they do not all agree. See alsoopenff.pablo.ResidueDefinition.residue_namelinking_bond¶ – Residue linking bond. May be taken from
molecule"linking_bond"property ifNone. Seeopenff.pablo.ResidueDefinition.linking_bondcrosslink¶ – Residue crosslink. May be taken from
molecule"crosslink"property ifNone. Seeopenff.pablo.ResidueDefinition.crosslinkvirtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sitesdescription¶ – An optional string describing the residue. Taken from
molecule"description"property ifNone. Seeopenff.pablo.ResidueDefinition.description
- classmethod from_smiles(mapped_smiles: str, atom_names: Mapping[int, str], residue_name: str, leaving_atoms: Collection[int] = (), linking_bond: BondDefinition | None = None, crosslink: BondDefinition | None = None, virtual_sites: Collection[str] = (), description: str | None = None) Self[source]
Create a
ResidueDefinitionfrom a mapped SMILES string.- Parameters:
residue_name¶ – The 3-letter code used to identify the residue in a PDB file. See
openff.pablo.ResidueDefinition.residue_namemapped_smiles¶ – The SMILES string. All atoms must be explicitly included with contiguous mapping numbers starting at 1.
atom_names¶ – Mapping from SMILES string mapping numbers to the canonical atom name. Note that this refers to numbers in the actual SMILES string, and so keys should be contiguous integers starting at 1. Atom names must be unique.
leaving_atoms¶ – SMILES string mapping numbers for atoms that should be marked as leaving atoms.
linking_bond¶ – The bond linking this residue to its neighbours in a polymer. See
openff.pablo.ResidueDefinition.linking_bondcrosslink¶ – See
openff.pablo.ResidueDefinition.crosslinkdescription¶ – An optional string describing the residue. See
openff.pablo.ResidueDefinition.descriptionvirtual_sites¶ – Virtual sites expected by the residue. See
openff.pablo.ResidueDefinition.virtual_sites
- property is_anonymous: bool
Trueif atom names may be used for matching,Falseotherwise.
- linking_bond: BondDefinition | None
Description of how this residue may bond to its neighbours in a polymer
If the residue is only found as a monomer,
None. Otherwise, aBondDefinition. Theatom1andatom2attributes give the canonical atom names of the atoms that form the linking bond.atom1is the name of the atom in the residue preceding the bond, andatom2is in the residue after the bond. Any atoms that the bond between residues replaces should be marked asatom.leaving=True; there must be either zero or one leaving fragments for each atom in a linking bond for the residue definition to validate, and there must be exactly one for a bond to form.A linking bond will be formed to join two residues if and only if all of the below are true:
The residues’ atom records are sequential in the PDB file
The residues have the same chain ID
There is no TER record between the residues in the PDB file
The two residues have identical
linking_bondattributesAll leaving atoms associated with
linking_bond.atom1are absent in the first encountered residue, and all leaving atoms associated withlinking_bond.atom2are absent in the latter residue. Leaving atoms are those that have theAtomDefinition.leavingattribute set toTrue. A leaving atom is associated with atom a if it is bonded to a, or it is bonded to a leaving atom associated with a.There is at least one leaving atom associated with each linking atom
The charge of linking atoms is not modified; any change in valence is accounted for via the removal of leaving atoms.
- property n_core_atoms: int
The number of non-leaving atoms in the residue.
Excludes virtual sites. A matching residue can have no fewer than this many atoms.
- property n_expected_atoms: int
The number of atoms that a matching residue without any linkages has.
In practice, the number of atoms including leaving atoms, plus the number of virtual sites. A residue with linkages can have no more than this many atoms.
- property name_to_atom: dict[str, AtomDefinition]
Map from each atoms’ name and synonyms to the atom definition.
- protonated_at(heavy_atom_name: str, proton_name: str, ignore_synonym_clashes: bool = False) Self[source]
Return a copy of
selfwithheavy_atom_nameprotonated byproton_name.The formal charge of the atom with canonical name
heavy_atom_nameis incremented, a new hydrogen atom namedproton_nameis added, and a bond is created between the two named atoms. If the heavy atom is missing or the new proton name clashes with an existing name or synonym,PabloErroris raised. The new atom has the same value for theleavingattribute as the heavy atom. The synonym clash check may be suppressed with theignore_synonym_clashesargument, but the canonical names are always checked.
- static react(reactants: Sequence[ResidueDefinition], reactant_smarts: Sequence[str], product_smarts: Sequence[str], product_residue_names: Sequence[str | None] | None = None, product_descriptions: Sequence[str | None] | None = None, product_linking_bonds: Sequence[BondDefinition | None] | None = None, product_crosslinks: Sequence[BondDefinition | None] | None = None, product_virtual_sites: Sequence[Collection[str]] | None = None) list[tuple[ResidueDefinition, ...]][source]
Perform a SMARTS reaction on some residue definitions
- Parameters:
reactants¶ – The residue definitions involved in the reaction. Names and synonyms for the products are taken from these. Chemical information is also derived from these, but may be modified by the reaction.
reactant_smarts¶ – Mapped SMARTS patterns identifying atoms in the reactants that will be involved in the reaction. There may be more or fewer of these than reactants to allow for complex and intramolecular reactions.
product_smarts¶ – Mapped SMARTS patterns describing any altered chemistry in the products. All atom mappings in the reactant smarts must be present in a product SMARTS. Each product SMARTS corresponds to a single product
ResidueDefinition.product_residue_names¶ – The residue names of the products. One for each product SMARTS. May be
Noneor omitted, in which case the product is anonymous — note that this means atom names in the reactants are discarded. If there are fewer residue names than product SMARTS, any unnamed products are made anonymous.product_descriptions¶ – The descriptions of the products. If there are fewer descriptions than product SMARTS, the given descriptions are assigned to the first products.
product_linking_bonds¶ – The linking bonds of the products. If there are fewer linking bonds than product SMARTS, the given linking bonds are assigned to the first products. Must be
Noneor omitted if the product is anonymous.product_crosslinks¶ – The crosslinks of the products. If there are fewer crosslinks than product SMARTS, the given crosslinks are assigned to the first products. Must be
Noneor omitted if the product is anonymous.product_virtual_sites¶ – The virtual sites of the products. If there are fewer virtual sites than product SMARTS, the given virtual sites are assigned to the first products.
- replace(*, residue_name: str | __UNSET__ = __UNSET__(), description: str | __UNSET__ = __UNSET__(), linking_bond: BondDefinition | None | __UNSET__ = __UNSET__(), crosslink: BondDefinition | None | __UNSET__ = __UNSET__(), atoms: Iterable[AtomDefinition] | __UNSET__ = __UNSET__(), bonds: Iterable[BondDefinition] | __UNSET__ = __UNSET__(), virtual_sites: Iterable[str] | __UNSET__ = __UNSET__()) Self[source]
Return a copy of
selfwith the specified attributes replaced.
- residue_name: str | None
The 3-letter residue code used in PDB files, or
Noneif only used anonymously.
- to_openff_molecule() Molecule[source]
Create a
Moleculerepresenting the complete, unlinked residue.
- vary_protonation(*, acidic: Iterable[str] = (), basic: Iterable[tuple[str, str]] = (), ignore_synonym_clashes: bool = False, skip_errors: bool = False) list[Self][source]
Compute all combinations of the specified protonation variants
The first element of the returned list is guaranteed to be the unmodified starting residue definition; to get a list of just the new variants, use
resdef.vary_protonation(...)[1:].Note that all combinations of protonations and deprotonations are generated; this means that if
acidichas lengthnandbasichas lengthm,2**(n+m)variants will be generated.- Parameters:
acidic¶ – Each element specifies an atom name to remove, decrementing the formal charge on the neighbouring heavy atom. Multiply bonded, unbonded, missing or non-hydrogen atoms raise
PabloErrorunlessskip_errorsisTrue.basic¶ – Each tuple specifies an atom name to protonate (increment the formal charge and form a bond) and the name of the added proton. Missing heavy atoms or new atom names that clash with existing names raise
PabloErrorunlessskip_errorsisTrue.ignore_synonym_clashes¶ – If set to
True, protons added by thebasicargument may have names that clash with the synonyms of other atoms. This can be useful in the early stages of a multi-step residue definition patching process. Added protons may never have names that clash with the canonical names of other atoms.skip_errors¶ – If set to
True, missing, clashing, or improperly bonded atoms are skipped rather than raisingPabloError.