Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_masses Class Reference

Reads and parses the masses file with residue and atom masses. More...

#include <ms_masses.hpp>

Inheritance diagram for ms_masses:
Collaboration diagram for ms_masses:

Public Member Functions

 ms_masses ()
 Default constructor.
 
 ms_masses (const char *filename, const matrix_science::ms_connection_settings *cs=0)
 Reads the file immediately after the construction.
 
 ms_masses (const ms_masses &src)
 Copying constructor.
 
 ms_masses (const ms_umod_configfile &src, bool addMissingResidueMasses=true)
 Copying constructor.
 
 ms_masses (const ms_umod_configfile &src, const ms_quant_component &quantComp)
 Constructor for prepared isotope-substituted version of masses.
 
 ~ms_masses ()
 Destructor.
 
void appendErrors (const ms_errors &src)
 Copies all errors from another instance and appends them at the end of own list.
 
ms_modvector applyFixedMods (const ms_modvector *mods, ms_errs *err)
 Change residue masses according to the list of fixed modifications.
 
void applyIsotopes (const ms_umod_configfile *umodFile, const ms_quant_component *quantComp)
 Update masses of amino-acids with isotope substitution.
 
void clearAllErrors ()
 Remove all errors from the current list of errors.
 
void copyFrom (const ms_errors *right)
 Use this member to make a copy of another instance.
 
void copyFrom (const ms_masses *right)
 Copies masses from another instance.
 
void copyFrom (const ms_umod_configfile *right, bool addMissingResidueMasses=true)
 Copies masses from a Unimod file.
 
void defaultValues (bool useDefaultResidueMasses=true)
 Use this member to re-initialise internal members.
 
double getCarbonMass (const matrix_science::MASS_TYPE massType) const
 Returns a carbon(C) atom mass for a given mass type (MONO or AVE).
 
matrix_science::ms_connection_settings getConnectionSettings () const
 Returns the sessionID and proxy server for use with an HTTP transfer.
 
double getCtermDelta (const matrix_science::MASS_TYPE massType) const
 Returns C-term modification delta if there is a correspondent fixed modification applied.
 
double getCterminalMass (const matrix_science::MASS_TYPE massType) const
 Returns C-terminal group mass (i.e. fixed modification delta or OH-mass).
 
double getCtermNeutralLoss (const matrix_science::MASS_TYPE massType) const
 Returns C-term neutral loss value if there is a correspondent fixed modification applied.
 
double getElectronMass () const
 Returns an electron mass.
 
const ms_errsgetErrorHandler () const
 Retrive the error object using this function to get access to all errors and error parameters.
 
std::string getFileName () const
 Returns a file name set before or by default.
 
double getFragResidueMass (const matrix_science::MASS_TYPE massType, const char residue) const
 Returns a residue mass with neutral loss after applying fixed modifications.
 
double getHydrogenMass (const matrix_science::MASS_TYPE massType) const
 Returns a hydrogen (H) atom mass for a given mass type (MONO or AVE).
 
int getLastError () const
 Return the error description of the last error that occurred.
 
std::string getLastErrorString () const
 Return the error description of the last error that occurred.
 
double getNitrogenMass (const matrix_science::MASS_TYPE massType) const
 Returns a nitrogen (N) atom mass for a given mass type (MONO or AVE).
 
double getNtermDelta (const matrix_science::MASS_TYPE massType) const
 Returns N-term modification delta if there is a correspondent fixed modification applied.
 
double getNterminalMass (const matrix_science::MASS_TYPE massType) const
 Returns N-terminal group mass (i.e. fixed modification delta or H-mass).
 
double getNtermNeutralLoss (const matrix_science::MASS_TYPE massType) const
 Returns N-term neutral loss value if there is a correspondent fixed modification applied.
 
double getOxygenMass (const matrix_science::MASS_TYPE massType) const
 Returns a oxygen (O) atom mass for a given mass type (MONO or AVE).
 
double getResidueMass (const matrix_science::MASS_TYPE massType, const char residue) const
 Returns a mass for a given amino acid.
 
bool isResidueModified (const char residue) const
 Returns true for residues modified by fixed modifications.
 
bool isSame (const ms_masses &other, const MASS_TYPE massType) const
 Return true if other ms_masses is the same as this one.
 
