Functional API¶
The functional API of medchem
provides an easy and uniform way to access most
the medchem
alerts, filters and rules proposed in the other medchem
module.
In [3]:
Copied!
import datamol as dm
import pandas as pd
import medchem as mc
import datamol as dm
import pandas as pd
import medchem as mc
Generic filters¶
All the filters can be applied on a list of SMILES or molecule objects. It's also possible to run the filtering in parallel in processes or threads.
The below examples contains molecules that are shown for illustration purposes.
macrocycle_filter
¶
Find molecules that do not infringe the strict maximum cycle size.
In [4]:
Copied!
smiles_list = [
"Nc1noc2cc(-c3noc(C(F)(F)F)n3)ccc12",
"Nc1noc2cc(-c3noc(n3)C(Cl)(Cl)Cl)c(Cl)c(B3C=C3)c12",
"C[C@H](Nc1ncc(-c2noc(C(F)(F)F)n2)cc1Cl)c1ccncc1",
"NC1=NOC2=CC(C3=NOC(=N3)C(F)(F)F)=C3CCCCCCCC3=C12",
"Nc1noc2c(cc(cc12)C1NCO1)C1CCCCCCCCC1",
]
mols = [dm.to_mol(s) for s in smiles_list]
# Apply the filter
out = mc.functional.macrocycle_filter(mols, max_cycle_size=7, return_idx=False)
legends = [f"Pass the filter={o}" for o in out]
dm.to_image(mols, legends=legends, n_cols=5, mol_size=(250, 150))
smiles_list = [
"Nc1noc2cc(-c3noc(C(F)(F)F)n3)ccc12",
"Nc1noc2cc(-c3noc(n3)C(Cl)(Cl)Cl)c(Cl)c(B3C=C3)c12",
"C[C@H](Nc1ncc(-c2noc(C(F)(F)F)n2)cc1Cl)c1ccncc1",
"NC1=NOC2=CC(C3=NOC(=N3)C(F)(F)F)=C3CCCCCCCC3=C12",
"Nc1noc2c(cc(cc12)C1NCO1)C1CCCCCCCCC1",
]
mols = [dm.to_mol(s) for s in smiles_list]
# Apply the filter
out = mc.functional.macrocycle_filter(mols, max_cycle_size=7, return_idx=False)
legends = [f"Pass the filter={o}" for o in out]
dm.to_image(mols, legends=legends, n_cols=5, mol_size=(250, 150))
Out[4]: