Chem

Chemistry related functions

RDKit i/o

Functions for converting between SMILES strings and RDKit mol objects


source

filter_valid_smiles

 filter_valid_smiles (smiles:list[str])

given a list of SMILES, filters list for SMILES that resolve to a valid molecule

Type Details
smiles list input list of SMILES strings
Returns list output list of valid SMILES strings

source

remove_stereo_smile

 remove_stereo_smile (smile:str)

removes stereochemistry from SMILES string

Type Details
smile str input SMILES string
Returns str output SMILES string

source

remove_stereo

 remove_stereo (mol:rdkit.Chem.rdchem.Mol)

removes stereochemistry from rdkit Mol

Type Details
mol Mol input rdkit Mol
Returns Mol output rdkit Mol

source

canon_smile

 canon_smile (smile:str)

attempts to canonicalize SMILES string. returns empty string if canonicalization fails

Type Details
smile str input SMILES string
Returns str canonicalized SMILES string

source

to_kekule

 to_kekule (smile:str)

converts SMILES string to kekule form

Type Details
smile str input SMILES string
Returns str output kekule SMILES string

source

to_smile

 to_smile (mol:rdkit.Chem.rdchem.Mol)

converts Mol to SMILES string

Type Details
mol Mol input rdkit mol
Returns str output SMILES string

source

smart_to_mol

 smart_to_mol (smart:str)

convertes smarts to Mol. returns None if mol creation fails

Type Details
smart str input SMARTS string
Returns typing.Optional[rdkit.Chem.rdchem.Mol] output rdkit mol

source

to_mol

 to_mol (smile:str)

convertes smile to Mol. returns None if mol creation fails

Type Details
smile str input SMILES string
Returns typing.Optional[rdkit.Chem.rdchem.Mol] output rdkit mol
assert type(to_mol('CCC')) == Chem.Mol
assert type(to_smile(Chem.MolFromSmiles('CCC'))) == str
assert type(smart_to_mol('[#6]')) == Chem.Mol

source

Molecule

 Molecule (smile:str, data:Optional[dict]=None)

Initialize self. See help(type(self)) for accurate signature.

Type Default Details
smile str SMILES string
data typing.Optional[dict] None dictionary of molecule data

source

smile_func_wrapper

 smile_func_wrapper (func:Callable[[str],Any])

takes a function with a SMILES string input and returns a wrapped version that accepts a Molecule as input

Type Details
func typing.Callable[[str], typing.Any] function that takes SMILES string as input
Returns typing.Callable[[main.Molecule], typing.Any] function that takes Molecule as input

source

mol_func_wrapper

 mol_func_wrapper (func:Callable[[rdkit.Chem.rdchem.Mol],Any])

takes a function with a Chem.Mol input and returns a wrapped version that accepts a Molecule as input

Type Details
func typing.Callable[[rdkit.Chem.rdchem.Mol], typing.Any] function that takes rdkit Mol as input
Returns typing.Callable[[main.Molecule], typing.Any] function that takes Molecule as input
rdkit_function = rdMolDescriptors.CalcExactMolWt

smile = 'CCCCCC'
mol = to_mol(smile)
molecule = Molecule(smile)

wrapped_function = mol_func_wrapper(rdkit_function)

assert rdkit_function(mol) == wrapped_function(molecule)

source

Catalog

 Catalog (catalog:rdkit.Chem.rdfiltercatalog.FilterCatalog)

Initialize self. See help(type(self)) for accurate signature.

Type Details
catalog FilterCatalog input filter catalog
smarts = [
    '[*]-[#6]1:[#6]:[#6](-[#0]):[#6]:[#6](-[*]):[#6]:1',
    '[*]-[#6]1:[#6]:[#6](-[*]):[#6]:[#6]:[#6]:1',
    '[*]-[#6]1:[#6]:[#6]:[#6]:[#6]:[#6]:1',
    '[*]-[#6]1:[#6]:[#6](-[#7]-[*]):[#6]:[#6]:[#6]:1',
    '[#6]1:[#6]:[#7]:[#6]:[#6]:[#6]:1'
]

catalog = Catalog.from_smarts(smarts)

smiles = [
    'c1ccccc1',
    'Cc1cccc(NCc2ccccc2)c1'
]

molecules = [Molecule(i) for i in smiles]

assert not catalog.has_match(molecules[0])
assert catalog.has_match(molecules[1])