Re: [Rdkit-discuss] Count carbon atoms

2015-10-07 Thread Ling Chan
Or you can use AllChem.CalcMolFormula() to get the chemical formula. Ling On Wed, Oct 7, 2015 at 3:55 AM, Andrew Dalke wrote: > On Oct 7, 2015, at 11:30 AM, Christos Kannas wrote: > > Yes there is an easier way, by using substructure search, i.e. do a > substructure

Re: [Rdkit-discuss] Count carbon atoms

2015-10-07 Thread Andrew Dalke
On Oct 7, 2015, at 11:38 PM, Ling Chan wrote: > Or you can use AllChem.CalcMolFormula() to get the chemical formula. Well spotted! It's a bit tricky because it needs to handle carbons with/without count ("CH4", "C2H6"), and structures with no carbons ("P", "Ca", "Cd"); the last two start with a

[Rdkit-discuss] Count carbon atoms

2015-10-07 Thread Joos Kiener
Hi all, is there an easy way I'm missing to get the number of C-Atoms in a molecule? Currently I iterate all atoms and check if it's symbol is C. Doesn't seem very efficient. Best Regards, Joos Kiener -- Full-scale,

Re: [Rdkit-discuss] Count carbon atoms

2015-10-07 Thread Christos Kannas
Hi Joss, Yes there is an easier way, by using substructure search, i.e. do a substructure search for [C] and then get the number of matches. Hope this example to be readable and answer your question. In [1]: from rdkit import rdBase print rdBase.rdkitVersion ​ from rdkit import Chem from

Re: [Rdkit-discuss] Count carbon atoms

2015-10-07 Thread Andrew Dalke
On Oct 7, 2015, at 11:30 AM, Christos Kannas wrote: > Yes there is an easier way, by using substructure search, i.e. do a > substructure search for [C] and then get the number of matches. > m = Chem.MolFromSmiles("c1c1") > patt= Chem.MolFromSmarts("[C]") > pm =