schrodinger.application.jaguar.csmiles.dihedral module

class schrodinger.application.jaguar.csmiles.dihedral.Dihedral(rank: int | float, bond: rdkit.Chem.rdchem.Bond | None = None, peeking_from: rdkit.Chem.rdchem.Atom | None = None, dihedral: float | None = None, second: rdkit.Chem.rdchem.Atom | None = None, third: rdkit.Chem.rdchem.Atom | None = None, collinearity: Collinearity = Collinearity.NONE, collin_steps: int = 0, is_implicit: bool = False)

Bases: object

Helper structure to track dihedral quads when peeking ahead to order symmetric branches and ring ordering.

first: Optional[SmilesAtom] = None
final: rdkit.Chem.rdchem.Atom | None = None
collinear_third: rdkit.Chem.rdchem.Atom | None = None
sorting_only: bool = False
is_ring_close: bool = False
__init__(rank: int | float, bond: rdkit.Chem.rdchem.Bond | None = None, peeking_from: rdkit.Chem.rdchem.Atom | None = None, dihedral: float | None = None, second: rdkit.Chem.rdchem.Atom | None = None, third: rdkit.Chem.rdchem.Atom | None = None, collinearity: Collinearity = Collinearity.NONE, collin_steps: int = 0, is_implicit: bool = False)
rank: int | float
bond: rdkit.Chem.rdchem.Bond | None
peeking_from: rdkit.Chem.rdchem.Atom | None
dihedral: float | None = None
second: rdkit.Chem.rdchem.Atom | None = None
third: rdkit.Chem.rdchem.Atom | None = None
collinearity: Collinearity = 'not collinear'
collin_steps: int = 0
is_implicit: bool = False
static ForwardCollinDihedral()

Return a default Dihedral object marking a forwards-collinear dihedral.

formatted(precision: int) str

Return the dihedral angle as a formatted string accounting for collinearity. Any forwards collinearity is printed as “!”, if only backwards collinearity is present then the number of collinear steps must be printed before the angle.

Parameters:

precision – The precision to round the angle to.

Returns:

The formatted string representation of the dihedral angle.

get_graph_next() Atom

When building the graph a dihedral can be peeked from either the third or the second atom. This returns the downstream atom of the bond pair around which the angle is defined.

set_collinearity(collinearity: Collinearity, collin_steps: int)

Set the collinearity character of the dihedral.

printable() bool

Returns True if this dihedral should be printed, False otherwise (e.g. is angle is undefined due to collinearity or no final atom exists).

get_as_atom_indices() tuple[int, int, int, int] | None

Returns the atom indices for each atom in the dihedral, in the order they appear.

Returns:

The quad of atom indices for all atoms or None if no such quad exists.

get_as_csmiles_indices() tuple[int | str, int, int, int | str] | None

Returns the atom CSMILES indices for each atom in the dihedral, in the order they appear. If an atom in the quad is implicit then this is indicated by ‘H’, which can only occur at the start and end of the string.

Raises:

KeyError – If const.CSMILES_ORDER_KEY has not been set.

Returns:

The quad of CSMILES indices or ‘H’ if the atom is implicit.

class schrodinger.application.jaguar.csmiles.dihedral.ReadDihedral(forward: list[Dihedral], back: list[float])

Bases: object

Helper structure to keep forward and backward dihedrals together.

forward: list[Dihedral]
back: list[float]
__init__(forward: list[Dihedral], back: list[float]) None
schrodinger.application.jaguar.csmiles.dihedral.process_dihedral_string(substr: str, minimal: bool) tuple[int, ReadDihedral]

Given a conformer SMILES formated string of dihedrals, return the dihedrals and the offset of the end of the set from the substring passed. e.g. calling on {123,234,3}CCN(C)C returns 11 as the offset and [123, 234, 3].

Parameters:
  • substr – The conformer SMILES substring to be parsed for leading dihedral block. Should start with the block open delimiter corresponding to the minimal parameter.

  • minimal – If True flag that we are using the minimal set of delimiters.

Returns:

The offest in substring where the block ends and the list of dihedrals read.

schrodinger.application.jaguar.csmiles.dihedral.munge_dihedral_angle(angle: float | None, precision: int) float

Process an angle into standard form for comparison by truncating it to the requested precision and casting None to np.inf so it is always sorted last.

Parameters:
  • angle – The dihedral angle to be munged, can be None if no angle exists.

  • precision – If positive this is the bin size to round the angle into with the first bin centered on zero and must be an integer divisor of 360. If it is negative then this is the number of decimal places rounded to instead. See format_dihedral.

