Unimod Mapper

class ursgal.UnimodMapper

UnimodMapper class that creates lookup to the unimod.xml and userdefined_unimod.xml found located in ursgal/kb/ext and offers several helper methods described below :

appMass2element_list(mass, decimal_places=2)

Creates a list of element composition dicts for a given approximate mass

Parameters:mass (float) –
Keyword Arguments:
 decimal_places (int) – Precision with which the masses in the Unimod is compared to the input, i.e. round( mass, decimal_places )
Returns:Dicts of elements
Return type:list
Examples::
>>> import ursgal
>>> U = ursgal.UnimodMapper()
>>> U.appMass2element_list(18, decimal_places=0)
[{'F': 1, 'H': -1}, {'13C': 1, 'H': -1, '2H': 3},
    {'H': -2, 'C': -1, 'S': 1}, {'H': 2, 'C': 4, 'O': -2},
    {'H': -2, 'C': -1, 'O': 2}]
appMass2id_list(mass, decimal_places=2)

Creates a list of unimod ids for a given approximate mass

Parameters:mass (float) –
Keyword Arguments:
 decimal_places (int) – Precision with which the masses in the Unimod is compared to the input, i.e. round( mass, decimal_places )
Returns:Unimod IDs
Return type:list
Examples::
>>> import ursgal
>>> U = ursgal.UnimodMapper()
>>> U.appMass2id_list(18, decimal_places=0)
['127', '329', '608', '1079', '1167']
appMass2name_list(mass, decimal_places=2)

Creates a list of unimod names for a given approximate mass

Parameters:mass (float) –
Keyword Arguments:
 decimal_places (int) – Precision with which the masses in the Unimod is compared to the input, i.e. round( mass, decimal_places )
Returns:Unimod names
Return type:list
Examples::
>>> import ursgal
>>> U = ursgal.UnimodMapper()
>>> U.appMass2name_list(18, decimal_places=0)
['Fluoro', 'Methyl:2H(3)13C(1)', 'Xle->Met', 'Glu->Phe', 'Pro->Asp']
composition2id_list(composition)
Converts unimod composition to unimod name list,
since a given composition can map to mutiple entries in the XML.
Parameters:composition (dict) –
Returns:Unimod IDs
Return type:list
composition2mass(composition)

Converts unimod composition to unimod monoisotopic mass,

Parameters:composition (float) –
Returns:monoisotopic mass
Return type:float
composition2name_list(composition)
Converts unimod composition to unimod name list,
since a given composition can map to mutiple entries in the XML.
Parameters:composition (dict) –
Returns:Unimod names
Return type:list
id2composition(unimod_id)

Converts unimod id to unimod composition

Parameters:unimod_id (int) –
Returns:Unimod elemental composition
Return type:dict
id2mass(unimod_id)

Converts unimodID to unimod mass

Parameters:unimod_id (int) –
Returns:Unimod mono isotopic mass
Return type:float
id2name(unimod_id)

Converts unimodID to unimod name

Parameters:unimod_id (int) –
Returns:Unimod name
Return type:str
mass2composition_list(mass)
Converts unimod mass to unimod element composition list,
since a given mass can map to mutiple entries in the XML.
Parameters:mass (float) –
Returns:Unimod elemental compositions
Return type:list
mass2id_list(mass)
Converts unimod mass to unimod name list,
since a given mass can map to mutiple entries in the XML.
Parameters:mass (float) –
Returns:Unimod IDs
Return type:list
mass2name_list(mass)
Converts unimod mass to unimod name list,
since a given mass can map to mutiple entries in the XML.
Parameters:mass (float) –
Returns:Unimod names
Return type:list
name2composition(unimod_name)

Converts unimod name to unimod composition

Parameters:unimod_name (str) –
Returns:Unimod elemental composition
Return type:dict
name2id(unimod_name)

Converts unimod name to unimodID

Parameters:unimod_name (str) –
Returns:Unimod id
Return type:int
name2mass(unimod_name)

Converts unimod name to unimod mono isotopic mass

Parameters:unimod_name (str) –
Returns:Unimod mono isotopic mass
Return type:float
writeXML(modification_dict, xmlFile=None)

Writes a unimod-style userdefined_unimod.xml file in ursal/resources/platform_independent/arc_independent/ext

Parameters:
  • modification_dict (dict) – dictionary containing at least
  • 'mass' (mass of the modification) –
  • 'name' (name of the modificaton) –
  • 'composition' (chmical composition of the modification as a Hill notation) –