bool isValid () const
 Call this function to determine if there have been any errors.
 
ms_massesoperator= (const ms_masses &right)
 C++ style assignment operator.
 
void read_file ()
 Reads the configuration file, parses it and fill the mass arrays.
 
void save_file ()
 Saves the information back to the file.
 
void saveToString (std::string &modfileAsStr)
 Stores masses information in the string supplied.
 
void setCarbonMass (const double massMono, const double massAve)
 Changes carbon mass values.
 
void setConnectionSettings (const matrix_science::ms_connection_settings &cs)
 Sets the sessionID and proxy server for use with an HTTP transfer.
 
void setCtermModification (const double monoDelta, const double aveDelta, const double monoNeutralLoss=0.0, const double aveNeutralLoss=0.0)
 Set C-term modification.
 
void setElectronMass (const double mass)
 Changes oxygen mass values.
 
void setFileName (const char *name)
 Set a custom file name instead of ../config/masses.
 
void setHydrogenMass (const double massMono, const double massAve)
 Changes hydrogen mass values.
 
void setNitrogenMass (const double massMono, const double massAve)
 Changes nitrogen mass values.
 
void setNtermModification (const double monoDelta, const double aveDelta, const double monoNeutralLoss=0.0, const double aveNeutralLoss=0.0)
 Set N-term modification.
 
void setOxygenMass (const double massMono, const double massAve)
 Changes oxygen mass values.
 
void setResidueMasses (const char residue, const double massMono, const double massAve)
 Changes mass values for a single residue.
 
void setResidueModification (const double monoDelta, const double aveDelta, const double monoNeutralLoss, const double aveNeutralLoss, const char *residues)
 Applies a single residue modification.
 

Detailed Description

Reads and parses the masses file with residue and atom masses.

After reading a file and before using the object, check its validity by calling isValid() and retrieve error descriptions with getLastErrorString() if not valid.

A class instance can be used even if the configuration file has been read with problems or not read at all. Default values will be given to all members in that case.

Examples
config_masses.cpp, config_modfile.cpp, and tools_aahelper.cpp.

Constructor & Destructor Documentation

◆ ms_masses() [1/5]

ms_masses ( )

Default constructor.

Sets default mass values for all residues

◆ ms_masses() [2/5]

ms_masses ( const ms_masses src)

Copying constructor.

Parameters
srcis the source object to copy masses from

◆ ms_masses() [3/5]

ms_masses ( const ms_umod_configfile src,
bool  addMissingResidueMasses = true 
)

Copying constructor.

Implemented by calling copyFrom(const ms_umod_configfile *, bool)

Parameters
srchas the residue and elemental masses that are used to initialise the masses
addMissingResidueMassesis used to specify whether residue masses missing from the src should be set to zero or set to the default masses. If true, then default masses are used and if false, then any missing masses are just set to zero.

◆ ms_masses() [4/5]

ms_masses ( const ms_umod_configfile src,
const ms_quant_component quantComp 
)

Constructor for prepared isotope-substituted version of masses.

Masses of amino-acids are re-calculated with a different isotope applied (for example, 13C instead of C).

Parameters
srca Unimod file object containing the composition of amino acids and original masses.
quantCompa quantitation component containing isotope substitutions used in the quantitation experiment. This object can be created from scratch without reading its content from a file, but normally it should be taken from the quantitation method selected by a user. An alternative way to apply isotope substition is to use applyIsotopes() method.

◆ ms_masses() [5/5]

ms_masses ( const char *  filename,
const matrix_science::ms_connection_settings cs = 0 
)

Reads the file immediately after the construction.

Parameters
filenamecan be either a local file path or a Mascot server URL, it cannot be an empty string or NULL pointer. If it is a URL it should be of the form http://your-server/mascot/cgi .
csis a pointer to the connection settings. This should contain a sessionID and optionally the proxy server settings.

Member Function Documentation

◆ appendErrors()

void appendErrors ( const ms_errors src)
inherited

Copies all errors from another instance and appends them at the end of own list.

Parameters
srcThe object to copy the errors across from. See Maintaining object references: two rules of thumb.

◆ applyFixedMods()

ms_modvector applyFixedMods ( const ms_modvector mods,
ms_errs err 
)

