examol.utils

Utilities that can be used across many types of operations

examol.utils.chemistry

Utility operations to perform common chemistry tasks

examol.utils.chemistry.get_baseline_charge(mol_string: str) int[source]

Determine the charge on a molecule from its SMILES string

Examples

H<sub>2</sub>O has a baseline charge of 0 NH<sub>4</sub>+ has a baseline charge of +1

Parameters:

mol_string – SMILES string of the molecule

Returns:

Charge on the molecule

examol.utils.chemistry.get_inchi_key_from_molecule_string(mol_string: str) str[source]

Get an InChI key from either SMILES or InChI

Parameters:

mol_string – String representing a molecule

Returns:

InChI key

examol.utils.chemistry.parse_from_molecule_string(mol_string: str) Mol[source]

Parse an RDKit molecule from either SMILES or InChI

Parameters:

mol_string – String representing a molecule

Returns:

RDKit molecule object

examol.utils.conversions

Converting between different descriptions of molecules

examol.utils.conversions.convert_nx_to_rdkit(graph: Graph) Mol[source]

Convert a networkx graph to a RDKit Molecule

Parameters:

graph (nx.Graph)

Returns:

Molecule to be converted

Return type:

(Chem.RWMol)

examol.utils.conversions.convert_nx_to_smiles(graph: Graph) str[source]

Compute a SMILES string from a networkx graph

examol.utils.conversions.convert_rdkit_to_nx(mol: Mol) Graph[source]

Convert a networkx graph to a RDKit Molecule

Parameters:

mol (Chem.RWMol) – Molecule to be converted

Returns:

(nx.Graph) Graph format of the molecule

examol.utils.conversions.convert_string_to_nx(mol_string: str) Graph[source]

Compute a networkx graph from a SMILES string

Parameters:

mol_string – InChI or SMILES string to be parsed

Returns:

(nx.Graph) NetworkX representation of the molecule

examol.utils.conversions.read_from_string(atoms_msg: str, fmt: str) Atoms[source]

Read an ASE atoms object from a string

Parameters:
  • atoms_msg – String format of the object to read

  • fmt – Format (cannot be autodetected)

Returns:

Parsed atoms object

examol.utils.conversions.write_to_string(atoms: Atoms, fmt: str, **kwargs) str[source]

Write an ASE atoms object to string

Parameters:
  • atoms – Structure to write

  • fmt – Target format

  • kwargs – Passed to the write function

Returns:

Structure written in target format