Hi Pat, Thanks for the help. I am interested in the H atom number.
Best regards, Dr. Xiaobo Li Postdoctoral Research Associate Andrew I. Cooper Group University of Liverpool / Materials Innovation Factory Department of Chemistry Crown Street Liverpool, L69 7ZD United Kingdom From: Patrick Walters [mailto:wpwalt...@gmail.com] Sent: 13 February 2019 13:00 To: Li, Xiaobo [xiaoboli] <xiaobo...@liverpool.ac.uk> Cc: Rdkit-discuss@lists.sourceforge.net Subject: Re: [Rdkit-discuss] General Smarts Language to select molecules without H elements Are you interested in aromatic c-H? It looks like 3 of 4 molecules have hydrogens (if you count methyls) from rdkit import Chem from rdkit.Chem.Draw import MolsToGridImage buff = """N#C/C(C#N)=C(C(F)=C/1F)\C(F)=C(F)C1=C(C#N)\C#N N#C/C(C#C)=C(C=C/1F)\C(F)=C(F)C1=C(C#N)\C#N FC1=C(F)C(C#N)=C(F)C(OC(Br)(Br)C)=C1C#N CC1=C(F)C(C#N)=C(F)C(OC(Br)(Br)C)=C1C#N""" smiles_list = buff.split("\n") mol_list = [Chem.MolFromSmiles(x) for x in smiles_list] MolsToGridImage(mol_list,molsPerRow=4) [image.png] aromatic_cH = Chem.MolFromSmarts("[cH]") [x.HasSubstructMatch(aromatic_cH) for x in mol_list] [False, True, False, False] If you're just looking for hydrogens, you could do something like this. from rdkit.Chem.rdMolDescriptors import CalcMolFormula def has_hydrogen(mol): mf = CalcMolFormula(mol) return mf.find("H") >= 0 [has_hydrogen(x) for x in mol_list] [False, True, True, True] Pat On Tue, Feb 12, 2019 at 6:40 PM Li, Xiaobo [xiaoboli] <xiaobo...@liverpool.ac.uk<mailto:xiaobo...@liverpool.ac.uk>> wrote: Dear all, I have a library of molecules, some of them don't have any H atom. I am wondering if there is a Smarts string to select these molecules using HasSubstructMatch function. For example, to select following molecules(no H atoms) N#C/C(C#N)=C(C(F)=C/1F)\C(F)=C(F)C1=C(C#N)\C#N FC1=C(F)C(C#N)=C(F)C(F)=C1C#N FC1=C(F)C(C#N)=C(F)C(OC(Br)(Br)Br)=C1C#N from N#C/C(C#N)=C(C(F)=C/1F)\C(F)=C(F)C1=C(C#N)\C#N N#C/C(C#C)=C(C=C/1F)\C(F)=C(F)C1=C(C#N)\C#N FC1=C(F)C(C#N)=C(F)C(OC(Br)(Br)C)=C1C#N CC1=C(F)C(C#N)=C(F)C(OC(Br)(Br)C)=C1C#N Or is there a better way to do it? Best regards, Xiaobo Li _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net<mailto: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