Re: [Rdkit-discuss] SDMolSupplier, next()
Dear Jean-Marc, in Python 3 you need to use next(suppl) or suppl.__next__(). Cheers, p. On 10/15/19 21:34, Jean-Marc Nuzillard wrote: Dear all, The code: from rdkit import Chem sdfnamein = "simple.sdf" suppl = Chem.SDMolSupplier(sdfnamein) m = suppl.next() print(m.GetNumAtoms()) prints: Traceback (most recent call last): File "demo.py", line 4, in m = suppl.next() AttributeError: 'SDMolSupplier' object has no attribute 'next' even though the code in http://www.rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html#rdkit.Chem.rdmolfiles.SDMolSupplier, at paragraph "Lazy evaluation 2" indicates: >>> suppl = SDMolSupplier('in.sdf') >>> mol1 = suppl.next() I run rdkit 2018.09.1.0 from Anaconda in Windows 10. for mol in suppl: mol.GetNumAtoms() works fine. Best, Jean-Marc -- Dr. Jean-Marc Nuzillard Institute of Molecular Chemistry, CNRS UMR 7312 Faculté des Sciences Exactes et Naturelles, Bâtiment 18 BP 1039 51687 REIMS Cedex 2 France Tel : 33 3 26 91 82 10 Fax : 33 3 26 91 31 66 http://www.univ-reims.fr/icmr http://eos.univ-reims.fr/LSD/CSNteam.html http://www.univ-reims.fr/LSD/ http://www.univ-reims.fr/LSD/JmnSoft/ ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] SDMolSupplier, next()
Dear all, The code: from rdkit import Chem sdfnamein = "simple.sdf" suppl = Chem.SDMolSupplier(sdfnamein) m = suppl.next() print(m.GetNumAtoms()) prints: Traceback (most recent call last): File "demo.py", line 4, in m = suppl.next() AttributeError: 'SDMolSupplier' object has no attribute 'next' even though the code in http://www.rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html#rdkit.Chem.rdmolfiles.SDMolSupplier, at paragraph "Lazy evaluation 2" indicates: suppl = SDMolSupplier('in.sdf') mol1 = suppl.next() I run rdkit 2018.09.1.0 from Anaconda in Windows 10. for mol in suppl: mol.GetNumAtoms() works fine. Best, Jean-Marc -- Dr. Jean-Marc Nuzillard Institute of Molecular Chemistry, CNRS UMR 7312 Faculté des Sciences Exactes et Naturelles, Bâtiment 18 BP 1039 51687 REIMS Cedex 2 France Tel : 33 3 26 91 82 10 Fax : 33 3 26 91 31 66 http://www.univ-reims.fr/icmr http://eos.univ-reims.fr/LSD/CSNteam.html http://www.univ-reims.fr/LSD/ http://www.univ-reims.fr/LSD/JmnSoft/ ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] RDKit Num Rotors descriptors?
> PS: I found that if you want to use the non-strict version, you can do this: > > from rdkit.Chem import rdMolDescriptors > rdMolDescriptors.CalcNumRotatableBonds(mol, 0) > > (where 0 means NonStrict, 1 means Strict, and -1 means Default.) > > I tested this with a molecule containing t-butyl and got different results > for strict and non-strict, as expected, and the default was the same as > strict. Excellent, thanks! -Geoff ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] RDKit Num Rotors descriptors?
This is from lipinski.cpp: if (strict == NonStrict) { std::string pattern = "[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]"; pattern_flyweight m(pattern); return m.get().countMatches(mol); } else if (strict==Strict) { std::string strict_pattern = "[!$(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])(" "[CH3])[CH3])&!$([CD3](=[N,O,S])-!@[#7,O,S!D1])&!$([#7,O,S!D1]-!@[CD3]=" "[N,O,S])&!$([CD3](=[N+])-!@[#7!D1])&!$([#7!D1]-!@[CD3]=[N+])]-!@[!$(*#" "*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])([CH3])" "[CH3])]"; pattern_flyweight m(strict_pattern); return m.get().countMatches(mol); } else { I suspect that it's taking the "Strict" brach, where the SMARTS pattern is more complex and actually has a rule that excludes tert-butyl (the "&!$(C([CH3])([CH3])[CH3])]" at the end). Ivan On Tue, Oct 15, 2019 at 1:06 PM Geoffrey Hutchison < geoff.hutchi...@gmail.com> wrote: > I'm using a script in RDKit to grab a bunch of descriptors for QSAR / ML. > I have a particular question about the # of rotatable bonds: > > Consider: > > from rdkit import Chem > from rdkit.Chem import Descriptors > example = Chem.MolFromSmiles("CN(C(=O)OC(C)(C)C)C(=S)NC(=O)OC(C)(C)C") > Descriptors.NumRotatableBonds(example) > 0 > > example2 = Chem.MolFromSmiles("CC(C)(C)CCC(C)(C)C") > Descriptors.NumRotatableBonds(example2) > 1 > > > Can someone explain why a terminal butyl isn't a rotatable bond? Based on > mailing list questions, I thought NumRotatableBonds was supposed to return > matches for the SMARTS "[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]" (e.g. what's > defined in the Lipinski code). > > Thanks, > -Geoff > > > > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] RDKit Num Rotors descriptors?
PS: I found that if you want to use the non-strict version, you can do this: from rdkit.Chem import rdMolDescriptors rdMolDescriptors.CalcNumRotatableBonds(mol, 0) (where 0 means NonStrict, 1 means Strict, and -1 means Default.) I tested this with a molecule containing t-butyl and got different results for strict and non-strict, as expected, and the default was the same as strict. On Tue, Oct 15, 2019 at 1:57 PM Ivan Tubert-Brohman < ivan.tubert-broh...@schrodinger.com> wrote: > This is from lipinski.cpp: > > if (strict == NonStrict) { > std::string pattern = "[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]"; > pattern_flyweight m(pattern); > return m.get().countMatches(mol); > } > else if (strict==Strict) { > std::string strict_pattern = > > "[!$(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])(" > > "[CH3])[CH3])&!$([CD3](=[N,O,S])-!@[#7,O,S!D1])&!$([#7,O,S!D1]-!@[CD3]=" > > "[N,O,S])&!$([CD3](=[N+])-!@[#7!D1])&!$([#7!D1]-!@[CD3]=[N+])]-!@[!$(*#" > > "*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])([CH3])" > "[CH3])]"; > pattern_flyweight m(strict_pattern); > return m.get().countMatches(mol); > } else { > > I suspect that it's taking the "Strict" brach, where the SMARTS pattern is > more complex and actually has a rule that excludes tert-butyl (the > "&!$(C([CH3])([CH3])[CH3])]" at the end). > > Ivan > > > On Tue, Oct 15, 2019 at 1:06 PM Geoffrey Hutchison < > geoff.hutchi...@gmail.com> wrote: > >> I'm using a script in RDKit to grab a bunch of descriptors for QSAR / ML. >> I have a particular question about the # of rotatable bonds: >> >> Consider: >> >> from rdkit import Chem >> from rdkit.Chem import Descriptors >> example = Chem.MolFromSmiles("CN(C(=O)OC(C)(C)C)C(=S)NC(=O)OC(C)(C)C") >> Descriptors.NumRotatableBonds(example) >> 0 >> >> example2 = Chem.MolFromSmiles("CC(C)(C)CCC(C)(C)C") >> Descriptors.NumRotatableBonds(example2) >> 1 >> >> >> Can someone explain why a terminal butyl isn't a rotatable bond? Based on >> mailing list questions, I thought NumRotatableBonds was supposed to return >> matches for the SMARTS "[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]" (e.g. what's >> defined in the Lipinski code). >> >> Thanks, >> -Geoff >> >> >> >> ___ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> > ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] RDKit Num Rotors descriptors?
I'm using a script in RDKit to grab a bunch of descriptors for QSAR / ML. I have a particular question about the # of rotatable bonds: Consider: from rdkit import Chem from rdkit.Chem import Descriptors example = Chem.MolFromSmiles("CN(C(=O)OC(C)(C)C)C(=S)NC(=O)OC(C)(C)C") Descriptors.NumRotatableBonds(example) 0 example2 = Chem.MolFromSmiles("CC(C)(C)CCC(C)(C)C") Descriptors.NumRotatableBonds(example2) 1 Can someone explain why a terminal butyl isn't a rotatable bond? Based on mailing list questions, I thought NumRotatableBonds was supposed to return matches for the SMARTS "[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]" (e.g. what's defined in the Lipinski code). Thanks, -Geoff ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss