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>
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_errs * | getErrorHandler () 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_peak * | getPeak (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_list & | operator= (const ms_spectral_lib_peak_list &right) |
C++ style assignment operator. | |
void | setAnnotationLevel (PEAK_ANNOTATION_LEVEL level) |
This class is used to encapsulate a peak list from a single spectrum in a NIST .msp or a SpectraST .sptxt file.
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. |
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.
input | is a vector or raw strings from the .msp file. |
format | is one of the ms_spectral_lib::FILE_FORMAT values. |
ms_spectral_lib_peak_list | ( | const ms_spectral_lib_peak_list & | src | ) |
Copying constructor.
src | is the source to initialise from |
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.
vecMz | vector of m/z values |
vecIntensity | vector of intensity values |
void annotatePeaks | ( | const ms_fragmentvector * | fragments, |
const double | fragmentToleranceValue, | ||
const std::string | fragmentToleranceUnit, | ||
double | precursorMz | ||
) |
annotate peaks for the given tolerance.
fragments | to a vector of fragments to be used for annotation |
fragmentToleranceValue | fragment tolerance as a double |
fragmentToleranceUnit | fragment tolerance unit (ppm, %, mmu or Da) |
precursorMz | m/z value of the precursor, used to annotate a peak with a p class (p for precursor) |
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.
fragments | to a vector of fragments to be used for annotation, it doesn't have to be sorted |
fragmentToleranceValue | fragment tolerance as a double |
fragmentToleranceUnit | fragment tolerance unit (ppm, %, mmu or Da) |
precursorMz | m/z value of the precursor, used to annotate a peak with a p class (p for precursor) |
|
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. |
|
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.
void clearAnnotation | ( | ) |
Removes all annotation from all peaks.
Does not change the file format associated with each peak.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_spectral_lib_peak_list * | right | ) |
Use this member to make a copy of another instance.
right | is the source to initialise from |
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
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
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.
|
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.
int getNumPeaks | ( | ) | const |
Returns the number of peaks in the peak list.
const ms_spectral_lib_peak * getPeak | ( | const int | pkNum | ) | const |
Return a single peak.
pkNum | must be in the range 1..getNumPeaks() |
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.
|
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.
ms_spectral_lib_peak_list & operator= | ( | const ms_spectral_lib_peak_list & | right | ) |
C++ style assignment operator.
right | is the source to initialise from |
void setAnnotationLevel | ( | PEAK_ANNOTATION_LEVEL | level | ) |
level | is the new annotation level |