schrodinger.application.jaguar.csmiles.utils module¶
- schrodinger.application.jaguar.csmiles.utils.get_tags(smiles: str) tuple[list[str], str]¶
Find the ring atom tag at the beginning of a SMILES substring, if any. e.g. the substring “13CCCCC13” from the SMILES for a hexane ring will return [“1”,”3”] whereas butane “CCCC” would return and empty list and string as no tag is found.
Note that “%” is used before 2-digit ring specifiers. >2 digit specifiers are not formally supported by SMILES, but some implementations use them. We do not so %123 will be parsed as [“%12”, “3”].
We must also be careful that bonds can fall between tags, e.g. ‘C1=3’ meaning ring close to tag 1 and ring close with double-bond to tag 3. This function doesn’t return the bond types as this is contained within the Mol object that is being mapped to.
- Parameters:
smiles – The smiles substring to search.
- Returns:
The list of ring atom tags if any are found, else an empty list is returned, and the total string that was matched (empty if nothing was found).
- schrodinger.application.jaguar.csmiles.utils.format_tag(tag: int) str¶
Format the ring tag to account for tags > 9 needing to be preceded with ‘%’. Note that strictly speaking this is outside the SMILES spec, but it is commonly supported.
- Parameters:
tag – The integer ring tag to be processed.
- Returns:
The string representation of the tag, preceded by “%” if required.
- schrodinger.application.jaguar.csmiles.utils.parse_tag(tag: str) int¶
Parse a tag string into an integer by discarding any leading “%”
- Parameters:
tag – The tag string to be parsed.
- Returns:
The tag integer.
- schrodinger.application.jaguar.csmiles.utils.parse_charge(block: str) int¶
Parse the charge from a SMILES atom block.
- Parameters:
block – The string to parsed for sign symbols.
- Returns:
The parsed charge.
- schrodinger.application.jaguar.csmiles.utils.get_h_count(atom: Atom) int¶
Count the number of hydrogen that are bonded to the provided atom. This does not consider RDKit’s ideas of implicit and explicit atoms instead counting only hydrogen Atom objects.
- Parameters:
atom – The atom that will have its bonded hydrogen counted.
- Returns:
The number of hydrogen bonded to atom.
- schrodinger.application.jaguar.csmiles.utils.get_rdkit_intprop_default(atom: Atom, prop: str, default: int | float) int | float¶
Safely return a property from an RDKit atom if it exists, if it doesn’t then return the default.
- Parameters:
atom – The atom to take the property from.
prop – The property key.
default – The default value to return if the property is not found. This can be a float to allow np.inf as a value that always sorts last.
- Returns:
The property if it exists, otherwise the default value.
- schrodinger.application.jaguar.csmiles.utils.remove_unused_hydrogen(mol: Mol, dihedral_dict: dict[tuple[int, int, int, int], float]) tuple[rdkit.Chem.rdchem.Mol, dict[tuple[int, int, int, int], float]]¶
Remove all hydrogen from
molthat do not appear indihedral_dict. The re-mapped dihedral dict is returned along with the new Mol object. Hydrogen which appear indihedral_dictare not removed.- Parameters:
mol – The structure from which hydrogen should be removed.
dihedral_dict – The dictionary mapping dihedral quad to angle. Hydrogen that appear in this will not be removed.
- Returns:
A new Mol with the hydrogen removed, and an updated version of the input
dihedral_dictfor the new numbering.
- schrodinger.application.jaguar.csmiles.utils.set_dihedral_exclusive(mol: RWMol, quad: tuple[int, int, int, int], ang: float)¶
Set the dihedral on conformer 0 of an RDKit Mol such that only the final atom of the quad and its children are moved. This required temporarily breaking all bonds from the 3rd atom that are not directly in the dihedral.
- Parameters:
mol – The RWMol object to apply the dihedral to.
quad – The four atom indices for the dihedral in order.
ang – The angle to set the dihedral to.
- schrodinger.application.jaguar.csmiles.utils.wrapped_difference(a: float, b: float) float¶
Compute the smallest difference a - b, wrapping around 360 as necessary. i.e. what must be added to a to get to b.
- Parameters:
a – First angle
b – Second angle
- Returns:
The smallest difference between a and b, wrapping around 360 as necessary.
- schrodinger.application.jaguar.csmiles.utils.csmiles_print(msg: str, idx: int | None = None, runtime: float | None = None, latex_re: re.Pattern | None = None)¶
Print message. If passed and index and runtime are prepended.
- Parameters:
msg – The message to be printed.
idx – The index of the message being printed, omitted if None is passed.
runtime – The runtime in seconds for the message, omitted if None is passed.
latex_re – If true
msgwill have dihedral block markers escaped for latex printing.
- schrodinger.application.jaguar.csmiles.utils.torsional_distance(diffs: list[float]) float¶
Calculate the torsional difference metric as the simple Euclidean distance from the dihedral diffs.
- Parameters:
diffs – The list of dihedral difference angles.
- Returns:
The torsional distance metric.