Conformer generation¶
RDKitConformerGenerator is a thin wrapper
around RDKit’s conformer embedding and optimization: for each input
molecule it embeds several 3D conformers (ETKDG), optimizes them (UFF), and
returns each molecule as a bag of single-conformer molecules — the
multi-instance representation used everywhere downstream.
Example¶
from rdkit import Chem
from qsarmil.conformer import RDKitConformerGenerator
smiles = [
"CC(C)Cc1ccc(cc1)C(C)C(=O)O",
"COc1ccc2cc(ccc2c1)C(C)C(=O)O",
]
mols = [Chem.MolFromSmiles(smi) for smi in smiles]
conf_gen = RDKitConformerGenerator(num_conf=10, num_cpu=2, verbose=True, random_seed=42)
conformers = conf_gen.run(mols)
conformers is a list with one entry per input molecule: either a list of
single-conformer Mol objects (the bag), or a
FailedMolecule sentinel if that molecule
could not be embedded.
Parameters¶
num_conf(default10) — number of conformers to embed per molecule (RDKit’sETKDGv3).e_thresh(defaultNone) — if set, conformers whose UFF energy is more thane_threshabove the lowest-energy conformer for that molecule are dropped after optimization. Leave asNoneto keep every embedded conformer.num_cpu(default: all available CPUs) — number of threads used to generate conformers in parallel.verbose(defaultTrue) — print a running “generated X/Y” progress count while conformers are being generated.random_seed(default42) — seed for the ETKDG embedding, so results are reproducible.
Failure handling¶
Molecules that fail to parse or fail to embed any conformer are wrapped in
a FailedMolecule sentinel rather than
raising an exception, so a handful of problematic molecules doesn’t stop
the rest of the batch from running.