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

Recursive descent parser for ProForma v2 peptidoform notation. More...

#include <OpenMS/CHEMISTRY/ProFormaParser.h>

Collaboration diagram for ProFormaParser:
[legend]

Static Public Member Functions

static Peptidoform parse (const String &input)
 Parse a ProForma string into a Peptidoform AST.
 
static PeptidoformIon parseIon (const String &input)
 Parse a ProForma string into a PeptidoformIon AST.
 
static String toString (const Peptidoform &pf, ProFormaWriteMode mode=ProFormaWriteMode::LOSSLESS)
 Convert a Peptidoform AST back to ProForma string notation.
 
static String toString (const PeptidoformIon &pfi, ProFormaWriteMode mode=ProFormaWriteMode::LOSSLESS)
 Convert a PeptidoformIon AST back to ProForma string notation.
 
static void resolveModifications (Peptidoform &pf)
 Resolve all modifications in a Peptidoform using ModificationsDB.
 
static AASequence toAASequence (const Peptidoform &pf, AASequenceConversionPolicy policy=AASequenceConversionPolicy::FAIL_ON_LOSS)
 Convert a Peptidoform to an OpenMS AASequence.
 
static Peptidoform fromAASequence (const AASequence &seq)
 Create a Peptidoform from an OpenMS AASequence.
 
static bool isRepresentableAsAASequence (const Peptidoform &pf)
 Check if a Peptidoform can be fully represented as an AASequence.
 
static std::vector< ConversionIssuegetAASequenceConversionIssues (const Peptidoform &pf)
 Get a list of all issues that would arise during AASequence conversion.
 
static bool canCalculateMass (const Peptidoform &pf)
 Check if mass can be calculated for a Peptidoform.
 
static bool canCalculateMass (const PeptidoformIon &pfi)
 Check if mass can be calculated for a PeptidoformIon.
 
static std::vector< ConversionIssuegetMassCalculationIssues (const Peptidoform &pf)
 Get issues preventing mass calculation for a Peptidoform.
 
static std::vector< ConversionIssuegetMassCalculationIssues (const PeptidoformIon &pfi)
 Get issues preventing mass calculation for a PeptidoformIon.
 
static double getMonoWeight (const Peptidoform &pf)
 Calculate monoisotopic mass of a Peptidoform.
 
static double getMonoWeight (const PeptidoformIon &pfi)
 Calculate monoisotopic mass of a PeptidoformIon.
 
static double getMZ (const PeptidoformIon &pfi)
 Calculate m/z for a PeptidoformIon at its specified charge state.
 
static double getMZ (const Peptidoform &pf, int charge)
 Calculate m/z for a Peptidoform at a given charge state.
 
static std::optional< double > tryGetMonoWeight (const Peptidoform &pf)
 Try to calculate monoisotopic mass of a Peptidoform (non-throwing)
 
static std::optional< double > tryGetMonoWeight (const Peptidoform &pf, std::vector< ConversionIssue > &issues_out)
 Try to calculate monoisotopic mass with diagnostic information.
 
static std::optional< double > tryGetMonoWeight (const PeptidoformIon &pfi)
 Try to calculate monoisotopic mass of a PeptidoformIon (non-throwing)
 
static std::optional< double > tryGetMonoWeight (const PeptidoformIon &pfi, std::vector< ConversionIssue > &issues_out)
 Try to calculate monoisotopic mass of PeptidoformIon with diagnostics.
 
static std::optional< double > tryGetMZ (const Peptidoform &pf, int charge)
 Try to calculate m/z for a Peptidoform (non-throwing)
 
static std::optional< double > tryGetMZ (const Peptidoform &pf, int charge, std::vector< ConversionIssue > &issues_out)
 Try to calculate m/z for a Peptidoform with diagnostics.
 
static std::optional< double > tryGetMZ (const PeptidoformIon &pfi)
 Try to calculate m/z for a PeptidoformIon (non-throwing)
 
static std::optional< double > tryGetMZ (const PeptidoformIon &pfi, std::vector< ConversionIssue > &issues_out)
 Try to calculate m/z for a PeptidoformIon with diagnostics.
 
static bool canGenerateSpectrum (const Peptidoform &pf)
 Check if a theoretical spectrum can be generated for a Peptidoform.
 
static bool canGenerateSpectrum (const PeptidoformIon &pfi)
 Check if a theoretical spectrum can be generated for a PeptidoformIon.
 
static std::vector< ConversionIssuegetSpectrumGenerationIssues (const Peptidoform &pf)
 Get issues preventing spectrum generation for a Peptidoform.
 
static std::vector< ConversionIssuegetSpectrumGenerationIssues (const PeptidoformIon &pfi)
 Get issues preventing spectrum generation for a PeptidoformIon.
 
static MSSpectrum generateSpectrum (const Peptidoform &pf, int min_charge=1, int max_charge=1, const std::string &ion_types="by", bool add_losses=false, bool add_metainfo=true)
 Generate a theoretical MS/MS spectrum for a Peptidoform.
 
static MSSpectrum generateSpectrum (const PeptidoformIon &pfi, int min_charge=1, int max_charge=1, const std::string &ion_types="by", bool add_losses=false, bool add_metainfo=true)
 Generate a theoretical MS/MS spectrum for a PeptidoformIon.
 

Private Member Functions

 ProFormaParser (std::string_view input)
 Private constructor - use static methods.
 
PeptidoformIon parsePeptidoformIon_ ()
 Parse a complete PeptidoformIon (multiple chains + charge)
 
Peptidoform parsePeptidoform_ ()
 Parse a single Peptidoform (one chain)
 
Peptidoform parsePeptidoformWithCharge_ (bool is_chimeric_context)
 
std::vector< GlobalModEntryparseGlobalMods_ ()
 Parse global modifications: < ... >
 
GlobalModEntry parseGlobalModEntry_ ()
 Parse a single global modification entry.
 
IsotopeReplacement parseIsotopeReplacement_ ()
 Parse isotope replacement: <13C>, <15N>, <D>
 
GlobalModification parseGlobalModification_ ()
 Parse global modification with locations: <[mod]@locations>
 
std::vector< UnlocalisedModparseUnlocalisedMods_ ()
 Parse unlocalised modifications: [mod]?
 
std::vector< LabileModificationparseLabileModifications_ ()
 Parse labile modifications: {mod}.
 
std::vector< SequenceSectionparseSequence_ ()
 Parse the amino acid sequence with modifications.
 
SequenceElement parseSequenceElement_ ()
 Parse a single sequence element (amino acid + mods)
 
AmbiguousRegion parseAmbiguousRegion_ ()
 Parse an ambiguous region: (?XY)
 
ModifiedRange parseModifiedRange_ ()
 Parse a modified range: (XYZ)[mod].
 
std::vector< ModificationparseTerminalMods_ ()
 Parse terminal modifications: [mod1][mod2]...
 
std::vector< ModificationparseModificationList_ ()
 Parse a modification list: [mod1, mod2, ...].
 
Modification parseModification_ ()
 Parse a single modification (may have alternatives with |)
 
std::pair< ModificationTag, std::optional< Label > > parseModificationTagWithLabel_ ()
 Parse a single modification tag (no alternatives)
 
ModificationTag parseModificationTag_ ()
 Parse a modification tag.
 
NamedMod parseNamedMod_ ()
 Parse a named modification: Oxidation, U:Oxidation.
 
NamedMod parseNamedMod_ (char cv_hint)
 Parse a named modification with a known CV hint prefix.
 
CvAccession parseCvAccession_ ()
 Parse a CV accession: UNIMOD:35, MOD:00046.
 
MassDelta parseMassDelta_ ()
 Parse a mass delta: +15.9949, Obs:+79.978.
 
FormulaTag parseFormulaTag_ ()
 Parse a formula tag: Formula:C12H20O2.
 
GlycanComposition parseGlycanComposition_ ()
 Parse a glycan composition: Glycan:HexNAc1Hex2.
 
InfoTag parseInfoTag_ ()
 Parse an info tag: INFO:text.
 
PositionConstraint parsePositionConstraint_ ()
 Parse a position constraint: Position:MKC.
 
Label parseLabel_ ()
 Parse a label: #XL1, #BRANCH, #g1(0.90)
 