Change residue masses according to the list of fixed modifications.

If you want to get the original (unmodified) masses of amino acids, load them from a file or obtain from another instance of the class.

Fixed modifications can also be applied separately using setNtermModification(), setCtermModification() and setResidueModification().

Parameters
modsis the vector of modifications to apply
erris used to collect the errors. To add any errors to the ms_masses object, pass this->getErrorHandler()
Returns
the new list of modifications

◆ applyIsotopes()

void applyIsotopes ( const ms_umod_configfile umodFile,
const ms_quant_component quantComp 
)

Update masses of amino-acids with isotope substitution.

Call this method explictly in order to re-calculate all amino acid masses according to a selected quantitation method. However, the quantitation component object can also be created on the fly with any custom isotope substitution. All applied fixed modifications are cancelled and should be re-applied if necessary with applyFixedMods() method.

Parameters
umodFilea Unimod file object containing chemical composition of amino acids and element masses.
quantCompa quantitation component object with isotope substitution information. If the object doesn't have any isotope elements in it no action will be taken.

◆ clearAllErrors()

void clearAllErrors ( )
inherited

Remove all errors from the current list of errors.

The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.

All messages are accumulated into a list in this object, until clearAllErrors() is called.

See Error Handling.

See also
isValid(), getLastError(), getLastErrorString(), getErrorHandler()
Examples
common_error.cpp, resfile_error.cpp, and resfile_summary.cpp.

◆ copyFrom() [1/3]

void copyFrom ( const ms_errors right)
inherited

Use this member to make a copy of another instance.

Parameters
rightis the source to initialise from

◆ copyFrom() [2/3]

void copyFrom ( const ms_masses right)

Copies masses from another instance.

Parameters
rightis the source masses object

◆ copyFrom() [3/3]

void copyFrom ( const ms_umod_configfile right,
bool  addMissingResidueMasses = true 
)

Copies masses from a Unimod file.

Parameters
righta pointer to unimod file object to copy the masses from.
addMissingResidueMassesis used to specify whether residue masses missing from right should be set to zero or set to the default masses. If true, then default masses are used and if false, then any missing masses are just set to zero.

◆ defaultValues()

void defaultValues ( bool  useDefaultResidueMasses = true)

Use this member to re-initialise internal members.

Called internally, but may also be used by other applications

Parameters
useDefaultResidueMassesshould be set to true if the residue masses are to be initialised with default values. Otherwise they will all be set to mass zero.

◆ getCarbonMass()

double getCarbonMass ( const matrix_science::MASS_TYPE  massType) const

Returns a carbon(C) atom mass for a given mass type (MONO or AVE).

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the mass of carbon

◆ getConnectionSettings()

matrix_science::ms_connection_settings getConnectionSettings ( ) const

Returns the sessionID and proxy server for use with an HTTP transfer.

See also the constructor documentation and setConnectionSettings().

Returns
The current connection settings.

◆ getCtermDelta()

double getCtermDelta ( const matrix_science::MASS_TYPE  massType) const

Returns C-term modification delta if there is a correspondent fixed modification applied.

See also
getCterminalMass()
Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the delta compared to an unmodified C terminus mass

◆ getCterminalMass()

double getCterminalMass ( const matrix_science::MASS_TYPE  massType) const

Returns C-terminal group mass (i.e. fixed modification delta or OH-mass).

See also
getCtermDelta()
Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the C terminus mass, including any applied modification

◆ getCtermNeutralLoss()

double getCtermNeutralLoss ( const matrix_science::MASS_TYPE  massType) const

Returns C-term neutral loss value if there is a correspondent fixed modification applied.

See also
getCterminalMass()
Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the delta compared to an unmodified C terminus mass

◆ getElectronMass()

double getElectronMass ( ) const

Returns an electron mass.

Returns
the mass of an electron

◆ getErrorHandler()

const ms_errs * getErrorHandler ( ) const
inherited

Retrive the error object using this function to get access to all errors and error parameters.

See Error Handling.

Returns
Constant pointer to the error handler
See also
isValid(), getLastError(), getLastErrorString(), clearAllErrors(), getErrorHandler()
Examples
common_error.cpp, and http_helper_getstring.cpp.

◆ getFileName()

std::string getFileName ( ) const

Returns a file name set before or by default.

See also
setFileName()
Returns
the name of the masses file

◆ getFragResidueMass()

double getFragResidueMass ( const matrix_science::MASS_TYPE  massType,
const char  residue 
) const

Returns a residue mass with neutral loss after applying fixed modifications.

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
residuea single letter encoding an amino acid in the range a..z or A..Z.
Returns
an absolute fragment for the amino acid.

◆ getHydrogenMass()

double getHydrogenMass ( const matrix_science::MASS_TYPE  massType) const

Returns a hydrogen (H) atom mass for a given mass type (MONO or AVE).

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the mass of hydrogen

◆ getLastError()

int getLastError ( ) const
inherited

Return the error description of the last error that occurred.

All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.

See Error Handling.

See also
isValid(), getLastErrorString(), clearAllErrors(), getErrorHandler()
Returns
the error number of the last error, or 0 if there have been no errors.

◆ getLastErrorString()

std::string getLastErrorString ( ) const
inherited

Return the error description of the last error that occurred.

All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.

Returns
Most recent error, warning, information or debug message

See Error Handling.

See also
isValid(), getLastError(), clearAllErrors(), getErrorHandler()
Examples
common_error.cpp, config_enzymes.cpp, config_fragrules.cpp, config_license.cpp, config_mascotdat.cpp, config_masses.cpp, config_modfile.cpp, config_procs.cpp, config_quantitation.cpp, config_taxonomy.cpp, http_helper_getstring.cpp, and tools_aahelper.cpp.

◆ getNitrogenMass()

double getNitrogenMass ( const matrix_science::MASS_TYPE  massType) const

Returns a nitrogen (N) atom mass for a given mass type (MONO or AVE).

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the mass of nitrogen

◆ getNtermDelta()

double getNtermDelta ( const matrix_science::MASS_TYPE  massType) const

Returns N-term modification delta if there is a correspondent fixed modification applied.

See also
getNterminalMass()
Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the delta compared to an unmodified N terminus mass

◆ getNterminalMass()

double getNterminalMass ( const matrix_science::MASS_TYPE  massType) const

Returns N-terminal group mass (i.e. fixed modification delta or H-mass).

See also
getNtermDelta()
Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the N terminus mass, including any applied modification

◆ getNtermNeutralLoss()

double getNtermNeutralLoss ( const matrix_science::MASS_TYPE  massType) const

Returns N-term neutral loss value if there is a correspondent fixed modification applied.

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
any neutral loss on the N terminus

◆ getOxygenMass()

double getOxygenMass ( const matrix_science::MASS_TYPE  massType) const

Returns a oxygen (O) atom mass for a given mass type (MONO or AVE).

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
Returns
the mass of oxygen

◆ getResidueMass()

double getResidueMass ( const matrix_science::MASS_TYPE  massType,
const char  residue 
) const

Returns a mass for a given amino acid.

Parameters
massTypeone of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE).
residuea single letter encoding an amino acid in the range a..z or A..Z.
Returns
an absolute mass for the amino acid.
Examples
config_masses.cpp.

◆ isResidueModified()

bool isResidueModified ( const char  residue) const

Returns true for residues modified by fixed modifications.

Parameters
residuea single letter encoding an amino acid in the range a..z or A..Z.
Returns
true for residues modified by fixed modifications.

◆ isSame()

bool isSame ( const ms_masses right,
const MASS_TYPE  massType 
) const

Return true if other ms_masses is the same as this one.

Parameters
rightis the object to test against
massTypespecifies whether to compare monoisotopic or average masses.
Returns
true if all the masses are the same

◆ isValid()

bool isValid ( ) const
inherited

◆ operator=()

ms_masses & operator= ( const ms_masses right)

C++ style assignment operator.

Only available for C++

Parameters
rightis the source object
Returns
a reference to 'this'

◆ read_file()

void read_file ( )

Reads the configuration file, parses it and fill the mass arrays.

Called from the constructor: ms_masses(const char*, const ms_connection_settings*)

◆ save_file()

void save_file ( )

Saves the information back to the file.

See also
setFileName() If the file cannot be opened for writing, an ms_errs::ERR_MSP_FAILED_TO_OPEN_FILE error is added.

