Reads and parses the masses
file with residue and atom masses.
More...
#include <ms_masses.hpp>
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_errs * | getErrorHandler () 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_masses & | operator= (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. | |
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.
ms_masses | ( | ) |
Default constructor.
Sets default mass values for all residues
Copying constructor.
src | is the source object to copy masses from |
ms_masses | ( | const ms_umod_configfile & | src, |
bool | addMissingResidueMasses = true |
||
) |
Copying constructor.
Implemented by calling copyFrom(const ms_umod_configfile *, bool)
src | has the residue and elemental masses that are used to initialise the masses |
addMissingResidueMasses | is 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 | ( | 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).
src | a Unimod file object containing the composition of amino acids and original masses. |
quantComp | a 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 | ( | const char * | filename, |
const matrix_science::ms_connection_settings * | cs = 0 |
||
) |
Reads the file immediately after the construction.
filename | can 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 . |
cs | is a pointer to the connection settings. This should contain a sessionID and optionally the proxy server settings. |
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
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().
mods | is the vector of modifications to apply |
err | is used to collect the errors. To add any errors to the ms_masses object, pass this->getErrorHandler() |
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.
umodFile | a Unimod file object containing chemical composition of amino acids and element masses. |
quantComp | a quantitation component object with isotope substitution information. If the object doesn't have any isotope elements in it no action will be taken. |
|
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.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_masses * | right | ) |
Copies masses from another instance.
right | is the source masses object |
void copyFrom | ( | const ms_umod_configfile * | right, |
bool | addMissingResidueMasses = true |
||
) |
Copies masses from a Unimod file.
right | a pointer to unimod file object to copy the masses from. |
addMissingResidueMasses | is 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. |
void defaultValues | ( | bool | useDefaultResidueMasses = true | ) |
Use this member to re-initialise internal members.
Called internally, but may also be used by other applications
useDefaultResidueMasses | should be set to true if the residue masses are to be initialised with default values. Otherwise they will all be set to mass zero. |
double getCarbonMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns a carbon(C) atom mass for a given mass type (MONO or AVE).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
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().
double getCtermDelta | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns C-term modification delta if there is a correspondent fixed modification applied.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getCterminalMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns C-terminal group mass (i.e. fixed modification delta or OH-mass).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getCtermNeutralLoss | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns C-term neutral loss value if there is a correspondent fixed modification applied.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getElectronMass | ( | ) | const |
Returns an electron mass.
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
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.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
residue | a single letter encoding an amino acid in the range a..z or A..Z. |
double getHydrogenMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns a hydrogen (H) atom mass for a given mass type (MONO or AVE).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
|
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.
|
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.
double getNitrogenMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns a nitrogen (N) atom mass for a given mass type (MONO or AVE).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getNtermDelta | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns N-term modification delta if there is a correspondent fixed modification applied.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getNterminalMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns N-terminal group mass (i.e. fixed modification delta or H-mass).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getNtermNeutralLoss | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns N-term neutral loss value if there is a correspondent fixed modification applied.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getOxygenMass | ( | const matrix_science::MASS_TYPE | massType | ) | const |
Returns a oxygen (O) atom mass for a given mass type (MONO or AVE).
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
double getResidueMass | ( | const matrix_science::MASS_TYPE | massType, |
const char | residue | ||
) | const |
Returns a mass for a given amino acid.
massType | one of two mass types (MASS_TYPE_MONO or MASS_TYPE_AVE). |
residue | a single letter encoding an amino acid in the range a..z or A..Z. |
bool isResidueModified | ( | const char | residue | ) | const |
Returns true for residues modified by fixed modifications.
residue | a single letter encoding an amino acid in the range a..z or A..Z. |
Return true if other ms_masses is the same as this one.
right | is the object to test against |
massType | specifies whether to compare monoisotopic or average masses. |
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
C++ style assignment operator.
Only available for C++
right | is the source object |
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*)
void save_file | ( | ) |
Saves the information back to the file.
Other errors in saving the file use ms_errs::ERR_MSP_FAILED_TO_WRITE_FILE
void saveToString | ( | std::string & | asStr | ) |
Stores masses information in the string supplied.
See Multiple return values in Perl, Java, Python and C#.
[out] | asStr | is the complete file as a string |
void setCarbonMass | ( | const double | massMono, |
const double | massAve | ||
) |
Changes carbon mass values.
massMono | is the new monoisotopic mass of carbon |
massAve | is the new average mass of carbon |
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.
cs | is the new connection settings. |
void setCtermModification | ( | const double | monoDelta, |
const double | aveDelta, | ||
const double | monoNeutralLoss = 0.0 , |
||
const double | aveNeutralLoss = 0.0 |
||
) |
Set C-term modification.
monoDelta | is 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. |
aveDelta | is 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. |
monoNeutralLoss | is the neutral loss of any fixed C terminus modification. |
aveNeutralLoss | is the neutral loss of any fixed C terminusmodification. |
void setElectronMass | ( | const double | mass | ) |
Changes oxygen mass values.
mass | is the new monoisotopic mass of an electron |
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
name | is the new file name |
void setHydrogenMass | ( | const double | massMono, |
const double | massAve | ||
) |
Changes hydrogen mass values.
massMono | is the new monoisotopic mass of hydrogen |
massAve | is the new average mass of hydrogen |
void setNitrogenMass | ( | const double | massMono, |
const double | massAve | ||
) |
Changes nitrogen mass values.
massMono | is the new monoisotopic mass of nitrogen |
massAve | is the new average mass of nitrogen |
void setNtermModification | ( | const double | monoDelta, |
const double | aveDelta, | ||
const double | monoNeutralLoss = 0.0 , |
||
const double | aveNeutralLoss = 0.0 |
||
) |
Set N-term modification.
monoDelta | is the mass of the NTerminus. If there is no fixed modification, the value passed should be the monoisotopic mass of hydrogen. |
aveDelta | is the mass of the NTerminus. If there is no fixed modification, the value passed should be the average mass of hydrogen. |
monoNeutralLoss | is the neutral loss of any fixed N terminus modification. |
aveNeutralLoss | is the neutral loss of any fixed N terminus modification. |
void setOxygenMass | ( | const double | massMono, |
const double | massAve | ||
) |
Changes oxygen mass values.
massMono | is the new monoisotopic mass of oxygen |
massAve | is the new average mass of oxygen |
void setResidueMasses | ( | const char | residue, |
const double | massMono, | ||
const double | massAve | ||
) |
Changes mass values for a single residue.
residue | a single letter encoding an amino acid in the range a..z or A..Z. |
massMono | is the new monoisotopic mass for the residue |
massAve | is the new average mass for the residue |
void setResidueModification | ( | const double | monoDelta, |
const double | aveDelta, | ||
const double | monoNeutralLoss, | ||
const double | aveNeutralLoss, | ||
const char * | residues | ||
) |
Applies a single residue modification.
monoDelta | is the delta in daltons for monoisotopic masses |
aveDelta | is the delta in daltons for average masses |
monoNeutralLoss | is the neutral loss for monoisotopic masses (typically zero) |
aveNeutralLoss | is the neutral loss for average masses (typically zero) |
residues | is a null terminated string with one or more letters which encoding amino acids in the range a..z or A..Z. |