OpenMS
Loading...
Searching...
No Matches
MzPAF Class Reference

Parser and writer for mzPAF (Peak Annotation Format) notation. More...

#include <OpenMS/CHEMISTRY/MzPAF.h>

Static Public Member Functions

static MzPAFAnnotation parse (const String &input)
 Parse an mzPAF string into a single annotation.
 
static MzPAFPeakAnnotations parseMultiple (const String &input)
 Parse an mzPAF string with potentially multiple annotations.
 
static std::optional< MzPAFAnnotationtryParse (const String &input)
 Try to parse an mzPAF string (non-throwing)
 
static std::optional< MzPAFPeakAnnotationstryParseMultiple (const String &input)
 Try to parse multiple annotations (non-throwing)
 
static String toString (const MzPAFAnnotation &ann)
 Convert an annotation to mzPAF string.
 
static 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 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 isStandardFragmentIon (MzPAFIonSeries series)
 Check if ion series is a standard fragment ion (a, b, c, 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.
 

Private Member Functions

 MzPAF ()=delete
 

Detailed Description

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:

// Parse a single annotation
MzPAFAnnotation ann = MzPAF::parse("y4^2-H2O/0.001*0.75");
// Parse multiple annotations (comma-separated)
// Convert back to string
// Check if a string is mzPAF format
if (MzPAF::isMzPAFFormat("y4^2")) { ... }
static MzPAFPeakAnnotations parseMultiple(const String &input)
Parse an mzPAF string with potentially multiple annotations.
static MzPAFAnnotation parse(const String &input)
Parse an mzPAF string into a single annotation.
static bool isMzPAFFormat(const String &annotation)
Check if a string appears to be in mzPAF format.
static String toString(const MzPAFAnnotation &ann)
Convert an annotation to mzPAF string.
A more convenient string class.
Definition String.h:34
A single mzPAF peak annotation.
Definition MzPAF.h:121
Multiple mzPAF annotations for a single peak.
Definition MzPAF.h:158
See also
MzPAFAnnotation, MzPAFPeakAnnotations

Constructor & Destructor Documentation

◆ MzPAF()

MzPAF ( )
privatedelete

Member Function Documentation

◆ calculateTheoreticalMZ()

static std::optional< double > calculateTheoreticalMZ ( const MzPAFAnnotation ann,
const AASequence sequence 
)
static

Calculate theoretical m/z for an annotation.

Calculates the theoretical m/z value for the annotated ion based on the sequence.

Parameters
[in]annThe annotation
[in]sequenceThe peptide sequence
Returns
Theoretical m/z, or std::nullopt if calculation not possible

◆ charToIonSeries()

static bool charToIonSeries ( char  c,
MzPAFIonSeries series 
)
static

Parse ion series from character.

Parameters
[in]cThe character to parse
[out]seriesOutput ion series if successful
Returns
True if parsing successful

◆ fromPeakAnnotation()

static MzPAFPeakAnnotations fromPeakAnnotation ( const PeptideHit::PeakAnnotation peak_annotation)
static

Parse mzPAF annotations from a PeptideHit::PeakAnnotation.

Attempts to parse the annotation string from a PeakAnnotation as mzPAF.

Parameters
[in]peak_annotationThe PeakAnnotation to parse
Returns
Parsed mzPAF annotations, or empty if not valid mzPAF

◆ ionSeriesToChar()

static char ionSeriesToChar ( MzPAFIonSeries  series)
static

Get the ion series character for an annotation.

Parameters
[in]seriesThe ion series enum
Returns
The character representation (a, b, c, x, y, z, p, I, m, r, f, _)

◆ isMzPAFFormat()

static bool isMzPAFFormat ( const 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]annotationThe string to check
Returns
True if the string appears to be mzPAF format

◆ isStandardFragmentIon()

static bool isStandardFragmentIon ( MzPAFIonSeries  series)
static

Check if ion series is a standard fragment ion (a, b, c, x, y, z)

Parameters
[in]seriesThe ion series to check
Returns
True if it's a standard fragment ion type

◆ parse()

static MzPAFAnnotation parse ( const String input)
static

Parse an mzPAF string into a single annotation.

Parameters
[in]inputThe mzPAF string to parse
Returns
The parsed annotation
Exceptions
MzPAFParseErrorif parsing fails
Note
If the input contains multiple comma-separated annotations, only the first is returned. Use parseMultiple() for multi-annotation strings.

◆ parseMultiple()

static MzPAFPeakAnnotations parseMultiple ( const String input)
static

Parse an mzPAF string with potentially multiple annotations.

Parameters
[in]inputThe mzPAF string to parse (may contain comma-separated annotations)
Returns
All parsed annotations
Exceptions
MzPAFParseErrorif parsing fails

◆ toPeakAnnotation()

static PeptideHit::PeakAnnotation toPeakAnnotation ( const MzPAFAnnotation mzpaf,
double  mz,
double  intensity 
)
static

Create a PeptideHit::PeakAnnotation from mzPAF data.

Converts an MzPAFAnnotation to the OpenMS PeakAnnotation format used in PeptideHit.

Parameters
[in]mzpafThe mzPAF annotation
[in]mzThe observed m/z value
[in]intensityThe peak intensity
Returns
A PeptideHit::PeakAnnotation

◆ toString() [1/2]

static String toString ( const MzPAFAnnotation ann)
static

Convert an annotation to mzPAF string.

Parameters
[in]annThe annotation to convert
Returns
The mzPAF string representation

◆ toString() [2/2]

static String toString ( const MzPAFPeakAnnotations anns)
static

Convert multiple annotations to mzPAF string.

Parameters
[in]annsThe annotations to convert
Returns
The mzPAF string representation (comma-separated)

◆ tryParse()

static std::optional< MzPAFAnnotation > tryParse ( const String input)
static

Try to parse an mzPAF string (non-throwing)

Parameters
[in]inputThe mzPAF string to parse
Returns
The parsed annotation, or std::nullopt on failure

◆ tryParseMultiple()

static std::optional< MzPAFPeakAnnotations > tryParseMultiple ( const String input)
static

Try to parse multiple annotations (non-throwing)

Parameters
[in]inputThe mzPAF string to parse
Returns
The parsed annotations, or empty on failure