It seems you want a list of the isotopes for a particular element? Looking
at the C++ code for openbabel, it seems like this might be easy to expose,
but for now, if you have a guess about the range of the function you can
get something in python fairly quickly:
In [1]: import openbabel
In [2]: for i in
xrange(1,25):
print i, openbabel.isotab.GetExactMass(6,i)
...:
1 0.0
2 0.0
3 0.0
4 0.0
5 0.0
6 0.0
7 0.0
8 8.037675
9 9.0310367
10 10.0168532
11 11.0114336
12 12.0
13 13.003354838
14 14.003241989
15 15.0105993
16 16.014701
17 17.022586
18 18.02676
19 19.03481
20 20.04032
21 21.04934
22 22.0572
23 0.0
24 0.0
In [3]: [i for i in xrange(1,25) if openbabel.isotab.GetExactMass(6,i) != 0]
Out[3]: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
What we see in the second command is that if openbabl does not think an
isotope of an element exists, it returns 0. In line 3, just filter on
whether the function returns 0 to get a list of all the isotopes of carbon
that openbabel believes exist. You can run this with a very large range and
it still returns almost instantly:
$ python2.7 -m timeit 'import openbabel;[i for i in xrange(1,1000) if
openbabel.isotab.GetExactMass(6,i) != 0]'
1000 loops, best of 3: 348 usec per loop
I'm unsure why you make comments saying that you doubt isotope.txt is not
where information about isotopes lives for openbabel. Openbabel is open
source and quickly scanning the code shows that it indeed does read that
file. And the 15 isotopes above for carbon are those in that file. Your
scepticism is largely unwarranted.
On Wed, Nov 13, 2013 at 10:00 PM, Dimitri Maziuk <dmaz...@bmrb.wisc.edu>wrote:
> PS. just to make sure I'm not reading some stale garbage from the heap:
>
> >>> for i in (9, 8, 7, 6, 5, 4) :
> ... mol = pybel.readstring("smi","C(=O)=O")
> ... mol.OBMol.BeginModify()
> ... for atom in mol.atoms :
> ... if atom.OBAtom.IsCarbon() : atom.OBAtom.SetIsotope( i )
> ... mol.OBMol.EndModify()
> ... print i, ":", mol.molwt
> ... del mol
> ...
> 9 : 41.0298367
> 8 : 40.036475
> 7 : 31.9988
> 6 : 31.9988
> 5 : 31.9988
> 4 : 31.9988
> >>>
>
> And with the same code:
>
> 21 : 53.04814
> 22 : 54.056
> 23 : 31.9988
> 24 : 31.9988
>
> --
> Dimitri Maziuk
> Programmer/sysadmin
> BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
>
>
>
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss