schrodinger.structutils.assignbondorders module¶
A module to assign bond orders based on molecular geometry.
Assigns double and triple bonds to structures based on molecular geometry (bond length, bond angles, and dihedral angles). Useful when importing ligands from PDBs into Maestro. Please check the output structure for errors and compare it to the molecular formula. If this script assigns bond orders incorrectly to a reasonable structure, please email the maestro file of the structure to help@schrodinger.com.
There is a single public function:
assignbondorders.assign_st(input_st, atoms=None, neutralize=False,
problem_only=False, skip_assigned_residues=True,
_logger=None)
Assigns bond orders to atom list [atoms] of structure input_st and returns a list of bonds that were adjusted. Bond orders are assigned for all atoms if the atoms list is empty or not specified.
Copyright (c) Schrodinger, LLC. All rights reserved.
- schrodinger.structutils.assignbondorders.debuggroup(msg)[source]¶
For debugging group bond assignments
- schrodinger.structutils.assignbondorders.debugbonders(msg)[source]¶
For debugging aromatic ring assignments
- schrodinger.structutils.assignbondorders.debugbond(msg)[source]¶
For debugging code that calculates bond “scores”
- schrodinger.structutils.assignbondorders.get_single_bond_length(a1, a2)[source]¶
Returns ideal length of a single-order bond between specified atoms. If either of the atoms is non-common, returns 0.0.
- schrodinger.structutils.assignbondorders.get_neighbors(st, atom)[source]¶
Returns a list of atoms that <atom> is bound to.
- schrodinger.structutils.assignbondorders.calculate_average_angle(st, atom_num)[source]¶
Calculates the average of all bond angles around the input atom. Returns 0 if the angle can not be calculated. Close to 109 degrees = tetrahedral Close to 120 degrees = planar Close to 180 degrees = linear
- schrodinger.structutils.assignbondorders.calculate_dihedral(st, a1, a2)[source]¶
Calculates the average dihedral angle of the bond between the specified atoms. Close to 0 (zero) is likely to be double bond.
- schrodinger.structutils.assignbondorders.order_ring_or_chain(st, atoms)[source]¶
This function orders the atoms in the ring or chain by bonding order.
- class schrodinger.structutils.assignbondorders.CCDAtomMapper(use_chirality)[source]¶
Bases:
schrodinger.comparison.atom_mapper.ConnectivityAtomMapper
Class for determining most ideal mapping of a CCD SMILES structure to a 3D ligand conformation.
- score_mapping(ccd_st, st, atset)[source]¶
This method is called to “score” a given mapping. Here, both input structures have been re-ordered to have the same atom ordering, and <atset> is a set of atoms that are “shared” between the 2 structures.
- ATOM_TYPE = 's_m_custom_atom_type'¶
- MAPPER_INDEX = 'i_m_atom_mapper_index'¶
- __init__(use_chirality)¶
- Parameters
use_chirality (boolean) – if True, in addition to element type use chirality (where defined) to equate atoms.
- are_conformers(st1, atlist1, st2, atlist2)¶
Determine if the two substructures, as defined by the atom lists, are conformers but do not explore isomorphisms.
- Parameters
- Returns
boolean indicating whether or not the two structures are conformers
- are_consistently_ordered_conformers(st1, st2, atlist)¶
Determine if two substructures are consistently ordered conformers. That is, they have the same atom numbering and bonding
- are_enantiomers(st1, atlist1, st2, atlist2)¶
Determine if the two substructures, as defined by the atom lists, are enantiomers but do not explore isomorphisms.
- Parameters
- Returns
boolean indicating whether or not the two structures are conformers
- comparator(d1, d2)¶
Comparison function to be used to determine if two nodes on graph are equivalent.
If this method is not used when constructing a GraphMatcher, node attributes will not be considered for the purpose of determining isomorphism.
- Parameters
d1 (dict) – key=value dictionary from graph returned from st_to_graph which represents node 1
d1 – key=value dictionary from graph returned from st_to_graph which represents node 2
- Returns
boolean indicating equilvalence
- get_atom_type(at)¶
This value is used as an atom property
- Parameters
at (_StructureAtom) – atom we wish to obtain a type for
- Returns
string which identifies atom type
- initialize_atom_types(st, invert_stereocenters=False)¶
Initialize the atom types
- Parameters
st (Structure) – structure containing atoms
invert_stereocenters (boolean) – whether or not R/S labels should be flipped
- invert_chirality(ch_list)¶
Invert the chirality (R/S) of an input list of chiralities.
- Parameters
ch_list (list of strings) – list of chirality labels for a structure
- isomeric_atom_sets(st1, atset1, st2, atset2)¶
Check that the atom types in atset1 are the same as those in atset2. If not, the two structures cannot be conformers.
- Parameters
- Returns
a boolean indicating if these atom lists are isomeric
- reorder_structures(st1, atlist1, st2, atlist2, invert_stereocenters=False)¶
Reorder the atoms in the two structures.
- Parameters
- Returns
the two structures with structure 2 having had atoms reordered
- score_is_equivalent(score1, score2)¶
determines if score should be considered equivalent
- Parameters
score1 (float) – the first score
score2 (float) – the second score
- set_atom_type(at, value)¶
Set the value of the atom type
- Parameters
at (_StructureAtom) – atom we wish to set type for
value (string) – set the type of atom to this
- st_to_graph(st, atset)¶
Convert Structure instance to a networkx Graph using _StructureAtom instances as nodes and adding an atom type property
- Parameters
st (Structure) – the structure to convert
atset (set of ints) – a set of atoms to use to create the graph
- Returns
networkx Graph
- unique_job_name(base_name)¶
Add an integer to the end of the base_name to get a unique name.
- Parameters
base_name (str) – base job name
- class schrodinger.structutils.assignbondorders.AssignBondOrders(st, atoms, neutralize)[source]¶
Bases:
object
- getNumNeighbors(atom)[source]¶
Returns a the number of atoms that <atom> is bound to. EXCLUDING zero-order bonds
- fixFormalCharge(atom)[source]¶
Adjusts the formal charge so that it is valid for number of bonds and bond orders.
- setBondOrder(atom1, atom2, bond_order)[source]¶
Sets the bond order between atom1 and atom2 to bond_order.
- getExtracyclicAtom(ring, a)[source]¶
Given an atom of a ring, return the extra-cyclic atom that is bound to this atom.
- calcBondScore(a1, a2, distance_weight=1.0, ring_angle_weight=0.0)[source]¶
Calculates the probability that the two atoms are double bonded to each other.
- getBestDoubleBond(a1, a2, a3)[source]¶
Returns a list of two atoms that are the best candidates. Returns [] if neither bond is potential double bond.
- sortFirstThreeOfGroup(atom_group)[source]¶
This function sorts the atoms in the group so that the 3 (or 4) atoms that need to be worked on the first will be listed first.
- resolveTriangularGroup(atoms)[source]¶
Assign a double bond to “best” bond pair in the set. If any bond score is under the double bond threshold and is also “terminal”, remove it from further consideration for double bonding.
Input atom list must be sorted: the first atom in the list must be central, and the three next atoms are bonded to it in a star-like arrangement.
If all three neighbors have bonds scores above the threshold, the one with the highest score is turned into a double bond. Else, the one with the lowest score is removed from the set to avoid infinite recursion.
In case of symmetrical inputs, 2 or more bonds may have the same length, etc, and ties may happen. We need a non-geometrical criterion to resolve ties in a reproducible manner. For this reason, use atom indexes as a secondary criterion.
- assignGroupDoubleBonds(atom_set)[source]¶
Assigns double bonds where appropriate for the atoms in the supplied group.
- isRingAromatic(ringatoms)[source]¶
Returns a boolean - whether the specified ring is aromatic or not. Aromatic ring is defined in this context as a 5 or 6 membered ring that is likely, based on bond lengths and angles, etc. to be an aromatic ring.
ringatoms are assumed to be in connectivity order.
- isAtomBetweenTwoRings(atom)[source]¶
Returns True if this atom is bound to two rings, but is not part of a ring itself. Like this: Ring-X-Ring. Such an atom may get a double bond to one of the rings if needed.
- isAtomBoundToAromaticRing(atom)[source]¶
Returns True if at least one of atoms bound to it is a member of an aromatic ring.
- assignAromaticBonders(ring, bonders)[source]¶
Assigns bond orders for the supplied 5 or 6-membered aromatic ring. Returns True if successful, False if not.
<bonders> is a list of atoms that MUST get double-bonded.
- determineAromaticAtomType(ring, a, ring_group_atoms)[source]¶
Determines the type of the atom in the aromatic ring.
- determineAromaticAtomTypes(ring, ring_group_atoms)[source]¶
Goes through every atom in the supplied aromatic ring, and determines what type of atom it is, then adds the atom to that category. It returns a dictionary (list) of atoms in different groups.
- assignGroupTripleBonds(atom_group)[source]¶
Assigns triple bonds as appripriateley to the atoms in the supplied group. Returns a list of atoms which now have assigned bond orders.
- assignAromaticRing(ring, ring_group_atoms)[source]¶
Returns ASSIGNED_AROMATIC if everything is okay. Returns NOT_AROMATIC if the ring is not aromatic. Returns NOT_ASSIGNED if this ring should be considered later.
- findAromaticBonders(ring, ringatomtypes_dict)[source]¶
Returns a list of suggested bonding atoms in the specified aromatic ring. Returns [] if no bonds should be made.
If “required_only” is set, return only the REQUIRED BONDERS and REQUIRED NON-BONDERS
Raises RuntimeError(“Not aromatic”) if the ring is not aromatic. Raises RuntimeError(“Not assigned”) if the ring could not be assigned.
- getNeighboringRings(ring, rings)[source]¶
Return a list of rings that share atoms with the specified ring.
- assignAromaticRingGroup(group)[source]¶
Assigns bond orders of aromatic rings (5 & 6 membered) which are arranged in a group (multi-cyclic systems).
- fixKetones()[source]¶
This function adds double bonds to ketones and aldehydes when necesary. It should be run only after ALL other bond orders have been assigned.
- fix_N4s()[source]¶
Sets the macromodel atom type of Positively Charged Nitrognes to N4(31/sp2) or N5(32/sp3).
- schrodinger.structutils.assignbondorders.get_ring_atom_coords(st, ring_atoms)[source]¶
Get the coordinates of the ring atoms as a numpy array.
If
st
has periodic boundary conditions (PBC), the coordinates returned will all be in the frame of reference of the first atom in ring_atoms.
- schrodinger.structutils.assignbondorders.get_edge_normals(ring_atom_coords)[source]¶
Get vectors normal to the planes described by each ring-edge and the center of the ring.
Assumes that atoms are in order.
- schrodinger.structutils.assignbondorders.calculate_planarity(st, ring_atoms)[source]¶
Calculate the ring planarity.
Very planar rings have a planarity of < 1.
Assumes that atoms are in order.
- exception schrodinger.structutils.assignbondorders.CCDStructureMismatchError[source]¶
Bases:
RuntimeError
raise this error when structure in CCD template doesn’t match HET
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception schrodinger.structutils.assignbondorders.SmilesGenerateError[source]¶
Bases:
RuntimeError
raise this error when RDKit fails to generate SMILES
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- schrodinger.structutils.assignbondorders.assign_st(st, atoms=None, neutralize=False, problem_only=False, skip_assigned_residues=True, use_ccd=False, _logger=None)[source]¶
Perform the assign-bond-order algorithm on the supplied structure. If the atom list is specified, only those atoms are fixed.
- Parameters
st (L{structure.Structure)) – Structure to assign bond orders in
atoms (list of ints) – List of atoms to assign. By default all atoms as assigned.
neutralize (bool) – Whether to protonate carboxylic acids.
problem_only (bool) – Whether to assign only to atoms with PDB convert problem of 4 (orange atoms). Not compatible with <atoms> argument.
skip_assigned_residues (bool) – If True, bond orders are not assigned to residues that have double or triple bonds, even if that residue’s atoms are in <atoms>. Not compatible with <problem_only> option.
use_ccd (bool) – Whether to use the Chemical Component Dictionary for hets that have records there. Not supported for covalent ligands.
_logger (logger) – logger to send messages to
- Returns
List of (atom1, atom2, order) for every bond whose order was altered.
- Return type
list of (int, int, int)
- schrodinger.structutils.assignbondorders.attempt_ccd_assignment(res, res_assign_atoms=None, _logger=None)[source]¶
Attempt to use the CCD record to assign the bond orders. Returns list of bonds that were assigned. Returns empty list if assignment was not successful.
- Parameters
res (structure._Residue) – Residue for the het to assign orders to.
res_assign_atoms (list(int)) – List of atoms (substructure from the residue) to assign bond orders to. By default all residue atoms are assigned.
_logger (logging.Logger) – Logger
- Returns
List of assigned bonds, as (index1, index2, bond order)
- Return type
list of (int, int, int)
- schrodinger.structutils.assignbondorders.orders_assigned(st, atoms=None, all=False)[source]¶
Returns True if all bond orders are OK in the specified structure. Can be given a list of atoms to check bond orders of. If not list is specified and all flag is set to True, all atoms are checked; otherwise only atoms with a PDB convert error (appear orange in Maestro) are checked. NOTE: atoms and all options are mutually exclusinve.