Other errors in saving the file use ms_errs::ERR_MSP_FAILED_TO_WRITE_FILE

◆ saveToString()

void saveToString ( std::string &  asStr)

Stores masses information in the string supplied.

See Multiple return values in Perl, Java, Python and C#.

Parameters
[out]asStris the complete file as a string

◆ setCarbonMass()

void setCarbonMass ( const double  massMono,
const double  massAve 
)

Changes carbon mass values.

Parameters
massMonois the new monoisotopic mass of carbon
massAveis the new average mass of carbon

◆ setConnectionSettings()

void setConnectionSettings ( const matrix_science::ms_connection_settings cs)

Sets the sessionID and proxy server for use with an HTTP transfer.

This value would normally be passed in the constructor.

Parameters
csis the new connection settings.

◆ setCtermModification()

void setCtermModification ( const double  monoDelta,
const double  aveDelta,
const double  monoNeutralLoss = 0.0,
const double  aveNeutralLoss = 0.0 
)

Set C-term modification.

Warning
The name of this function and the name of the first two parameters are potentially misleading.
Parameters
monoDeltais the mass of the CTerminus. If there is no fixed modification, the value passed should be the monoisotopic mass of hydrogen plus the monoisotopic mass of oxygen.
aveDeltais the mass of the CTerminus. If there is no fixed modification, the value passed should be the average mass of hydrogen plus the average mass of oxygen.
monoNeutralLossis the neutral loss of any fixed C terminus modification.
aveNeutralLossis the neutral loss of any fixed C terminusmodification.

◆ setElectronMass()

void setElectronMass ( const double  mass)

Changes oxygen mass values.

Parameters
massis the new monoisotopic mass of an electron

◆ setFileName()

void setFileName ( const char *  name)

Set a custom file name instead of ../config/masses.

Does not re-read the file, just saves the new name

See also
getFileName()
read_file()
Parameters
nameis the new file name

◆ setHydrogenMass()

void setHydrogenMass ( const double  massMono,
const double  massAve 
)

Changes hydrogen mass values.

Parameters
massMonois the new monoisotopic mass of hydrogen
massAveis the new average mass of hydrogen

◆ setNitrogenMass()

void setNitrogenMass ( const double  massMono,
const double  massAve 
)

Changes nitrogen mass values.

Parameters
massMonois the new monoisotopic mass of nitrogen
massAveis the new average mass of nitrogen

◆ setNtermModification()

void setNtermModification ( const double  monoDelta,
const double  aveDelta,
const double  monoNeutralLoss = 0.0,
const double  aveNeutralLoss = 0.0 
)

Set N-term modification.

Warning
The name of this function and the name of the first two parameters are potentially misleading.
Parameters
monoDeltais the mass of the NTerminus. If there is no fixed modification, the value passed should be the monoisotopic mass of hydrogen.
aveDeltais the mass of the NTerminus. If there is no fixed modification, the value passed should be the average mass of hydrogen.
monoNeutralLossis the neutral loss of any fixed N terminus modification.
aveNeutralLossis the neutral loss of any fixed N terminus modification.

◆ setOxygenMass()

void setOxygenMass ( const double  massMono,
const double  massAve 
)

Changes oxygen mass values.

Parameters
massMonois the new monoisotopic mass of oxygen
massAveis the new average mass of oxygen

◆ setResidueMasses()

void setResidueMasses ( const char  residue,
const double  massMono,
const double  massAve 
)

Changes mass values for a single residue.

Parameters
residuea single letter encoding an amino acid in the range a..z or A..Z.
massMonois the new monoisotopic mass for the residue
massAveis the new average mass for the residue

◆ setResidueModification()

void setResidueModification ( const double  monoDelta,
const double  aveDelta,
const double  monoNeutralLoss,
const double  aveNeutralLoss,
const char *  residues 
)

Applies a single residue modification.

Parameters
monoDeltais the delta in daltons for monoisotopic masses
aveDeltais the delta in daltons for average masses
monoNeutralLossis the neutral loss for monoisotopic masses (typically zero)
aveNeutralLossis the neutral loss for average masses (typically zero)
residuesis a null terminated string with one or more letters which encoding amino acids in the range a..z or A..Z.

The documentation for this class was generated from the following files: