On Tue, Mar 26, 2019 at 8:22 PM Patrick Walters <wpwalt...@gmail.com> wrote:
> HI Xiaobo, > > There's an explicit hydrogen in the SMARTS that shouldn't be there. I > also wouldn't include the single bonds around the ring closures. > To be fair, that explicit hydrogen was in the original SMILES string, so it is reasonable to find it in the SMARTS string if the conversion program didn't make the same choice as RDKit to remove all hydrogens on parsing. If you disable hydrogen removal in RDKit you do find a match, smi = "O=C(C1=C2C(C=CC=C23)=CC=C1)N([H])C3=O" params = Chem.SmilesParserParams() params.removeHs=False mol = Chem.MolFromSmiles(smi, params) s=Chem.MolFromSmarts("[#8]=[#6]-3-c1c2c(ccc1)cccc2-[#6](-[#7]-3-[#1])=[#8]") mol.HasSubstructMatch(s) // True Whether you want to remove hydrogens when parsing SMILES strings or whether you want to represent those hydrogens as explicit vertices in the pattern, that is up to you. > '[#8]=[#6]-3-c1c2c(ccc1)cccc2-[#6](-[#7]-3-*[#1]*)=[#8]') > > from rdkit import Chem > from rdkit.Chem import Draw > > smi = "O=C(C1=C2C(C=CC=C23)=CC=C1)N([H])C3=O" > mol = Chem.MolFromSmiles(smi) > mol_list = [mol] > core = Chem.MolFromSmarts("[#8]=[#6]3-c1c2c(ccc1)cccc2-[#6](-[#7H]3)=[#8]") > Draw.MolsToGridImage(mol_list,highlightAtomLists=[x.GetSubstructMatch(core) > for x in mol_list]) > > [image: image.png] > > > _______________________________________________ > 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