Parser and writer for mzPAF (Peak Annotation Format) notation.
More...
#include <OpenMS/CHEMISTRY/MzPAF.h>
|
| static MzPAFAnnotation | parse (const std::string &input) |
| | Parse an mzPAF string into a single annotation.
|
| |
| static MzPAFPeakAnnotations | parseMultiple (const std::string &input) |
| | Parse an mzPAF string with potentially multiple annotations.
|
| |
| static std::optional< MzPAFAnnotation > | tryParse (const std::string &input) |
| | Try to parse an mzPAF string (non-throwing)
|
| |
| static std::optional< MzPAFPeakAnnotations > | tryParseMultiple (const std::string &input) |
| | Try to parse multiple annotations (non-throwing)
|
| |
| static std::string | toString (const MzPAFAnnotation &ann) |
| | Convert an annotation to mzPAF string.
|
| |
| static std::string | toString (const MzPAFPeakAnnotations &anns) |
| | Convert multiple annotations to mzPAF string.
|
| |
| static PeptideHit::PeakAnnotation | toPeakAnnotation (const MzPAFAnnotation &mzpaf, double mz, double intensity) |
| | Create a PeptideHit::PeakAnnotation from mzPAF data.
|
| |
| static MzPAFPeakAnnotations | fromPeakAnnotation (const PeptideHit::PeakAnnotation &peak_annotation) |
| | Parse mzPAF annotations from a PeptideHit::PeakAnnotation.
|
| |
| static bool | isMzPAFFormat (const std::string &annotation) |
| | Check if a string appears to be in mzPAF format.
|
| |
| static std::optional< double > | calculateTheoreticalMZ (const MzPAFAnnotation &ann, const AASequence &sequence) |
| | Calculate theoretical m/z for an annotation.
|
| |
| static bool | isPeptideFragmentIon (MzPAFIonSeries series) |
| | Check if ion series is a peptide fragment ion (a, b, c, d, v, w, x, y, z)
|
| |
| static char | ionSeriesToChar (MzPAFIonSeries series) |
| | Get the ion series character for an annotation.
|
| |
| static bool | charToIonSeries (char c, MzPAFIonSeries &series) |
| | Parse ion series from character.
|
| |
Parser and writer for mzPAF (Peak Annotation Format) notation.
mzPAF is the HUPO-PSI standard string notation for fragment ion peak annotations, used in mzSpecLib and other spectral library formats.
This class provides static methods for:
Usage example:
static MzPAFAnnotation parse(const std::string &input)
Parse an mzPAF string into a single annotation.
static MzPAFPeakAnnotations parseMultiple(const std::string &input)
Parse an mzPAF string with potentially multiple annotations.
static bool isMzPAFFormat(const std::string &annotation)
Check if a string appears to be in mzPAF format.
static std::string toString(const MzPAFAnnotation &ann)
Convert an annotation to mzPAF string.
A single mzPAF peak annotation.
Definition MzPAF.h:129
Multiple mzPAF annotations for a single peak.
Definition MzPAF.h:167
- See also
- MzPAFAnnotation, MzPAFPeakAnnotations
◆ MzPAF()
◆ calculateTheoreticalMZ()
Calculate theoretical m/z for an annotation.
Calculates the theoretical m/z value for the annotated ion based on the sequence.
- Note
- Satellite ions (d, v, w, including their subtypes) are parsed and serialized, but their residue-dependent side-chain losses are not yet supported here; these ions return std::nullopt.
- Parameters
-
| [in] | ann | The annotation |
| [in] | sequence | The peptide sequence |
- Returns
- Theoretical m/z, or std::nullopt if calculation not possible
◆ charToIonSeries()
Parse ion series from character.
- Parameters
-
| [in] | c | The character to parse |
| [out] | series | Output ion series if successful |
- Returns
- True if parsing successful
◆ fromPeakAnnotation()
Parse mzPAF annotations from a PeptideHit::PeakAnnotation.
Attempts to parse the annotation string from a PeakAnnotation as mzPAF.
- Parameters
-
| [in] | peak_annotation | The PeakAnnotation to parse |
- Returns
- Parsed mzPAF annotations, or empty if not valid mzPAF
◆ ionSeriesToChar()
Get the ion series character for an annotation.
- Parameters
-
| [in] | series | The ion series enum |
- Returns
- The character representation (a, b, c, d, v, w, x, y, z, p, I, m, r, f, _)
- Note
- The satellite subtype is stored separately in MzPAFAnnotation::satellite_subtype.
◆ isMzPAFFormat()
| static bool isMzPAFFormat |
( |
const std::string & |
annotation | ) |
|
|
static |
Check if a string appears to be in mzPAF format.
Performs a quick heuristic check to determine if a string looks like mzPAF notation.
- Parameters
-
| [in] | annotation | The string to check |
- Returns
- True if the string appears to be mzPAF format
◆ isPeptideFragmentIon()
Check if ion series is a peptide fragment ion (a, b, c, d, v, w, x, y, z)
These are exactly the series that mzPAF requires to carry an ordinal.
- Parameters
-
| [in] | series | The ion series to check |
- Returns
- True if it's a peptide fragment ion type
- Note
- True here does not imply a computable mass. calculateTheoreticalMZ() returns std::nullopt for the satellite series d/v/w, so
if (isPeptideFragmentIon(s)) mz = *calculateTheoreticalMZ(...) would dereference an empty optional.
◆ parse()
Parse an mzPAF string into a single annotation.
- Parameters
-
| [in] | input | The mzPAF string to parse |
- Returns
- The parsed annotation
- Exceptions
-
- Note
- If the input contains multiple comma-separated annotations, only the first is returned. Use parseMultiple() for multi-annotation strings.
◆ parseMultiple()
Parse an mzPAF string with potentially multiple annotations.
- Parameters
-
| [in] | input | The mzPAF string to parse (may contain comma-separated annotations) |
- Returns
- All parsed annotations
- Exceptions
-
◆ toPeakAnnotation()
◆ toString() [1/2]
Convert an annotation to mzPAF string.
- Parameters
-
| [in] | ann | The annotation to convert |
- Returns
- The mzPAF string representation
- Note
- This function is total and never throws. An annotation carrying a satellite subtype that mzPAF does not allow – anything other than 'a'/'b', or a subtype on a series other than d/w – is written without it, mirroring how an UNKNOWN series is written as '?'. Use isValid() to reject such an annotation.
◆ toString() [2/2]
Convert multiple annotations to mzPAF string.
- Parameters
-
| [in] | anns | The annotations to convert |
- Returns
- The mzPAF string representation (comma-separated)
◆ tryParse()
| static std::optional< MzPAFAnnotation > tryParse |
( |
const std::string & |
input | ) |
|
|
static |
Try to parse an mzPAF string (non-throwing)
- Parameters
-
| [in] | input | The mzPAF string to parse |
- Returns
- The parsed annotation, or std::nullopt on failure
◆ tryParseMultiple()
Try to parse multiple annotations (non-throwing)
- Parameters
-
| [in] | input | The mzPAF string to parse |
- Returns
- The parsed annotations, or empty on failure