Re: [Rdkit-discuss] About Explict [H] in Smarts.
Hello Changge, By default, RDKit throws away hydrogens. If you add explicit hydrogens to mol using AddHs(), it should work. Just add the line mol = Chem.AddHs(mol) Ling On Thu, Jan 19, 2017 at 9:49 AM, Changge Ji wrote: > Dear All, > > I'm a new to rdkit. > > I fount that the molecule 'c1c1' don't fit to the smarts > 'c1cc([#1,F,Cl,I])ccc1' > > --- > mol = Chem.MolFromSmiles('c1c1') > fap = FragmentMatcher.FragmentMatcher() > smarts = 'c1cc([#1,F,Cl,I])ccc1' > fap.Init(smarts) > tp = fap.HasMatch(mol) > > result : tp = 0 > - > > It seems that it is due to the explict H atom in smarts. > > How can I make my smarts work? > > Thank you for your help. > > > > > Best, > > > -- > Changge > > > -- > 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 > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > -- 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 Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] About Explict [H] in Smarts.
Because the H atoms are by default not explicitly present in the molecular graph, the substructure matcher cannot match to them. If you have queries that include explicit Hs like this and you really want to match to them, you will need to call AddHs() on the molecules before doing the substructure match. This will slow everything down a lot. Depending upon what you want to do, an alternative may be to edit your query to something like: In [37]: smarts = 'c1c[cH,$(c[F,Cl,I])]ccc1' In [39]: Chem.MolFromSmiles('c1c1').HasSubstructMatch(Chem.MolFromSmarts(smarts)) Out[39]: True In [40]: Chem.MolFromSmiles('Cc1c(C)c(C)c(C)c(C)c1C').HasSubstructMatch(Chem.MolFromSmarts(smarts)) Out[40]: False -greg On Thu, Jan 19, 2017 at 6:49 PM, Changge Ji wrote: > Dear All, > > I'm a new to rdkit. > > I fount that the molecule 'c1c1' don't fit to the smarts > 'c1cc([#1,F,Cl,I])ccc1' > > --- > mol = Chem.MolFromSmiles('c1c1') > fap = FragmentMatcher.FragmentMatcher() > smarts = 'c1cc([#1,F,Cl,I])ccc1' > fap.Init(smarts) > tp = fap.HasMatch(mol) > > result : tp = 0 > - > > It seems that it is due to the explict H atom in smarts. > > How can I make my smarts work? > > Thank you for your help. > > > > > Best, > > > -- > Changge > > > -- > 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 > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > -- 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 Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] About Explict [H] in Smarts.
Dear All, I'm a new to rdkit. I fount that the molecule 'c1c1' don't fit to the smarts 'c1cc([#1,F,Cl,I])ccc1' --- mol = Chem.MolFromSmiles('c1c1') fap = FragmentMatcher.FragmentMatcher() smarts = 'c1cc([#1,F,Cl,I])ccc1' fap.Init(smarts) tp = fap.HasMatch(mol) result : tp = 0 - It seems that it is due to the explict H atom in smarts. How can I make my smarts work? Thank you for your help. Best, Changge -- 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 Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss