schrodinger.application.jaguar.csmiles.decoding module

schrodinger.application.jaguar.csmiles.decoding.default_conf_from_smiles(smiles: str) Mol

Given a SMILES string return the default 3D structure for this with CSMILES_ORDER_KEY and SYM_GROUP_KEY properties set.

Parameters:

smiles – The SMILES string to generate a conformation for.

Returns:

A molecule built from smiles with conformer(0) set.

Raises:

ValueError – Raised if the SMILES string could not be parsed.

schrodinger.application.jaguar.csmiles.decoding.sdgr_default_conformer(mol: Mol) Mol

Given an RDKit Mol, clear all existing conformers and use Schrodinger Fast3d to generate a guess conformer, then return this as an RDKit Mol.

Parameters:

mol – The Mol to generate a conformer for.

Returns:

A new Mol object with conformer(0) set.

schrodinger.application.jaguar.csmiles.decoding.rdkit_default_conformer(mol: Mol, smiles: str) Mol

Clear all conformers and use RDKit’s ETKDGv3 to generate a guess conformer.

Un-used as we are guaranteed to be in the Schrodinger suite, but kept in case it becomes useful in the future.

Parameters:

mol – The Mol object to generate a conformer for. This is modified in-place, but a reference to it is also returned.

Returns:

The Mol passed in with confomer(0) set.

schrodinger.application.jaguar.csmiles.decoding.parse_csmiles_string(csmiles: str, template: rdkit.Chem.rdchem.Conformer | None = None, minimal_inset: bool = False, debug: bool = False) tuple[rdkit.Chem.rdchem.Mol, SmilesAtom, dict[tuple[int, int, int, int], float], list[tuple[int, int]]]

Analyze the SMILES string and build the graph of SmilesAtom objects.

We parse the SMILES string attaching atom objects to the SMILES string symbols as dictated by smiles_order. Directional bonding is set up such that the root atom returned can be recursively accessed to expand the graph.

Parameters:
  • csmiles – The CSMILES string to be indexed.

  • template – A template to which the conformer will be assigned. This defines the bond angles and bond lengths which would otherwise be determined by UFF.

  • minimal_inset – Flag if we are parsing a CSMILES string with full delimiters, or with the minimal set.

  • debug – Flag that we should print extra debugging information.

Returns:

The RDKit Mol object with Conformer(0) set, the root of the CSMILES graph, a dictionary mapping quads of atom indices in the RDKit mol to the CSMILES encoded dihedral angle, and a list of ring-close bonds as atom index pairs.

schrodinger.application.jaguar.csmiles.decoding.read_dihedral_block(csmiles: str, ptr: int, minimal_inset: bool) tuple[int, ReadDihedral]

Read a dihedral block, return the next dihedral, and increase the pointer to the end of the block.

Parameters:
  • csmiles – The full CSMILES string being read.

  • ptr – The current position in the CSMILES string.

  • minimal_inset – Flag if we are using minimal CSMILES form or not.

Returns:

The new ptr position and the Dihedral information that was read.

Raises:

ValueError – If the dihedral block is empty.

schrodinger.application.jaguar.csmiles.decoding.read_atom_block(csmiles: str, ptr: int, symbol: str, charge: int, atom: Atom, mol: Mol, previous: SmilesAtom | None, next_dihedral: ReadDihedral | None, tag_dict: dict[str, SmilesAtom], root: SmilesAtom | None, precision: int, closed_set: set[int], templating_error: str) int

Read an atom block from a SMILES string, e.g. [n+]. Updates previous

Parameters:
  • csmiles – The CSMILES string being parsed.

  • ptr – The current position in the CSMILES string.

  • symbol – The expected atomic symbol.

  • charge – The expected formal charge.

  • atom – The RDKit atom object we are expecting in the string.

  • mol – The Mol object this atom belongs to.

  • previous – The previously read SmilesAtom, if one exists.

  • next_dihedral – The dihedral information we have read for the bond going into this atom, if it exists.

  • tag_dict – The dictionary mapping

schrodinger.application.jaguar.csmiles.decoding.get_next_atom(previous: Atom, closed_set: set[int]) rdkit.Chem.rdchem.Atom | None

Given an atom and a set of atoms that should be ignored, return the next we should visit as that with the lowest symmetry group from those bonded to the atom that are not part of the ignored set.

If none exists then we return None instead.

Parameters:
  • previous – The atom for which bonded atoms should be found.

  • closed_set – The set of atom indices that should be ignored.

Returns:

The atoms bonded to previous that are not in closed_set.

schrodinger.application.jaguar.csmiles.decoding.apply_conformation(root: SmilesAtom) tuple[rdkit.Chem.rdchem.Mol, dict[tuple[int, int, int, int], float], list[tuple[int, int]]]

Apply the conformation stored in the SmilesAtom graph to the underlying RDKit conformer stored as root.conf by setting the dihedral angles to their respective values.

Parameters:

root – The root SmilesAtom object of the graph.

Returns:

The RDKit molecule object with the conformation imposed onto conformer 0, a dictionary mapping dihedral atom indices to angles, and a list containing the atom indices of all ring close bonds that should be broken in order to impose the dihedral angles in constraints.

schrodinger.application.jaguar.csmiles.decoding.create_ring_bonds(tags: list[str], tag_dict: dict[str, SmilesAtom], atom: SmilesAtom)

Attempt to create ring closing bonds by locating the ring start atom in the graph with the given tag. If no such atom has been found yet then the tag_dict is updated to record that this atom is the ring start atom. If an existing ring start atom is found then a ring_close_to bond is created pointing to the ring start atom found. If the tag passed is the empty string then this is a no-op.

