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

This class is used to encapsulate a peak list from a single spectrum in a NIST .msp or a SpectraST .sptxt file. More...

#include <ms_spectral_lib_peak_list.hpp>

Inheritance diagram for ms_spectral_lib_peak_list:
Collaboration diagram for ms_spectral_lib_peak_list:

Public Types

enum  PEAK_ANNOTATION_LEVEL {
  ANNOT_LVL_NONE ,
  ANNOT_LVL_QUESTION_MARKS ,
  ANNOT_LVL_SOME_PEAKS ,
  ANNOT_LVL_CANNOT_ANNOTATE
}
 Amount of annotation as returned by getAnnotationLevel() More...
 

Public Member Functions

 ms_spectral_lib_peak_list ()
 Constructor.
 
 ms_spectral_lib_peak_list (const ms_spectral_lib_peak_list &src)
 Copying constructor.
 
 ms_spectral_lib_peak_list (std::vector< std::string > input, ms_spectral_lib::FILE_FORMAT format)
 Constructor from a peak list in NIST format.
 
 ~ms_spectral_lib_peak_list ()
 Destructor.
 
void addPeaks (const std::vector< double > &vecMz, const std::vector< double > &vecIntensity)
 add peaks from masses and intensities
 
void annotatePeaks (const ms_fragmentvector *fragments, const double fragmentToleranceValue, const std::string fragmentToleranceUnit, double precursorMz)
 annotate peaks for the given tolerance.
 
void annotatePeaks (const std::vector< ms_fragment > *fragments, const double fragmentToleranceValue, const std::string fragmentToleranceUnit, double precursorMz)
 annotate peaks for the given tolerance, from a C++ vector.
 
void appendErrors (const ms_errors &src)
 Copies all errors from another instance and appends them at the end of own list.
 
std::vector< std::string > asText (ms_spectral_lib::FILE_FORMAT format) const
 Return the whole peak list as an array of strings.
 
void clearAllErrors ()
 Remove all errors from the current list of errors.
 
void clearAnnotation ()
 Removes all annotation from all peaks.
 
void copyFrom (const ms_errors *right)
 Use this member to make a copy of another instance.
 
void copyFrom (const ms_spectral_lib_peak_list *right)
 Use this member to make a copy of another instance.
 
std::string getChecksum () const
 Return the 'checksum' for the original peak list before any calls to annotatePeaks.
 
const ms_errsgetErrorHandler () const
 Retrive the error object using this function to get access to all errors and error parameters.
 
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.
 
int getNumPeaks () const
 Returns the number of peaks in the peak list.
 
const ms_spectral_lib_peakgetPeak (const int pkNum) const
 Return a single peak.
 
PEAK_ANNOTATION_LEVEL getPeakAnnotationLevel () const
 Return information about the amount of peak annotation - i.e. what experimental peaks matched to calculated peaks.
 
bool isValid () const
 Call this function to determine if there have been any errors.
 
ms_spectral_lib_peak_listoperator= (const ms_spectral_lib_peak_list &right)
 C++ style assignment operator.
 
void setAnnotationLevel (PEAK_ANNOTATION_LEVEL level)
 

Detailed Description

This class is used to encapsulate a peak list from a single spectrum in a NIST .msp or a SpectraST .sptxt file.

Member Enumeration Documentation

◆ PEAK_ANNOTATION_LEVEL

Amount of annotation as returned by getAnnotationLevel()

See Using enumerated values and static const ints in Perl, Java, Python and C#.

See ms_spectral_lib_peak::getAnnotation for a description of the annotation format.

Most files supplied by NIST have annotation, but PRIDE files don't have any annotation.

Enumerator
ANNOT_LVL_NONE 

None of the peaks have any annotation.

ANNOT_LVL_QUESTION_MARKS 

In Parser 2.6.0, when calling ms_spectral_lib_file::saveAs(), the resulting file adds "?" to each peak without annotation. At least one peak has a question mark, and none have any 'matching' annotation.

ANNOT_LVL_SOME_PEAKS 

One or more peaks have annotation that is not just a "?".

ANNOT_LVL_CANNOT_ANNOTATE 

A call to ms_spectral_lib_entry::annotatePeaks() or ms_spectral_lib_peak_list::annotatePeaks() failed to annotate the peak list.

Constructor & Destructor Documentation

◆ ms_spectral_lib_peak_list() [1/2]

ms_spectral_lib_peak_list ( std::vector< std::string >  input,
ms_spectral_lib::FILE_FORMAT  format 
)

Constructor from a peak list in NIST format.

An ms_spectral_lib_peak_list object is nomally created by calling ms_spectral_lib_entry::getPeakListObject rather than calling this constructor which simply creates the ms_spectral_lib_peak objects using this constructor.

