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.

class schrodinger.structutils.assignbondorders.AssignBondOrders(st, atoms, neutralize)
areAtomsOrtho(ring, atom1, atom2)
areCOsPara(ring, c1, c2)
assign()
assignAromaticBonders(ring, bonders)

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.

assignAromaticRing(ring, ring_group_atoms)

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.

assignAromaticRingGroup(group)

Assigns bond orders of aromatic rings (5 & 6 membered) which are arranged in a group (multi-cyclic systems).

assignAromaticRingOrders()

Assign all aromatic rings

assignChainOrders()
assignGroupDoubleBonds(atom_set)

Assigns double bonds where appropriate for the atoms in the supplied group.

assignGroupTripleBonds(atom_group)

Assigns triple bonds as appripriateley to the atoms in the supplied group. Returns a list of atoms which now have assigned bond orders.

assignTemplatedSubstructures()

Force assignment of known functional groups by SMARTS

assignTripleBonds()
calcBondScore(a1, a2, distance_weight=1.0, ring_angle_weight=0.0)

Calculates the probability that the two atoms are double bonded to each other.

determineAromaticAtomType(ring, a, ring_group_atoms)

Determines the type of the atom in the aromatic ring.

determineAromaticAtomTypes(ring, ring_group_atoms)

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.

findAromaticBonders(ring, ringatomtypes_dict)

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.

findAromaticRings()

Returns a list of aromatic rings in st within all_rings.

findPotentialTripleBondAtoms()

Returns a list of atoms that can potentially triple-bond.

findRings()

Returns a list of all rings in the st within the atoms range.

fixFormalCharge(atom)

Adjusts the formal charge so that it is valid for number of bonds and bond orders.

fixKetones()

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()

Sets the macromodel atom type of Positively Charged Nitrognes to N4(31/sp2) or N5(32/sp3).

forEdgeInRing(ring)

Iterates over (atom1, atom2) in the given ring

getAtomsRings(atom)

Return a list of rings that this atom is part of.

getBestDoubleBond(a1, a2, a3)

Returns a list of two atoms that are the best candidates. Returns [] if neither bond is potential double bond.

getElement(atomnum)
getExtracyclicAtom(ring, a)

Given an atom of a ring, return the extra-cyclic atom that is bound to this atom.

getNeighboringRings(ring, rings)

Return a list of rings that share atoms with the specified ring.

getNeighbors(atom)

Returns a list of atoms that <atomnum> is bound to.

getNeighborsObj(atom)

Returns a list of atoms that <atomnum> is bound to.

getNumBondOrders(atom)
getNumNeighbors(atom)

Returns a the number of atoms that <atom> is bound to. EXCLUDING zero-order bonds

getPotentialDoubleBondAtoms()

Returns a list of atoms that can potentially double bond. Only bond angles are considered.

groupAromaticRings()
identifyGroups()

Identifies groups and sets bond orders appropriately.

isAtomAromatic(atom)

Returns True if the given atom is part of an aromatic ring

isAtomBetweenTwoRings(atom)

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)

Returns True if at least one of atoms bound to it is a member of an aromatic ring.

isAtomInRing(atom)
isAtomInSmallRing(atom_num)

Returns 1 if atom_num is a ring with 3, 4, or 5 members.

isBondRingEdge(a1, a2, rings=None)
isKetoneCarbon(atom)
isOnlySingleBonded(atom)

Returns False if atom has double or triple bonds.

isRingAromatic(ringatoms)

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.

setBondOrder(atom1, atom2, bond_order)

Sets the bond order between atom1 and atom2 to bond_order.

setFormalCharge(atom, charge)
sortBondableAtomsByGroups(potential_double_bond_atoms)

Takes the list of input atoms, and puts them into groups, and returns a list of those groups. Atoms are considerred in the same group if they are bonded together (in the same chain).

sortFirstThreeOfGroup(atom_group)

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.

splitTriangularGroup(atoms)

breaks the group into 2 groups, breaking the weakest bond of the triangular arrangement.

exception schrodinger.structutils.assignbondorders.CCDAtomNumberMismatchError

Bases: exceptions.RuntimeError

raise this error when atom numbers in CCD templates don’t match HET

exception schrodinger.structutils.assignbondorders.SmilesGenerateError

Bases: exceptions.RuntimeError

raise this error when CANVAS fails to generate SMILES

schrodinger.structutils.assignbondorders.assign_st(st, atoms=None, neutralize=False, problem_only=False, skip_assigned_residues=True, use_ccd=False, _logger=None)

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.
  • _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.calculate_average_angle(st, atom_num)

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)

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.calculate_planarity(st, ring_atoms)

Calculate the ring planarity.

Very planar rings have a planarity of < 1.

Assumes that atoms are in order.

schrodinger.structutils.assignbondorders.debug(txt)

For general debug messages

schrodinger.structutils.assignbondorders.debugbond(msg)

For debugging code that calculates bond “scores”

schrodinger.structutils.assignbondorders.debugbonders(msg)

For debugging aromatic ring assignments

schrodinger.structutils.assignbondorders.debuggroup(msg)

For debugging group bond assignments

schrodinger.structutils.assignbondorders.do_rings_share_atoms(r1, r2)
schrodinger.structutils.assignbondorders.get_canonical_ordering(st, atoms)

Return a canonical ordering of all atoms in the given structure, based on unique SMILES after removing all bond orders and formal charges. Hydrogens must not be present in the <atoms> list.

Parameters:
  • st (structure.Structure) – Structure containing the het.
  • atoms (list of ints) – List of atom indices to get the ordering for.
Returns:

List of original atom indices in canonical order.

Return type:

list of ints

schrodinger.structutils.assignbondorders.get_edge_normals(ring_atom_coords)

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.get_neighbors(st, atom)

Returns a list of atoms that <atom> is bound to.

schrodinger.structutils.assignbondorders.get_ring_atom_coords(st, ring_atoms)

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_rings_in_group(ring, rings_to_check)
schrodinger.structutils.assignbondorders.get_single_bond_length(a1, a2)

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.order_ring_or_chain(st, atoms)

This function orders the atoms in the ring or chain by bonding order.

schrodinger.structutils.assignbondorders.orders_assigned(st, atoms=None, all=False)

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.

schrodinger.structutils.assignbondorders.warning(msg)