std::optional< ChargeStateparseChargeState_ ()
 Parse charge state: /2, /+2, /[Na:z+1].
 
std::vector< AdductIonparseAdductIons_ ()
 Parse adduct ions: [Na:z+1, H:z+1].
 
AdductIon parseAdductIon_ ()
 Parse a single adduct ion: Na:z+1.
 
ProFormaTokenizer::Token current_ ()
 Get the current token.
 
ProFormaTokenizer::Token peek_ ()
 Look at the next token without consuming.
 
ProFormaTokenizer::Token advance_ ()
 Consume and return the current token.
 
bool check_ (ProFormaTokenizer::TokenType type)
 Check if current token matches expected type.
 
bool match_ (ProFormaTokenizer::TokenType type)
 Check if current token matches expected type, consume if true.
 
ProFormaTokenizer::Token expect_ (ProFormaTokenizer::TokenType type, const char *expected_desc)
 Expect a specific token type, throw error if not found.
 
bool isAtEnd_ ()
 Check if at end of input.
 
void error_ (ProFormaErrorCode code, const char *message)
 Throw a parse error at the current position.
 
void errorAt_ (ProFormaErrorCode code, size_t pos, const char *message)
 Throw a parse error at a specific position.
 
std::optional< CvDatabaseparseCvDatabasePrefix_ (const std::string_view &id)
 Parse a CV database prefix from identifier.
 
bool looksLikeModificationTagContent_ ()
 Check if the current position could start a modification tag content.
 
bool hasNTerminalModPattern_ ()
 Check if current position has N-terminal modification pattern ([mod]-)
 
ProFormaTokenizer createLookahead_ () const
 Create a lookahead tokenizer positioned at the current logical position.
 

Static Private Member Functions

static bool isAminoAcid_ (char c)
 Check if identifier is a valid amino acid.
 

Private Attributes

ProFormaTokenizer tokenizer_
 The tokenizer for lexical analysis.
 
std::string input_
 The original input string (for error messages)
 
ProFormaTokenizer::Token current_token_
 Current token (cached)
 
bool has_current_ = false
 Whether we have a cached current token.
 

Detailed Description

Recursive descent parser for ProForma v2 peptidoform notation.

This class parses ProForma strings into an Abstract Syntax Tree (AST) representation. The AST structures are defined in ProFormaData.h.

The parser implements the ProForma v2 grammar:

  • peptidoform_ion -> peptidoform [charge_state | adduct_ion]
  • peptidoform -> [global_mods] [n_term_mod "-"] sequence ["-" c_term_mod]
  • sequence -> {amino_acid [modification_list]}+
  • modification_list -> "[" modification {"," modification}* "]"
  • modification -> named_mod | mass_delta | formula | cv_accession | glycan | info_tag
  • global_mods -> "<" global_mod {"," global_mod}* ">"
  • cross_link_label -> "#" identifier ["(" occurrence ")"]

Usage example:

String input = "EM[UNIMOD:35]K";
// pf now contains the parsed AST
static Peptidoform parse(const String &input)
Parse a ProForma string into a Peptidoform AST.
A more convenient string class.
Definition String.h:34
A single peptidoform (one peptide chain)
Definition ProFormaData.h:509
See also
ProFormaData.h for AST structure definitions
ProFormaTokenizer for lexical analysis
ProFormaError for error handling

Constructor & Destructor Documentation

◆ ProFormaParser()

ProFormaParser ( std::string_view  input)
explicitprivate

Private constructor - use static methods.

Member Function Documentation

◆ advance_()

ProFormaTokenizer::Token advance_ ( )
private

Consume and return the current token.

◆ canCalculateMass() [1/2]

static bool canCalculateMass ( const Peptidoform pf)
static

Check if mass can be calculated for a Peptidoform.

Returns true if all components have known masses:

  • All amino acids are standard residues
  • All modifications are either resolved or have explicit mass deltas
  • No ambiguous regions with different possible amino acids
Parameters
[in]pfThe Peptidoform to check (modifications will be resolved if needed)
Returns
True if mass calculation is possible

◆ canCalculateMass() [2/2]

static bool canCalculateMass ( const PeptidoformIon pfi)
static

Check if mass can be calculated for a PeptidoformIon.