Parameters:
  • tags – The ring tags to be found or created.

  • tag_dict – The dictionary mapping ring tag to SmilesAtom.

  • atom – The atom this tag applies to. If a ring start atom with this tag already exists then a ring_close_to bond is created from atom to the ring start atom. If the tag is not found then this atom is recorded as the ring start.

schrodinger.application.jaguar.csmiles.decoding.assign_rank_properties(mol: Mol, raw_smiles: str) tuple[rdkit.Chem.rdchem.Mol, int]

Attach symmetry rank properties to the atoms of the provided molecule object. Rank properties are not added to implicit hydrogen, such that explicit atoms can be distinguished from implicit atoms.

In rare cases, such as c1[nH]ccn1 RDKit’s substructure match can struggle due to the mesomer c1ncc[nH]1, which may lead to incorrect atom matching and an incorrect decoding for templated decoding.

Parameters:
  • mol – The molecule object to be annotated.

  • raw_smiles – The smiles string derived from the CSMILES string being parsed.

Returns:

Tuple of the molecule object with atoms annotated and the index of the root atom for the graph.

schrodinger.application.jaguar.csmiles.decoding.parse_cxsmiles(cxsmiles: str, debug: bool = False) tuple[rdkit.Chem.rdchem.Mol, dict[tuple[int, int, int, int], float], list[tuple[int, int]]]

Parse a CXSMILES string and use the dihedral information encoded to apply the conformation on the molecule.

Parameters:
  • cxsmiles – The CXSMILES string to parse.

  • debug – Flag if we should print extra debug information.

Returns:

The Mol object with the conformation set as conformer 0, a dictionary mapping quads of atom indices in the Mol object to the encoded dihedral, and a list of ring-close bonds as atom indices.

schrodinger.application.jaguar.csmiles.decoding.relax_driver(structure_list: list[rdkit.Chem.rdchem.Mol], constraint_list: list[dict[tuple[int, int, int, int], float]]) list[rdkit.Chem.rdchem.Mol]

Driver function for relaxing decoded structures with dihedral angle constraints imposed. Uses Schrodinger OPLS force-field if available, otherwise falls back to the UFF in RDKit.

Parameters:
  • structure_list – The list of structures to be relaxed.

  • constraint_list – A list of dictionaries mapping quads of atom indices defining dihedrals to the encoded angle.

Returns:

A list of relaxed structures in the same order as structure_list input.

schrodinger.application.jaguar.csmiles.decoding.relax_structure_opls(mol: Mol, constraints: dict[tuple[int, int, int, int], float], ff_handle: int) Mol

Relax the raw CSMILES structure using OPLS. The CSMILES angles are applied as restraints such that the encoded conformation is maintained. Bond angles, bond lengths, and dihedrals for implicit hydrogen are relaxed.

Parameters:
  • mol – The RDKit mol object containing the conformation.

  • constraints – A dictionary of Quad -> angle for each dihedral contained in the CSMILES string, 0-indexed to match mol.

  • ff_handle – OPLS forcefield handle instantiated outside for efficiency with multiple structures.

Returns:

A new Mol object with the relaxed geometry as conformation 0.

schrodinger.application.jaguar.csmiles.decoding.relax_structure_rdkit(mol: Mol, constraints: dict[tuple[int, int, int, int], float]) Mol

Relax a structure using RDKit’s UFF while constraining the dihedral angles.

Parameters:
  • mol – The Mol for which conformer 0 will be relaxed.

  • constraints – dictionary of atom index quads and the angle their torsion should be constrained to.

Returns:

The Mol object with conformer 0 relaxed.

schrodinger.application.jaguar.csmiles.decoding.get_csmiles_torsion_differences(ref_csmiles: str, other_csmiles: str, tolerance: float, precision: int, minimal_inset: bool) tuple[list[tuple[tuple[int | str, int, int, int | str], float]], str]

Get the dihedral differences between two CSMILES strings as a list of (CSMILES index, angle difference) pairs.

Parameters:
  • ref_csmiles – The reference CSMILES to compute the distance from.

  • other_csmiles – The other CSMILES to which the distance will be computed.

  • tolerance – The angle below which differences will be truncated.

  • precision – The pricision for the CSMILES analysis.

  • minimal_inset – Flag that the strings are minimal form CSMILES.

Raise:

ConnectivityMismatchException if the molecules do not have idnetical connectivity.

Returns:

A list of dihedral CSMILES index quads and corresponding angle difference, and the canonical CSMILES string for the reference mol.

schrodinger.application.jaguar.csmiles.decoding.get_mol_torsion_differences(ref_mol: Mol, other_mol: Mol, tolerance: float, precision: int) tuple[list[tuple[tuple[int | str, int, int, int | str], float]], str]

Get the dihedral differences between two conformers as a list of (CSMILES index, angle difference) pairs.

Parameters:
  • ref_mol – The reference conformer to compute the distance from.

  • other_mol – The other conformer to which the distance will be computed.

  • tolerance – The angle below which differences will be truncated.

  • precision – The pricision for the CSMILES analysis.

Raise:

ConnectivityMismatchException if the molecules do not have idnetical connectivity.

Returns:

A list of dihedral CSMILES index quads and corresponding angle difference, and the canonical CSMILES string for the reference mol.

schrodinger.application.jaguar.csmiles.decoding.get_graph_torsion_differences(ref_graph: SmilesAtom, other_graph: SmilesAtom, tolerance: float) list[tuple[tuple[int | str, int, int, int | str], float]]

Compute the difference in torsion angles between two molecular graphs.

Parameters:
  • ref_graph – The reference graph to compute the distance from.

  • other_graph – The other graph to which the distance will be computed.

  • tolerance – The angle below which differences will be truncated.

Raise:

ConnectivityMismatchException if the graphs do not have idnetical connectivity.

Returns:

A list of dihedral CSMILES index quads and corresponding angle difference.