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 rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
2014.09.2
In [2]:
m = Chem.MolFromSmiles("CCCCCCCCc1ccccc1")
m
Out[2]:
[image: Inline images 1]
In [3]:
patt= Chem.MolFromSmarts("[C]")
print Chem.MolToSmarts(patt)
C
In [4]:
pm = m.GetSubstructMatches(patt)
print len(pm)
8
Regards,
Christos
Christos Kannas
Researcher
Ph.D Student
Mob (UK): +44 (0) 7447700937
Mob (Cyprus): +357 99530608
[image: View Christos Kannas's profile on LinkedIn]
<http://cy.linkedin.com/in/christoskannas>
On 7 October 2015 at 10:12, Joos Kiener <joos.kie...@gmail.com> wrote:
> 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, agent-less Infrastructure Monitoring from a single dashboard
> Integrate with 40+ ManageEngine ITSM Solutions for complete visibility
> Physical-Virtual-Cloud Infrastructure monitoring from one console
> Real user monitoring with APM Insights and performance trend reports
> Learn More
> http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
------------------------------------------------------------------------------
Full-scale, agent-less Infrastructure Monitoring from a single dashboard
Integrate with 40+ ManageEngine ITSM Solutions for complete visibility
Physical-Virtual-Cloud Infrastructure monitoring from one console
Real user monitoring with APM Insights and performance trend reports
Learn More http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss