mlchem.chem.manipulation.mol_from_string

mol_from_string(mol_input: str) Mol

Convert a molecular string (InChI or SMILES) to an RDKit molecule object.

Attempts to interpret the input string as an InChI first, then as a SMILES. Raises a ValueError if both conversions fail.

Parameters:

mol_input (str) – A string representing a molecule in InChI or SMILES format.

Returns:

RDKit molecule object corresponding to the input string.

Return type:

rdkit.Chem.rdchem.Mol

Raises:

ValueError – If the input string is not a valid InChI or SMILES.