Returns true if mass can be calculated for all chains. Cross-links are handled correctly (cross-linker mass counted once).

Parameters
[in]pfiThe PeptidoformIon to check
Returns
True if mass calculation is possible

◆ canGenerateSpectrum() [1/2]

static bool canGenerateSpectrum ( const Peptidoform pf)
static

Check if a theoretical spectrum can be generated for a Peptidoform.

Returns true if the Peptidoform can be converted to AASequence and fragmented. Use getSpectrumGenerationIssues() to get detailed diagnostics.

Parameters
[in]pfThe Peptidoform to check
Returns
True if spectrum generation is possible

◆ canGenerateSpectrum() [2/2]

static bool canGenerateSpectrum ( const PeptidoformIon pfi)
static

Check if a theoretical spectrum can be generated for a PeptidoformIon.

Returns true if the PeptidoformIon can be fragmented. For cross-linked peptides, both chains must be convertible. Chimeric spectra are not supported.

Parameters
[in]pfiThe PeptidoformIon to check
Returns
True if spectrum generation is possible

◆ check_()

bool check_ ( ProFormaTokenizer::TokenType  type)
private

Check if current token matches expected type.

◆ createLookahead_()

ProFormaTokenizer createLookahead_ ( ) const
private

Create a lookahead tokenizer positioned at the current logical position.

◆ current_()

ProFormaTokenizer::Token current_ ( )
private

Get the current token.

◆ error_()

void error_ ( ProFormaErrorCode  code,
const char *  message 
)
private

Throw a parse error at the current position.

◆ errorAt_()

void errorAt_ ( ProFormaErrorCode  code,
size_t  pos,
const char *  message 
)
private

Throw a parse error at a specific position.

◆ expect_()

ProFormaTokenizer::Token expect_ ( ProFormaTokenizer::TokenType  type,
const char *  expected_desc 
)
private

Expect a specific token type, throw error if not found.

◆ fromAASequence()

static Peptidoform fromAASequence ( const AASequence seq)
static

Create a Peptidoform from an OpenMS AASequence.

Converts an AASequence with modifications to ProForma notation. Uses CV accessions (UNIMOD) where available, otherwise named modifications.

Parameters
[in]seqThe AASequence to convert
Returns
The equivalent Peptidoform AST

◆ generateSpectrum() [1/2]

static MSSpectrum generateSpectrum ( const Peptidoform pf,
int  min_charge = 1,
int  max_charge = 1,
const std::string &  ion_types = "by",
bool  add_losses = false,
bool  add_metainfo = true 
)
static

Generate a theoretical MS/MS spectrum for a Peptidoform.

Converts the Peptidoform to AASequence and uses TheoreticalSpectrumGenerator to generate fragment ions based on the specified ion types.

Parameters
[in]pfThe Peptidoform to fragment
[in]min_chargeMinimum fragment ion charge state
[in]max_chargeMaximum fragment ion charge state
[in]ion_typesString specifying which ion types to generate: 'a','b','c','x','y','z' for ion series, 'M' for precursor peaks, 'I' for immonium ions. Example: "by" for b/y ions, "byM" for b/y + precursor
[in]add_lossesIf true, include neutral loss peaks (H2O, NH3)
[in]add_metainfoIf true, include ion annotations in spectrum
Returns
MSSpectrum with theoretical peaks
Exceptions
Exception::ConversionErrorif spectrum generation fails

◆ generateSpectrum() [2/2]

static MSSpectrum generateSpectrum ( const PeptidoformIon pfi,
int  min_charge = 1,
int  max_charge = 1,
const std::string &  ion_types = "by",
bool  add_losses = false,
bool  add_metainfo = true 
)
static

Generate a theoretical MS/MS spectrum for a PeptidoformIon.

