Created
August 2, 2018 08:23
-
-
Save andersx/4ef2c423a514197edb18ba3c38ba11e2 to your computer and use it in GitHub Desktop.
Example that will throw a "ValueError: Bad conformer id" with RDKit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from rdkit import Chem | |
| from rdkit.Chem import AllChem | |
| if __name__ == "__main__": | |
| # my_smiles = ['C#N', 'C1C(C2C1OC2)O', 'C1C2C3C1C2C3O', 'C1C2COC2C1O', 'C1CC2(C1CC2)O', | |
| # 'C1CC2(C1NC2)O', 'C1CC2(C1OC2)N', 'C1CC2(C1OC2)O', 'C1CC2C1CC2O'] | |
| my_smiles = ['C#N', 'C1C(C2C1OC2)O'] | |
| for smiles in my_smiles: | |
| mol = Chem.MolFromSmiles(smiles) | |
| mol = Chem.AddHs(mol) | |
| AllChem.EmbedMolecule(mol, useRandomCoords=True) | |
| AllChem.EmbedMultipleConfs(mol, | |
| numConfs=50, | |
| # useExpTorsionAnglePrefs=True, | |
| # useBasicKnowledge=True, | |
| # enforceChirality=True | |
| ) | |
| optimization = AllChem.MMFFOptimizeMoleculeConfs(mol, maxIters=100) | |
| for i,conf in enumerate(mol.GetConformers()): | |
| filename = "output_%02i_%s.sdf" % (i, smiles) | |
| tm = Chem.Mol(mol, False, conf.GetId()) | |
| writer = Chem.SDWriter(filename) | |
| writer.write(tm) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you so much!!!!