Leading and trailing white space is removed from each line.

Any format errors will be set in this object and isValid() will then return false.

Parameters
inputis a vector or raw strings from the .msp file.
formatis one of the ms_spectral_lib::FILE_FORMAT values.

◆ ms_spectral_lib_peak_list() [2/2]

Copying constructor.

Parameters
srcis the source to initialise from

Member Function Documentation

◆ addPeaks()

void addPeaks ( const std::vector< double > &  vecMz,
const std::vector< double > &  vecIntensity 
)

add peaks from masses and intensities

Note that both vectors MUST have the same size.

Existing peaks are not removed.

Parameters
vecMzvector of m/z values
vecIntensityvector of intensity values

◆ annotatePeaks() [1/2]

void annotatePeaks ( const ms_fragmentvector fragments,
const double  fragmentToleranceValue,
const std::string  fragmentToleranceUnit,
double  precursorMz 
)

annotate peaks for the given tolerance.

See also
annotatePeaks(const std::vector<ms_fragment> *fragments, const double fragmentToleranceValue, const std::string fragmentToleranceUnit, double precursorMz)
Parameters
fragmentsto a vector of fragments to be used for annotation
fragmentToleranceValuefragment tolerance as a double
fragmentToleranceUnitfragment tolerance unit (ppm, %, mmu or Da)
precursorMzm/z value of the precursor, used to annotate a peak with a p class (p for precursor)

◆ annotatePeaks() [2/2]

void annotatePeaks ( const std::vector< ms_fragment > *  fragments,
const double  fragmentToleranceValue,
const std::string  fragmentToleranceUnit,
double  precursorMz 
)

annotate peaks for the given tolerance, from a C++ vector.

Annotate the peaks stored in the object according to the NIST format, if the provided format is different, the NIST format will still be used. The existing annotation on peaks is overriden. All annotations are between double quotes.

Note that default values are used for the mass of Nitrogen, Helium, Oxygen and Carbon, the mono-isotopic type of these values are used. If a peak cannot be encoded in MSP format (for example for w ion series), or if there is no matching fragment, the annotation of the peak will be "?". Ion series c, x and z are not accepted in the MSP format; ion series b, y and y are respectively used instead with a differential neutral loss.

Parameters
fragmentsto a vector of fragments to be used for annotation, it doesn't have to be sorted
fragmentToleranceValuefragment tolerance as a double
fragmentToleranceUnitfragment tolerance unit (ppm, %, mmu or Da)
precursorMzm/z value of the precursor, used to annotate a peak with a p class (p for precursor)

◆ 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.

◆ 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.

◆ clearAnnotation()

void clearAnnotation ( )

Removes all annotation from all peaks.

Does not change the file format associated with each peak.

See also ms_spectral_lib_peak::clearAnnotation

◆ copyFrom() [1/2]

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/2]

void copyFrom ( const ms_spectral_lib_peak_list right)

Use this member to make a copy of another instance.

Parameters
rightis the source to initialise from

◆ getChecksum()

std::string getChecksum ( ) const

Return the 'checksum' for the original peak list before any calls to annotatePeaks.

All spaces, tabs, newlines, carriage returns and quotation marks are removed before calculating the checksum

This is the checksum of the original 'file' entry before any annotations have been added, or format changes made.

For example: aj5r7ovt6b6q4wr7btazzd4s6i

Returns
the checksum as a string

◆ 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.

◆ 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.

◆ getNumPeaks()

int getNumPeaks ( ) const

Returns the number of peaks in the peak list.

Returns
the number of peaks in the list

◆ getPeak()

const ms_spectral_lib_peak * getPeak ( const int  pkNum) const

Return a single peak.

Parameters
pkNummust be in the range 1..getNumPeaks()
Returns
a pointer to the peak object, or 0 if pkNum is out of range

◆ getPeakAnnotationLevel()

ms_spectral_lib_peak_list::PEAK_ANNOTATION_LEVEL getPeakAnnotationLevel ( ) const

Return information about the amount of peak annotation - i.e. what experimental peaks matched to calculated peaks.

Returns
one of the ms_spectral_lib_peak_list::PEAK_ANNOTATION_LEVEL values

◆ isValid()

bool isValid ( ) const
inherited

◆ operator=()

ms_spectral_lib_peak_list & operator= ( const ms_spectral_lib_peak_list right)

C++ style assignment operator.

Parameters
rightis the source to initialise from
Returns
reference to the current object

◆ setAnnotationLevel()

void setAnnotationLevel ( PEAK_ANNOTATION_LEVEL  level)
Parameters
levelis the new annotation level

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