![]() |
OpenMS
|
Reading and writing the charge notation used in fragment ion names. More...
Functions | |
| std::string | chargeSuffix (int charge) |
| The charge notation to append to an ion name, e.g. "+" for 1, "--" for -2. | |
| int | chargeFromName (const std::string &ion_name) |
| The charge an ion name spells out, or 0 if it does not spell one. | |
| std::string | withCharge (const std::string &ion_name, int charge) |
The ion name to display for a peak annotated with ion_name and charge. | |
| UInt | ordinalFromName (const std::string &ion_name) |
| The fragment ordinal an ion name spells out ("y12++" -> 12), or 0 if it does not spell one. | |
Variables | |
| constexpr int | MAX_REPEATED_SIGNS = 8 |
| Largest charge magnitude still written as a run of signs. | |
Reading and writing the charge notation used in fragment ion names.
Producers disagree on whether PeptideHit::PeakAnnotation::annotation spells the charge out: TheoreticalSpectrumGenerator writes "y3+", TheoreticalSpectrumGeneratorXLMS writes "[alpha|ci$y3]" and leaves the charge to PeakAnnotation::charge, and mzPAF names use "^2". A consumer that wants to display a complete ion name therefore has to ask what a given name already says, rather than assume. These functions are that one place to ask.
|
inline |
The charge an ion name spells out, or 0 if it does not spell one.
Understands the three notations that occur in OpenMS: a trailing run of '+'/'-' signs ("y3++"), a trailing sign followed by the number ("y3+3"), and the mzPAF caret ("y3-H2O^2", which may be followed by mzPAF's mass delta or confidence field, e.g. "y3^2/3.2ppm"). Only the first line is inspected; further lines of a peak label are free text.
This is deliberately conservative: a name that does not clearly spell a charge returns 0 rather than guessing, so callers can tell "no charge in the name" from "charge 1".
| [in] | ion_name | The ion name to inspect; only its first line is read |
Referenced by Annotation1DPeakItem< DataPoint >::draw(), Annotation1DPeakItem< DataPoint >::toPeakAnnotation(), and withCharge().
|
inline |
The charge notation to append to an ion name, e.g. "+" for 1, "--" for -2.
Up to MAX_REPEATED_SIGNS the charge is written as a run of '+' (or '-' in negative mode), which is what TheoreticalSpectrumGenerator has always written and what TOPPView has always shown. Beyond that the sign is followed by the number ("+12"). That bounds the allocation: charge can come from a file, where an unbounded run of signs would try to allocate gigabytes for a large value. A charge of 0 (unknown) yields "".
| [in] | charge | The charge to spell out; may come from a file, so it is not assumed to be small |
References MAX_REPEATED_SIGNS.
Referenced by NuXLAnnotateAndLocate::annotateAndLocate_(), NuXLFragmentAnnotationHelper::fragmentAnnotationDetailsToPHFA(), and withCharge().
|
inline |
The fragment ordinal an ion name spells out ("y12++" -> 12), or 0 if it does not spell one.
The ordinal is the run of digits directly after the ion letter, so it stops at whatever follows – a neutral loss, a charge suffix, or an mzPAF field. Deriving it this way rather than by deleting the parts that are not the ordinal means a name the caller does not recognise yields 0 instead of a wrong number: "y3-H2O1+" has ordinal 3, not 31.
Returns 0 for names whose ordinal is not in that position, e.g. the cross-link names ("[alpha|ci$y3]++"). Callers must range-check the result against the peptide before indexing.
| [in] | ion_name | The ion name to inspect |
|
inline |
The ion name to display for a peak annotated with ion_name and charge.
Producers disagree about whether the name already spells the charge out, so a consumer that wants a complete name has to ask rather than assume: appending unconditionally is what labelled every singly charged fragment as doubly charged (issue #8766). Returns ion_name unchanged when it already spells a charge, or when the charge is unknown (0); otherwise appends the notation.
The charge goes at the end of the first line, because anything below that is free text rather than part of the ion name.
| [in] | ion_name | The ion name as the producer wrote it |
| [in] | charge | The charge recorded alongside it, 0 if unknown |
ion_name with the charge spelled out, or unchanged if it already spells one References chargeFromName(), and chargeSuffix().
Referenced by NuXLAnnotateAndLocate::annotateAndLocate_(), and OpenMS::createIonCentricFragmentAnnotationsForUnshiftedIons().
|
constexpr |
Largest charge magnitude still written as a run of signs.
Beyond this the charge is written as a sign followed by the number, which keeps names readable and bounds the allocation for a charge that came from a file.
Referenced by chargeSuffix().