75 static constexpr Size SERIES = 4;
76 static constexpr Size PRECURSOR_BUCKETS = 3;
77 static constexpr Size FRAGMENT_CHARGES = 2;
78 static constexpr Size POSITION_BINS = 10;
79 static constexpr Size CLEAVAGE_SITES = 3;
80 static constexpr Size COMPLEMENT_STATES = 2;
81 static constexpr Size RANK_BINS = 7;
82 static constexpr Size ERROR_BINS = 3;
118 double mz(
Size index,
Size peak)
const {
return mz_[index][peak]; }
139 std::vector<std::vector<float>>
mz_;
153 double log_likelihood_ratio = 0.0;
154 double explained_presence = 0.0;
155 double top_predicted_observed = 0.0;
224 int precursor_charge,
227 std::vector<Ion>& ions)
const;
239 const std::vector<Residue::ResidueType>& ion_types,
240 const std::vector<UInt>& ion_ordinals,
241 const std::vector<Int>& ion_charges,
243 int precursor_charge,
246 std::vector<Ion>& ions)
const;
286 template <
typename IonOf,
typename ChargeOf>
288 const AASequence& peptide,
int precursor_charge,
double tolerance,
bool ppm, std::vector<Ion>& ions)
const;
295 std::vector<double>
smooth_(
const std::vector<double>& counts)
const;
312 double pseudo_count_ = 20.0;
313 bool finalized_ =
false;
Definition AASequence.h:96
Compact peak lists of the spectra of one run: per peak only its m/z and its intensity-rank bin.
Definition FragmentIonLikelihoodModel.h:92
Size totalPeaks() const
Number of peaks over all lists.
std::vector< std::vector< float > > mz_
m/z per peak, ascending, per spectrum
Definition FragmentIonLikelihoodModel.h:139
double mz(Size index, Size peak) const
m/z of peak peak of list index
Definition FragmentIonLikelihoodModel.h:118
Size rankBin(Size index, Size peak) const
Intensity-rank bin (see rankBin()) of peak peak of list index.
Definition FragmentIonLikelihoodModel.h:121
std::vector< std::vector< std::uint8_t > > rank_bins_
intensity-rank bin per peak, per spectrum
Definition FragmentIonLikelihoodModel.h:140
void assign(Size index, const MSSpectrum &spectrum)
Store the peaks of spectrum as list index, replacing what was there.
Size peaks(Size index) const
Number of peaks of list index.
Definition FragmentIonLikelihoodModel.h:115
void clear()
Remove all peak lists and release their memory.
Size size() const
Number of peak lists (spectra)
Definition FragmentIonLikelihoodModel.h:101
void reset(Size spectra)
Remove all peak lists and make room for spectra empty ones.
Int findNearest(Size index, double mz, double tolerance) const
The peak of list index nearest to mz, if it lies within [mz - tolerance, mz + tolerance].
Size memoryUsage() const
Bytes held by the peak lists (peak data, list headers)
Per-run likelihood model of fragment ion presence, intensity rank and mass error, learned from confid...
Definition FragmentIonLikelihoodModel.h:64
std::vector< double > signal_counts_
contexts_ * outcomes_ counts of confident ions
Definition FragmentIonLikelihoodModel.h:306
Size signalPsms() const
Number of confident PSMs added.
Definition FragmentIonLikelihoodModel.h:258
static Size rankBin(Size rank)
Rank bin (0 .. RANK_BINS - 1) of a matched peak with the given 1-based intensity rank.
Size absentOutcome() const
Outcome of an unmatched ion.
Definition FragmentIonLikelihoodModel.h:179
FragmentIonLikelihoodModel(ContextSet context_set=ContextSet::RICH, double pseudo_count=20.0)
Untrained model.
bool isTrained() const
Whether finalize() was called after the last observation.
Definition FragmentIonLikelihoodModel.h:255
void finalize()
Turn the counts into smoothed log-probabilities. Required before scoring; observations added later ne...
static Size seriesOf(Residue::ResidueType type)
Ion series (see SERIES) of an ion type (Residue::AIon ... Residue::Zp2Ion); SERIES for any other type...
std::vector< double > signal_logp_
smoothed ln P(outcome | signal, context)
Definition FragmentIonLikelihoodModel.h:308
Size complement_
complement states of the context set (1 for BASIC)
Definition FragmentIonLikelihoodModel.h:302
Size outcomes_
Definition FragmentIonLikelihoodModel.h:305
double pseudoCount() const
Pseudo-count of the back-off smoothing.
Definition FragmentIonLikelihoodModel.h:264
void requireTrained_() const
Throws unless finalize() was called after the last observation.
double presenceProbability(Size context) const
Probability that an ion of this context is present in the spectrum of its peptide.
void addObservations(const std::vector< Ion > &ions, bool noise)
Add the matched ions of one PSM to the signal (noise false) or noise counts.
Size level1Context_(Size context) const
Contexts of the coarser back-off levels: level 1 is the coarsest above the flat prior.
void matchIons(const PeakLists &peaks, Size index, const MSSpectrum &theoretical, const std::vector< Residue::ResidueType > &ion_types, const std::vector< UInt > &ion_ordinals, const std::vector< Int > &ion_charges, const AASequence &peptide, int precursor_charge, double tolerance, bool ppm, std::vector< Ion > &ions) const
matchIons() with the ions given as codes instead of names: per peak of theoretical its ion type,...
ContextSet contextSet() const
The context set of this model.
Definition FragmentIonLikelihoodModel.h:170
static bool parseIonSeries(const std::string &name, Size &series, Size &ordinal)
parseIonName() that returns the ion series (see SERIES) instead of the terminus, e....
Size noisePsms() const
Number of reversed PSMs added.
Definition FragmentIonLikelihoodModel.h:261
double logLikelihoodRatio(Size context, Size outcome) const
ln P(outcome | signal, context) - ln P(outcome | noise, context)
Size errors_
error bins of the context set (1 for BASIC)
Definition FragmentIonLikelihoodModel.h:303
static Size errorBin(double relative_error)
Error bin (0 .. ERROR_BINS - 1) of a match with the given |mass error| / tolerance (at most 1)
Size contexts_
Definition FragmentIonLikelihoodModel.h:304
static bool parseIonName(const std::string &name, bool &prefix, Size &ordinal)
Terminus and ordinal of an ion name as written by TheoreticalSpectrumGenerator, e....
ContextSet context_set_
Definition FragmentIonLikelihoodModel.h:300
UInt32 context
flat context index, below contexts()
Definition FragmentIonLikelihoodModel.h:146
Size sites_
cleavage-site classes of the context set (1 for BASIC)
Definition FragmentIonLikelihoodModel.h:301
void matchIons_(const PeakLists &peaks, Size index, const MSSpectrum &theoretical, IonOf &&ion_of, ChargeOf &&charge_of, const AASequence &peptide, int precursor_charge, double tolerance, bool ppm, std::vector< Ion > &ions) const
matchIons() for ion(i, series, ordinal) (false: not an ion of a series) and charge(i) of the peaks
Size outcomes() const
Number of outcomes, absence included.
Definition FragmentIonLikelihoodModel.h:176
Size contexts() const
Number of ion contexts.
Definition FragmentIonLikelihoodModel.h:173
std::vector< double > noise_logp_
smoothed ln P(outcome | noise, context)
Definition FragmentIonLikelihoodModel.h:309
ContextSet
Ion contexts and outcomes the model distinguishes.
Definition FragmentIonLikelihoodModel.h:68
std::vector< double > noise_counts_
contexts_ * outcomes_ counts of reversed ions
Definition FragmentIonLikelihoodModel.h:307
UInt32 outcome
outcome index, below outcomes(); absentOutcome() if unmatched
Definition FragmentIonLikelihoodModel.h:147
std::vector< double > smooth_(const std::vector< double > &counts) const
Smoothed log-probabilities of one count table, backing off over the context hierarchy.
void matchIons(const PeakLists &peaks, Size index, const MSSpectrum &theoretical, const AASequence &peptide, int precursor_charge, double tolerance, bool ppm, std::vector< Ion > &ions) const
Match the named ions of a theoretical spectrum against peak list index: one Ion per recognised ion.
Size level2Context_(Size context) const
Features score(const std::vector< Ion > &ions, Size top_k=6) const
Features of one PSM from its matched ions (see matchIons()); top_k bounds top_predicted_observed.
Features of one PSM.
Definition FragmentIonLikelihoodModel.h:152
One theoretical ion after matching.
Definition FragmentIonLikelihoodModel.h:145
The representation of a 1D spectrum.
Definition MSSpectrum.h:45
ResidueType
Definition Residue.h:153
int Int
Signed integer type.
Definition Types.h:72
uint32_t UInt32
Unsigned integer type (32bit)
Definition Types.h:33
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19