Returns:

The munged angle suitable for sorting.

schrodinger.application.jaguar.csmiles.dihedral.format_dihedral(dihedral: float | None, precision: int, make_positive: bool = True) str

Format a dihedral angle into the desired string representation. This rounding is somewhat complicated by the wish to center the first bin on 0.0, as this is a common dihedral angle so it is better that it not be on a threshold. e.g. if precision is 5, then the first bin is [357.5, 2.5) -> 0 Alternatively if the precision is negative then this is the number of decimal places we should round to.

If the dihedral is None (e.g. there is no dihedral possible) then we return an empty string.

Parameters:
  • dihedral – The angle to format.

  • precision – If positive this is the bin size to round the angle into with the first bin centered on zero and must be an integer divisor of 360. If it is negative then this is the number of decimal places rounded to instead.

  • make_positive – If true then dihedral is wapped around 360 to make a positive angle.

Returns:

The formatted string representation of the angle.

schrodinger.application.jaguar.csmiles.dihedral.get_bonded_dihedrals_sorted(atom: Atom, ignore: list[int] | None = None) tuple[list[Dihedral], list[Dihedral]]

Get the atoms bonded to this atom as unfilled Dihedral objects sorted by symmetry rank. Ties are not broken as we do not know dihedral angles at this point.

Parameters:
  • atom – The atom to find the bonded atoms from.

  • ignore – The list of atom indices that should be ignored as already expanded.

Returns:

The bonded explicit atoms and the bonded implicit atoms.

schrodinger.application.jaguar.csmiles.dihedral.dihedral_sort(dihedral: Dihedral) tuple[float, float]

Sorting key to sort by symmetry group rank and dihedral angle, handling implicit atoms which do not have a symmetry group.

Parameters:

dihedral – The Dihedral object to be keyed.

Returns:

(symmetry_rank, dihedral_angles), symmetry_rank is np.inf for implicit atoms so this always sorts last. Dihedrals is a tuple assumed sorted in canonical order.

schrodinger.application.jaguar.csmiles.dihedral.lexi_before(csmiles1: str, csmiles2: str, representation: Representation, minimal: bool = False) bool

Wrapper function for sorting CSMILES into lexicographical order in any representation. An empty string always sorts last.

Parameters:
  • csmiles1 – The first CSMILES string for checking.

  • csmiles2 – The second CSMILES string for checking.

  • representation – The format of the CSMILES to sort.

  • minimal – Flag that we are using the minimal set of delimiters for INSET notation. Has no effect otherwise.

Returns:

True if csmiles1 < csmiles2, else False.

schrodinger.application.jaguar.csmiles.dihedral.format_dihedral_dict(dihedrals: dict[tuple[int | str, int, int, int | str], float], precision: int) str

Format a dictionary of dihedral keys mapping to dihedral angles into a string list for suffix notation.

Parameters:
  • dihedrals – The dictionary mapping quads of CSMILES indices onto the respective dihedral angle.

  • precision – The precision to which the angles should be binned.

Returns:

The formatted string of the dictionary.

schrodinger.application.jaguar.csmiles.dihedral.format_dihedral_block(d_strs: list[str], back_d_strs: list[str], minimal: bool) list[str]

Helper function to format a list of dihedral angle strings into a CSMILES dihedral block. If this is an empty list then return an empty list, no block is needed. If the list is a single forwards collinear case then we omit the dihedral block delimiters, { and } usually. Otherwise, wrap the list of angles in opening and closing delimiters.

Parameters:
  • d_strs – The list of string formatted dihedrals for the block.

  • back_d_strs – The list of string formatted back-dihedrals for the block.

  • minimal – Flag that we should use the minimal set of delimiters for greater compression sacrificing readability.

Returns:

The bond’s dihedrals formatted as a dihedral block. This list is empty if no block is needed.

schrodinger.application.jaguar.csmiles.dihedral.sort_to_canonical(explicits: list[Dihedral]) list[Dihedral]

Given a list of possible dihedrals to follow, sort them into the canonical order. First priority is RDKit’s symmetry rank, so ascending const.SYM_GROUP_KEY order. If two atoms share a symmetry group then we must do secondary sorting based on ascending dihedral angle(s), to break ties between symmetric groups. Return the sorted list.

Parameters:

explicits – List containing the dihedrals in to the next possible atoms that explicitly appear in the graph.

Returns:

The list sorted into dihedral order.