For single-chain peptides, uses TheoreticalSpectrumGenerator. For cross-linked peptides (// separator), uses TheoreticalSpectrumGeneratorXLMS. Chimeric spectra are not supported.

Parameters
[in]pfiThe PeptidoformIon to fragment
[in]min_chargeMinimum fragment ion charge state
[in]max_chargeMaximum fragment ion charge state
[in]ion_typesString specifying which ion types to generate: 'a','b','c','x','y','z' for ion series, 'M' for precursor peaks, 'I' for immonium ions. Example: "by" for b/y ions, "abyM" for a/b/y + precursor
[in]add_lossesIf true, include neutral loss peaks
[in]add_metainfoIf true, include ion annotations
Returns
MSSpectrum with theoretical peaks
Exceptions
Exception::ConversionErrorif spectrum generation fails

◆ getAASequenceConversionIssues()

static std::vector< ConversionIssue > getAASequenceConversionIssues ( const Peptidoform pf)
static

Get a list of all issues that would arise during AASequence conversion.

Returns detailed information about every aspect of the Peptidoform that cannot be represented in an AASequence.

Parameters
[in]pfThe Peptidoform to analyze
Returns
Vector of conversion issues (empty if fully convertible)

◆ getMassCalculationIssues() [1/2]

static std::vector< ConversionIssue > getMassCalculationIssues ( const Peptidoform pf)
static

Get issues preventing mass calculation for a Peptidoform.

Returns detailed information about components that prevent mass calculation.

Parameters
[in]pfThe Peptidoform to analyze
Returns
Vector of issues (empty if mass can be calculated)

◆ getMassCalculationIssues() [2/2]

static std::vector< ConversionIssue > getMassCalculationIssues ( const PeptidoformIon pfi)
static

Get issues preventing mass calculation for a PeptidoformIon.

Returns detailed information about components that prevent mass calculation across all chains.

Parameters
[in]pfiThe PeptidoformIon to analyze
Returns
Vector of issues (empty if mass can be calculated)

◆ getMonoWeight() [1/2]

static double getMonoWeight ( const Peptidoform pf)
static

Calculate monoisotopic mass of a Peptidoform.

Calculates the neutral monoisotopic mass including:

  • Amino acid residue masses
  • Terminal H2O mass
  • All modification mass deltas
  • Unlocalised and labile modifications (included in total)
  • Global modifications applied to matching residues
Parameters
[in]pfThe Peptidoform to calculate mass for
Returns
Monoisotopic mass in Daltons
Exceptions
Exception::InvalidValueif mass cannot be calculated (use canCalculateMass() first)
Note
Modifications are resolved automatically if not already resolved

◆ getMonoWeight() [2/2]

static double getMonoWeight ( const PeptidoformIon pfi)
static

Calculate monoisotopic mass of a PeptidoformIon.

For cross-linked peptides, calculates the combined mass of all chains. Cross-linker masses are counted only once per cross-link group.

Parameters
[in]pfiThe PeptidoformIon to calculate mass for
Returns
Monoisotopic mass in Daltons
Exceptions
Exception::InvalidValueif mass cannot be calculated
Exception::InvalidValueif pfi is chimeric (use getMonoWeight on individual chains)

◆ getMZ() [1/2]

static double getMZ ( const Peptidoform pf,
int  charge 
)
static

Calculate m/z for a Peptidoform at a given charge state.

Parameters
[in]pfThe Peptidoform to calculate m/z for
[in]chargeThe charge state (must be non-zero)
Returns
m/z value
Exceptions
Exception::InvalidValueif mass cannot be calculated or charge is zero

◆ getMZ() [2/2]

static double getMZ ( const PeptidoformIon pfi)
static

Calculate m/z for a PeptidoformIon at its specified charge state.

Uses the charge state from the PeptidoformIon if present.

Parameters
[in]pfiThe PeptidoformIon with charge state
Returns
m/z value
Exceptions
Exception::InvalidValueif mass cannot be calculated or no charge state

◆ getSpectrumGenerationIssues() [1/2]

static std::vector< ConversionIssue > getSpectrumGenerationIssues ( const Peptidoform pf)
static

Get issues preventing spectrum generation for a Peptidoform.

Parameters
[in]pfThe Peptidoform to analyze
Returns
Vector of issues (empty if spectrum can be generated)

◆ getSpectrumGenerationIssues() [2/2]

static std::vector< ConversionIssue > getSpectrumGenerationIssues ( const PeptidoformIon pfi)
static

Get issues preventing spectrum generation for a PeptidoformIon.

Parameters
[in]pfiThe PeptidoformIon to analyze
Returns
Vector of issues (empty if spectrum can be generated)

◆ hasNTerminalModPattern_()

bool hasNTerminalModPattern_ ( )
private

Check if current position has N-terminal modification pattern ([mod]-)

◆ isAminoAcid_()

static bool isAminoAcid_ ( char  c)
staticprivate

Check if identifier is a valid amino acid.

◆ isAtEnd_()

bool isAtEnd_ ( )
private

Check if at end of input.

◆ isRepresentableAsAASequence()

static bool isRepresentableAsAASequence ( const Peptidoform pf)
static

Check if a Peptidoform can be fully represented as an AASequence.

Returns true if all modifications can be resolved and there are no unsupported features (ambiguous regions, cross-links, etc.)

Parameters
[in]pfThe Peptidoform to check
Returns
True if conversion is possible without issues

◆ looksLikeModificationTagContent_()

bool looksLikeModificationTagContent_ ( )
private

Check if the current position could start a modification tag content.

◆ match_()

bool match_ ( ProFormaTokenizer::TokenType  type)
private

Check if current token matches expected type, consume if true.

◆ parse()

static Peptidoform parse ( const String input)
static

Parse a ProForma string into a Peptidoform AST.

This is the main entry point for parsing simple peptidoforms without charge state information.

Parameters
[in]inputThe ProForma string to parse
Returns
The parsed Peptidoform AST
Exceptions
ProFormaParseErrorif the input is invalid
Note
For peptidoforms with charge state (e.g., "PEPTIDE/2"), use parseIon()

◆ parseAdductIon_()

AdductIon parseAdductIon_ ( )
private

Parse a single adduct ion: Na:z+1.

◆ parseAdductIons_()

std::vector< AdductIon > parseAdductIons_ ( )
private

Parse adduct ions: [Na:z+1, H:z+1].

◆ parseAmbiguousRegion_()

AmbiguousRegion parseAmbiguousRegion_ ( )
private

Parse an ambiguous region: (?XY)

◆ parseChargeState_()

std::optional< ChargeState > parseChargeState_ ( )
private

Parse charge state: /2, /+2, /[Na:z+1].

◆ parseCvAccession_()

CvAccession parseCvAccession_ ( )
private

Parse a CV accession: UNIMOD:35, MOD:00046.

◆ parseCvDatabasePrefix_()

std::optional< CvDatabase > parseCvDatabasePrefix_ ( const std::string_view &  id)
private

Parse a CV database prefix from identifier.

◆ parseFormulaTag_()

FormulaTag parseFormulaTag_ ( )
private

Parse a formula tag: Formula:C12H20O2.

◆ parseGlobalModEntry_()

GlobalModEntry parseGlobalModEntry_ ( )
private

Parse a single global modification entry.

◆ parseGlobalModification_()

GlobalModification parseGlobalModification_ ( )
private

Parse global modification with locations: <[mod]@locations>

◆ parseGlobalMods_()

std::vector< GlobalModEntry > parseGlobalMods_ ( )
private

Parse global modifications: < ... >

◆ parseGlycanComposition_()

GlycanComposition parseGlycanComposition_ ( )
private

Parse a glycan composition: Glycan:HexNAc1Hex2.

◆ parseInfoTag_()

InfoTag parseInfoTag_ ( )
private

Parse an info tag: INFO:text.

◆ parseIon()

static PeptidoformIon parseIon ( const String input)
static

Parse a ProForma string into a PeptidoformIon AST.

This entry point handles the full ProForma notation including:

  • Multiple chains (separated by //)
  • Charge state specification (/2, /+2, /-1)
  • Adduct ion specification (/[Na:z+1,H:z+1])
Parameters
[in]inputThe ProForma string to parse
Returns
The parsed PeptidoformIon AST
Exceptions
ProFormaParseErrorif the input is invalid

◆ parseIsotopeReplacement_()

IsotopeReplacement parseIsotopeReplacement_ ( )
private

Parse isotope replacement: <13C>, <15N>, <D>

◆ parseLabel_()

Label parseLabel_ ( )
private

Parse a label: #XL1, #BRANCH, #g1(0.90)

◆ parseLabileModifications_()

std::vector< LabileModification > parseLabileModifications_ ( )
private

Parse labile modifications: {mod}.

◆ parseMassDelta_()

MassDelta parseMassDelta_ ( )
private

Parse a mass delta: +15.9949, Obs:+79.978.

◆ parseModification_()

Modification parseModification_ ( )
private

Parse a single modification (may have alternatives with |)

◆ parseModificationList_()

std::vector< Modification > parseModificationList_ ( )
private

Parse a modification list: [mod1, mod2, ...].

◆ parseModificationTag_()

ModificationTag parseModificationTag_ ( )
private

Parse a modification tag.

◆ parseModificationTagWithLabel_()

std::pair< ModificationTag, std::optional< Label > > parseModificationTagWithLabel_ ( )
private

Parse a single modification tag (no alternatives)

◆ parseModifiedRange_()

ModifiedRange parseModifiedRange_ ( )
private

Parse a modified range: (XYZ)[mod].

◆ parseNamedMod_() [1/2]

NamedMod parseNamedMod_ ( )
private

Parse a named modification: Oxidation, U:Oxidation.

◆ parseNamedMod_() [2/2]

NamedMod parseNamedMod_ ( char  cv_hint)
private

Parse a named modification with a known CV hint prefix.

◆ parsePeptidoform_()

Peptidoform parsePeptidoform_ ( )
private

Parse a single Peptidoform (one chain)

◆ parsePeptidoformIon_()

PeptidoformIon parsePeptidoformIon_ ( )
private

Parse a complete PeptidoformIon (multiple chains + charge)

◆ parsePeptidoformWithCharge_()

Peptidoform parsePeptidoformWithCharge_ ( bool  is_chimeric_context)
private

Parse a Peptidoform with optional per-chain charge (for chimeric spectra)

Parameters
[in]is_chimeric_contextIf true, parse trailing charge as per-chain charge

◆ parsePositionConstraint_()

PositionConstraint parsePositionConstraint_ ( )
private

Parse a position constraint: Position:MKC.

◆ parseSequence_()

std::vector< SequenceSection > parseSequence_ ( )
private

Parse the amino acid sequence with modifications.

◆ parseSequenceElement_()

SequenceElement parseSequenceElement_ ( )
private

Parse a single sequence element (amino acid + mods)

◆ parseTerminalMods_()

std::vector< Modification > parseTerminalMods_ ( )
private

Parse terminal modifications: [mod1][mod2]...

◆ parseUnlocalisedMods_()

std::vector< UnlocalisedMod > parseUnlocalisedMods_ ( )
private

Parse unlocalised modifications: [mod]?

◆ peek_()

ProFormaTokenizer::Token peek_ ( )
private

Look at the next token without consuming.

◆ resolveModifications()

static void resolveModifications ( Peptidoform pf)
static

Resolve all modifications in a Peptidoform using ModificationsDB.

Looks up each modification tag (CV accession, named mod, mass delta) in ModificationsDB and stores the resolved ResidueModification pointer.

Parameters
[in,out]pfThe Peptidoform to resolve (modified in place)
Note
Modifications that cannot be resolved will have resolved_mod = nullptr

◆ toAASequence()

static AASequence toAASequence ( const Peptidoform pf,
AASequenceConversionPolicy  policy = AASequenceConversionPolicy::FAIL_ON_LOSS 
)
static

Convert a Peptidoform to an OpenMS AASequence.

Parameters
[in]pfThe Peptidoform to convert
[in]policyHow to handle unconvertible modifications
Returns
The equivalent AASequence
Exceptions
Exception::ConversionErrorif STRICT policy and conversion not possible
Note
Call resolveModifications() first, or this will resolve automatically

◆ toString() [1/2]

static String toString ( const Peptidoform pf,
ProFormaWriteMode  mode = ProFormaWriteMode::LOSSLESS 
)
static

Convert a Peptidoform AST back to ProForma string notation.

Parameters
[in]pfThe Peptidoform to convert
[in]modeWrite mode: LOSSLESS preserves original formatting, CANONICAL produces normalized output
Returns
The ProForma string representation

◆ toString() [2/2]

static String toString ( const PeptidoformIon pfi,
ProFormaWriteMode  mode = ProFormaWriteMode::LOSSLESS 
)
static

Convert a PeptidoformIon AST back to ProForma string notation.

Parameters
[in]pfiThe PeptidoformIon to convert
[in]modeWrite mode: LOSSLESS preserves original formatting, CANONICAL produces normalized output
Returns
The ProForma string representation

◆ tryGetMonoWeight() [1/4]

static std::optional< double > tryGetMonoWeight ( const Peptidoform pf)
static

Try to calculate monoisotopic mass of a Peptidoform (non-throwing)

Single-pass calculation that resolves modifications and calculates mass. More efficient than calling canCalculateMass() followed by getMonoWeight().

Parameters
[in]pfThe Peptidoform to calculate mass for
Returns
Monoisotopic mass in Daltons, or std::nullopt if calculation not possible

◆ tryGetMonoWeight() [2/4]

static std::optional< double > tryGetMonoWeight ( const Peptidoform pf,
std::vector< ConversionIssue > &  issues_out 
)
static

Try to calculate monoisotopic mass with diagnostic information.

Single-pass calculation that also collects any issues preventing calculation.

Parameters
[in]pfThe Peptidoform to calculate mass for
[out]issues_outVector to receive any issues (cleared first)
Returns
Monoisotopic mass in Daltons, or std::nullopt if calculation not possible

◆ tryGetMonoWeight() [3/4]

static std::optional< double > tryGetMonoWeight ( const PeptidoformIon pfi)
static

Try to calculate monoisotopic mass of a PeptidoformIon (non-throwing)

Parameters
[in]pfiThe PeptidoformIon to calculate mass for
Returns
Monoisotopic mass in Daltons, or std::nullopt if calculation not possible
Note
Returns std::nullopt for chimeric spectra (calculate per-chain instead)

◆ tryGetMonoWeight() [4/4]

static std::optional< double > tryGetMonoWeight ( const PeptidoformIon pfi,
std::vector< ConversionIssue > &  issues_out 
)
static

Try to calculate monoisotopic mass of PeptidoformIon with diagnostics.

Parameters
[in]pfiThe PeptidoformIon to calculate mass for
[out]issues_outVector to receive any issues (cleared first)
Returns
Monoisotopic mass in Daltons, or std::nullopt if calculation not possible

◆ tryGetMZ() [1/4]

static std::optional< double > tryGetMZ ( const Peptidoform pf,
int  charge 
)
static

Try to calculate m/z for a Peptidoform (non-throwing)

Parameters
[in]pfThe Peptidoform to calculate m/z for
[in]chargeThe charge state (must be non-zero)
Returns
m/z value, or std::nullopt if calculation not possible or charge is zero

◆ tryGetMZ() [2/4]

static std::optional< double > tryGetMZ ( const Peptidoform pf,
int  charge,
std::vector< ConversionIssue > &  issues_out 
)
static

Try to calculate m/z for a Peptidoform with diagnostics.

Parameters
[in]pfThe Peptidoform to calculate m/z for
[in]chargeThe charge state (must be non-zero)
[out]issues_outVector to receive any issues (cleared first)
Returns
m/z value, or std::nullopt if calculation not possible or charge is zero

◆ tryGetMZ() [3/4]

static std::optional< double > tryGetMZ ( const PeptidoformIon pfi)
static

Try to calculate m/z for a PeptidoformIon (non-throwing)

Parameters
[in]pfiThe PeptidoformIon with charge state
Returns
m/z value, or std::nullopt if calculation not possible or no charge

◆ tryGetMZ() [4/4]

static std::optional< double > tryGetMZ ( const PeptidoformIon pfi,
std::vector< ConversionIssue > &  issues_out 
)
static

Try to calculate m/z for a PeptidoformIon with diagnostics.

Parameters
[in]pfiThe PeptidoformIon with charge state
[out]issues_outVector to receive any issues (cleared first)
Returns
m/z value, or std::nullopt if calculation not possible or no charge

Member Data Documentation

◆ current_token_

ProFormaTokenizer::Token current_token_
private

Current token (cached)

◆ has_current_

bool has_current_ = false
private

Whether we have a cached current token.

◆ input_

std::string input_
private

The original input string (for error messages)

◆ tokenizer_

ProFormaTokenizer tokenizer_
private

The tokenizer for lexical analysis.