API helper modules

Data of chemical Elements

Data of chemical elements are available from the elements module, e.g:

>>> print emzed.elements.C
{'massnumber': 12, 'm0': 12.0, 'number': 6, 'name': 'Carbon'}
>>> print emzed.elements.C["m0"]
12.0
>>> print emzed.elements.C12
{'abundance': 0.9893000000000001, 'name': 'Carbon', 'number': 6, 'mass': 12.0}
>>> print emzed.elements.C12["abundance"]
0.9893

Masses and Mass Calculation

Masses can be queried like this:

>>> print emzed.mass.C13
13.003355
>>> print emzed.mass.of("C4H8O2")
88.0524302552

Nested formulas are supported:

>>> print emzed.mass.of("C(CH2)4COOH")
113.060255287

And isotopes can be specified in brackets:

>>> print emzed.mass.of("[13]C4H8O2")
92.0658502552
>>> print emzed.mass.of("[13]CC2H8O2")
77.0557852552

Natural Abundances of isotopes

>>> print emzed.abundance.C
{12: 0.9893000000000001, 13: 0.010700000000000001}
>>> print emzed.abundance.C[12]
0.9893
>>> print emzed.abundance.C12
0.9893

Data of common Adducts

The adducts module provides information about most common ESI adducts, adduct lists can be converted to a Table eg:

>>> print emzed.adducts.labels
['M+H', 'M+NH4', 'M+Na', 'M+H-2H2O', 'M+H-H2O', 'M+K', 'M+ACN+H', 'M+ACN+Na', 'M+2Na-H', 'M+2H', 'M+3H', 'M+H+Na', 'M+2H+Na', 'M+2Na', 'M+2Na+H', 'M+Li', 'M+CH3OH+H', 'M-H', 'M-H2O-H', 'M+Na-2H', 'M+Cl', 'M+K-2H', 'M+KCl-H', 'M+FA-H', 'M-2H', 'M-3H', 'M+CH3COO', 'M+F', 'M']
>>> subgroup = emzed.adducts.get("M+H", "M+2Na-H")
>>> subgroup.toTable().print_()
adduct_name mass_shift z_signed z       
str         float      int      int     
------      ------     ------   ------  
M+H         1.007276   +1       1       
M+2Na-H     44.971165  +1       1       
>>> 
>>> print emzed.adducts.namedLabels
['M_plus_H', 'M_plus_NH4', 'M_plus_Na', 'M_plus_H_minus_2H2O', 'M_plus_H_minus_H2O', 'M_plus_K', 'M_plus_ACN_plus_H', 'M_plus_ACN_plus_Na', 'M_plus_2Na_minus_H', 'M_plus_2H', 'M_plus_3H', 'M_plus_H_plus_Na', 'M_plus_2H_plus_Na', 'M_plus_2Na', 'M_plus_2Na_plus_H', 'M_plus_Li', 'M_plus_CH3OH_plus_H', 'M_minus_H', 'M_minus_H2O_minus_H', 'M_plus_Na_minus_2H', 'M_plus_Cl', 'M_plus_K_minus_2H', 'M_plus_KCl_minus_H', 'M_plus_FA_minus_H', 'M_minus_2H', 'M_minus_3H', 'M_plus_CH3COO', 'M_plus_F', 'M']
>>> print emzed.adducts.M_plus_H
<emzed.adducts._Adducts object at 0x101d358d0>
>>> print emzed.adducts.M_plus_2Na_minus_H
<emzed.adducts._Adducts object at 0x101d35810>

The following preselected groups of adducts exist:

>>> print len(emzed.adducts.all)
29
>>> print len(emzed.adducts.positive)
17
>>> print len(emzed.adducts.negative)
11
>>> print len(emzed.adducts.single_charged)
20
>>> print len(emzed.adducts.double_charged)
4
>>> print len(emzed.adducts.triple_charged)
4
>>> print len(emzed.adducts.positive_single_charged)
11
>>> print len(emzed.adducts.positive_double_charged)
3
>>> print len(emzed.adducts.positive_triple_charged)
3
>>> print len(emzed.adducts.negative_single_charged)
9
>>> print len(emzed.adducts.negative_double_charged)
1
>>> print len(emzed.adducts.negative_triple_charged)
1

Further a default dialog can be opened for asking a multiple choice selection of all adducts or of a subgroup:

_images/adduct_dialog.png
>>> tab = emzed.adducts.all.buildTableFromUserDialog() 
>>> tab.print_() 
adduct_name mass_shift z       
str         float      int     
------      ------     ------  
[M+H]+      1.007276   +1      
[M+2Na-H]+  44.971165  +1      
[M-H]-      -1.007276  -1      
[M-H-H2O]-  -19.017842 -1