Combining two replies into one here.
On Fri, May 31, 2013 at 9:58 PM, Yingfeng Wang <[email protected]> wrote:
> Greg,
>
> I got a weird case. With the following code,
>
> >>> from rdkit import Chem
> >>> from rdkit.Chem import Descriptors
> >>> m
> =Chem.MolFromInchi('InChI=1S/C10H9N3O/c1-7-11-10(14)9(13-12-7)8-5-3-2-4-6-8/h2-6H,1H3,(H,11,12,14)')
> >>> Descriptors.MolWt(m)
> 9.072
> >>> em = Chem.EditableMol(m)
> >>> em.RemoveBond(8,7)
> >>> nm = em.GetMol()
> >>> frags = Chem.GetMolFrags(nm,asMols=True)
> >>> [Descriptors.MolWt(x) for x in frags]
> [5.04, 6.048]
>
> It seems the mass of the original molecule is 9.072, while the summation
> of masses of its fragments is 5.04+6.048 > 9.072. I don't think it is
> caused by the precision problem. Could you please let me know how to remove
> the "extra" mass?
>
It's not extra mass. The difference is caused by the Hs that are added to
the fragments to replace the bonds that have been broken:
In [14]: m
=Chem.MolFromInchi('InChI=1S/C10H9N3O/c1-7-11-10(14)9(13-12-7)8-5-3-2-4-6-8/h2-6H,1H3,(H,11,12,14)')
In [15]: AllChem.CalcMolFormula(m)
Out[15]: 'C10H9N3O'
In [16]: em = Chem.EditableMol(m)
In [17]: em.RemoveBond(8,7)
In [18]: nm = em.GetMol()
In [19]: frags = Chem.GetMolFrags(nm,asMols=True)
In [20]: [AllChem.CalcMolFormula(x) for x in frags]
Out[20]: ['C4H5N3O', 'C6H6']
you can see that there are two more Hs here.
On Fri, May 31, 2013 at 10:33 PM, Yingfeng Wang <[email protected]> wrote:
> I change MolWt() into ExactMolWt(), and get
>
> Descriptors.ExactMolWt(m)
> 187.074561908
>
> [Descriptors.ExactMolWt(x) for x in frags]
> [111.04326178, 78.046950192]
>
> According to the document, MolWt() outputs the average molecular weight
> of the molecule ignoring hydrogens, while ExactMolWt() is for the exact
> molecular weight of the molecule. What do I observe so big difference of
> mass? By the way, the mass of m calculated by the ExactMolWt () is still
> less than summation of its fragments.
>
The docstring for MolWt is incredibly wrong. Thanks for pointing it out.
I'll fix it.
MolWt() computes the average molecular weight of the molecule, taking into
account the standard isotope distribution for each atom where an isotope is
not specified.
ExactMolWt() computes the molecular weight using either the atomic weights
of the most common isotope (if not specified) or the specified isotope. An
example of that:
In [22]: Descriptors.ExactMolWt(Chem.MolFromSmiles('[CH4]'))
Out[22]: 16.031300127999998
In [23]: Descriptors.ExactMolWt(Chem.MolFromSmiles('[12CH4]'))
Out[23]: 16.031300127999998
In [24]: Descriptors.ExactMolWt(Chem.MolFromSmiles('[13CH4]'))
Out[24]: 17.034654967999998
-greg
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss