Re: [Rdkit-discuss] RDKit appears to be parsing SMILES stereochemistry differently
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Brian C. <co...@gm...> - 2017-11-09 15:09:55
|
Here's an example of why this is useful at maintaining molecular fragmentation inside your molecular representation: >>> from rdkit import Chem >>> smiles = 'F9.[C@]91(C)CCO1' >>> fluorine, core = smiles.split('.') >>> fluorine 'F9' >>> fragment = core.replace('9', '([*:9])') >>> fragment '[C@]([*:9])1(C)CCO1' >>> mol = Chem.RWMol(Chem.MolFromSmiles(fragment)) ### RDKit is flipping the stereo on me here even the order of the bonds has not changed >>> idx = mol.AddAtom(Chem.Atom(0)) >>> mol.AddBond(idx, 4, Chem.rdchem.BondType.SINGLE) 7 >>> mol.GetAtomWithIdx(idx).SetIntProp("molAtomMapNumber", 8) >>> new_core = Chem.MolToSmiles(mol, True) >>> new_core = new_core.replace('([*:9])', '9').replace('([*:8])', '8') >>> new_core 'C[C@]19CC8O1' >>> analog_smiles = 'Cl8.' + fluorine + '.' + new_core >>> analog_smiles 'Cl8.F9.C[C@]19CC8O1' >>> analog = Chem.MolFromSmiles(analog_smiles) >>> analog.HasSubstructMatch(Chem.MolFromSmiles(smiles), useChirality=True) # Uh oh! My original molecule didn't match False >>> analog.HasSubstructMatch(Chem.MolFromSmiles(smiles.replace('@', '@@')), useChirality=True) # flipping the stereo of the original causes it to match again True On Thu, Nov 9, 2017 at 4:41 AM, Andrew Dalke <da...@da...> wrote: > On Nov 9, 2017, at 08:13, Greg Landrum <gre...@gm...> wrote: > > As was discussed in the comments of https://github.com/rdkit/ > rdkit/issues/786, I think it's pretty gross that the second syntax is > even legal. But that's a side point. > > To belabor that point. Neither Daylight SMILES nor OpenSMILES accept it, > which are the only two explicit sources of "legal" that people use. > > "allowed" might be a better term. > > Andrew > da...@da... > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Rdkit-discuss mailing list > Rdk...@li... > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > |