OpenMS
Loading...
Searching...
No Matches
ProSEAlgorithm.h File Reference
#include <OpenMS/CONCEPT/ProgressLogger.h>
#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
#include <OpenMS/ANALYSIS/ID/FragmentIndex.h>
#include <OpenMS/ANALYSIS/ID/FragmentIonLikelihoodModel.h>
#include <OpenMS/ANALYSIS/ID/OpenSearchModificationAnalysis.h>
#include <OpenMS/CHEMISTRY/EnzymaticDigestion.h>
#include <OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h>
#include <OpenMS/FORMAT/FASTAFile.h>
#include <OpenMS/KERNEL/MSExperiment.h>
#include <OpenMS/METADATA/PeptideIdentificationList.h>
#include <algorithm>
#include <functional>
#include <iosfwd>
#include <limits>
#include <map>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

class  ProSEAlgorithm
 Fragment-index-based peptide database search algorithm (experimental). More...
 
struct  ProSEAlgorithm::RunStatistics
 Per-run identification statistics for the end-of-search report. More...
 
struct  ProSEAlgorithm::SharedSearchStats
 Configuration, database and fragment-index facts shared across all input files of one ProSE invocation. More...
 
struct  ProSEAlgorithm::PercolatorRescoring
 Outcome of the Percolator rescoring of one search run (see rescoreWithPercolator() and the parameter 'rescore'). More...
 
struct  ProSEAlgorithm::SearchResult
 Comprehensive search result including modification analysis. More...
 
struct  ProSEAlgorithm::MultiFileSearchResult
 Multi-file search result bundle. More...
 
struct  ProSEAlgorithm::MergedResult
 The pooled evaluation of a multi-file search (the ProSE tool's -out_merged). More...
 
struct  ProSEAlgorithm::SearchContext
 Prepared per-database state shared across multiple spectrum files. More...
 
struct  ProSEAlgorithm::AnnotatedHit_
 Slimmer structure as storing all scored candidates in PeptideHit objects takes too much space. More...
 
struct  ProSEAlgorithm::CandidatePoolStats_
 Running summary of the complete candidate pool of one spectrum. More...
 
struct  ProSEAlgorithm::DeisotopingSettings_
 MS2 deisotoping rule of preprocessSpectra_(). More...
 
struct  ProSEAlgorithm::DecoyStrategy_
 Resolved decoy handling for one concrete input database. More...
 
struct  ProSEAlgorithm::LocalFragmentEvidence_
 Local fragment evidence of one candidate (annotate:local_fragment_evidence). More...
 
struct  ProSEAlgorithm::CoIsolatedPSM_
 The PSM of a precursor co-isolated with the selected one (chimeric:enabled), until its residual spectrum is built. More...
 
struct  ProSEAlgorithm::CalibrationResult_
 Result of a calibration pass. More...
 
struct  ProSEAlgorithm::ProteinMapping_
 The protein occurrences of the sequences of a search's hits (peptide:protein_mapping = index). More...
 
struct  ProSEAlgorithm::TransferStratum_
 
struct  ProSEAlgorithm::SpectraCounts_
 

Namespaces

namespace  OpenMS
 Main OpenMS namespace.
 

Class Documentation

◆ OpenMS::ProSEAlgorithm::RunStatistics

struct OpenMS::ProSEAlgorithm::RunStatistics

Per-run identification statistics for the end-of-search report.

Populated by collectRunStatistics_() once a single spectrum file has been searched (post-FDR), plus a few fields captured at well-defined points during search() (target/decoy counts pre-FDR, achieved q-value, timing). All counts refer to one input file. Cross-file/shared facts (database, fragment index, configuration) live in SharedSearchStats instead.

Class Members
double achieved_psm_fdr = -1.0 max retained q-value after FDR (<0 = n/a)
map< Int, Size > charge_histogram precursor charge -> PSM count
Size charge_out_of_range_spectra = 0 MS2 spectra not searched: their charge is outside precursor:min/max_charge.
Size decoy_psms = 0 decoy PSMs in the final IDs (after FDR, if applied)
bool fdr_applied = false true if PSM-level FDR filtering ran
double frag_err_mad = 0.0
double frag_err_median = 0.0
double frag_err_recommended = 0.0
bool frag_tol_valid = false true if fragment-error estimate present

The same of the annotated b and y fragment peaks (without neutral losses) of these PSMs; within the searched fragment tolerance (unmatched peaks have no error)

double hyperscore_max = 0.0
double hyperscore_median = 0.0
double hyperscore_min = 0.0
string input_file spectrum file this run searched (basename or path)
Size matched_spectra = 0 spectra with >=1 retained PSM in the final IDs (after FDR, if applied)
map< Size, Size > missed_cleavage_histogram missed cleavages -> PSM count
Size ms2_spectra = 0 number of MS2 spectra in the input
double prec_err_mad = 0.0
double prec_err_median = 0.0
double prec_err_recommended = 0.0
bool prec_tol_valid = false true if precursor-error estimate present

Mass error estimate (ppm) of the top hits of the target PSMs (at least 10): the median of the signed errors (observed minus theoretical; of the precursor corrected by the hit's isotope error, in an open search of the PSMs without a delta mass, within 0.05 Da of zero, only), their median absolute deviation from it (unscaled), and the recommended symmetric tolerance ceil(|median| + 3 * 1.4826 * MAD)

Size profile_spectra = 0 MS2 spectra recorded as profile (not centroided) spectra.
bool score_stats_valid = false true if hyperscore_* below are meaningful
double seconds_calibration = 0.0 calibration pass wall time (0 if disabled)
double seconds_fdr = 0.0 FDR filtering wall time (0 if not applied)
double seconds_search = 0.0 scoring + post-processing wall time
Size target_psms = 0 target PSMs in the final IDs (after FDR, if applied)
Size unique_peptides = 0 distinct peptide sequences among top hits
Size unique_proteins = 0 distinct protein accessions among top hits

◆ OpenMS::ProSEAlgorithm::SharedSearchStats

struct OpenMS::ProSEAlgorithm::SharedSearchStats

Configuration, database and fragment-index facts shared across all input files of one ProSE invocation.

Computed once (the fragment index is built once and reused), so these costs/counts must NOT be summed per file. Populated by the multi-file searchWithModificationAnalysis() overloads.

Class Members
bool calibration_enabled = false
bool chunked = false
string database_file FASTA path (empty for in-memory db)
Size db_decoy_proteins = 0 decoy entries in the searched (augmented) db
Size db_target_proteins = 0 target entries in the searched (augmented) db
string decoy_mode "generated" | "external" | "none (target-only)"
string enzyme
vector< string > fixed_mods
double fragment_tol = 0.0
string fragment_tol_unit
Size indexed_fragments = 0 theoretical fragments in the index (summed over chunks)
Size indexed_peptides = 0 peptides in the fragment index (summed over chunks)
vector< string > ion_series
Int max_charge = 0
Int min_charge = 0
Size missed_cleavages = 0
bool open_search = false
bool peptide_mass_mode = false
double precursor_tol_lower = 0.0
string precursor_tol_unit
double precursor_tol_upper = 0.0
double protein_fdr_threshold = 0.0
double psm_fdr_threshold = 0.0
double seconds_index_build = 0.0 decoy generation + fragment index build wall time
double seconds_output = 0.0 of seconds_total, the wall time after the search of the files: the outputs (set by the caller)
double seconds_qpx_extended = 0.0 of seconds_output, ProSE's -qpx_extended work: the spectra and predictions of the PSMs (set by the caller)
double seconds_total = 0.0 whole-search wall time (set by the caller)
vector< string > variable_mods

◆ OpenMS::ProSEAlgorithm::PercolatorRescoring

struct OpenMS::ProSEAlgorithm::PercolatorRescoring

Outcome of the Percolator rescoring of one search run (see rescoreWithPercolator() and the parameter 'rescore').

With 'rescore' off nothing is attempted: applied is false and skipped_reason empty.

Class Members
bool applied = false True if the PSMs were rescored.
string skipped_reason Why the PSMs were not rescored, as a sentence to show to the user (empty if applied or not attempted)
string warning

A caveat of an applied rescoring, as a sentence to show to the user (empty if none): Percolator's sanity check replaced the learned model by the best single feature (Percolator::usedDefaultDirection())

◆ OpenMS::ProSEAlgorithm::SearchResult

struct OpenMS::ProSEAlgorithm::SearchResult

Comprehensive search result including modification analysis.

This structure contains all outputs from an open search including:

  • Standard protein and peptide identifications
  • Delta mass statistics table (histogram of mass shifts)
  • PTM statistics table (mapped modifications with residue analysis)
  • Per-run identification statistics for the end-of-search report
Class Members
ExitCodes exit_code = ExitCodes::EXECUTION_OK
PeptideIdentificationList inference_only_peptide_ids

The PSMs whose q-values pass FDR:protein_inference_PSM but not FDR:PSM (targets and decoys, with the q-value as main score): the protein inference and the picked-protein FDR use them with peptide_ids, but they are not reported (see applyCompleteSetProteinFDR()). The multi-file searches fill it with FDR:protein > 0 and an FDR:PSM filter below FDR:protein_inference_PSM, and mergeFileResults() moves it out; the single-file searchWithModificationAnalysis() overloads use it for their protein FDR and return it empty.

bool is_open_search = false
OpenSearchAnalysisResult modification_analysis
PeptideIdentificationList peptide_ids
PercolatorRescoring percolator Outcome of the Percolator rescoring of this run (parameter 'rescore')
PeptideIdentificationList pre_fdr_peptide_ids

the PSMs before rescoring and FDR:PSM; only filled with setKeepPreFdrPsms(true)

vector< ProteinIdentification > protein_ids
RunStatistics stats

◆ OpenMS::ProSEAlgorithm::MultiFileSearchResult

struct OpenMS::ProSEAlgorithm::MultiFileSearchResult

Multi-file search result bundle.

Returned by the file-list searchWithModificationAnalysis() overloads. Holds one SearchResult per input file (in per_file, in input order) and a single aggregate result whose peptide_ids are the concatenation of all per-file PSMs and whose modification_analysis is computed once on the pooled set of PSMs.

Special cases for aggregate:

  • When the input list contains exactly one file, aggregate is left almost-empty (only is_open_search and exit_code are set) — the single-file pooled aggregate would just duplicate per_file[0] and re-run modification analysis on the same PSMs. Callers should use per_file[0] for the result in this case.
  • When every per-file run failed, aggregate.exit_code is set to the first non-OK per-file exit code (so callers can inspect it without walking the per_file vector).
  • When the caller passed build_pooled_aggregate = false, the pooled PSM copy is not retained: aggregate is left almost-empty (only is_open_search and exit_code), exactly as in the single-file case. In OPEN search the pooling still happens internally because the aggregate modification analysis needs it, so aggregate.modification_analysis is populated as usual and only aggregate.protein_ids / aggregate.peptide_ids are released afterwards. In closed search nothing is pooled at all.
  • With 'rescore', a file that Percolator cannot rescore on its own (e.g. fewer than 100 PSMs) gets the scores of a model trained on the files it rescored on their own, or if there are none, all files are rescored together (see rescoreFilesTogether_()). Only if that fails, the runs report different search engines (Percolator / ProSE): the pooled copies of the runs then all get ProSE's engine, so that IDMergerAlgorithm merges them (see mergeFileResults() for the scores); the runs of per_file stay as they are.

The aggregate's protein_ids template is taken from the first successful per-file result (search parameters are identical across files by construction), with the primary MS run path overwritten to list every input file. Its PSMs carry the meta value 'id_merge_index', the input position of their file (see poolSearchedFiles_()).

Class Members
SearchResult aggregate
bool decoy_is_prefix = true Position of decoy_string (true = prefix, false = suffix).
string decoy_string

Effective decoy marker resolved from the shared database, for a caller-side merged-PSM protein-FDR step (e.g. the ProSE TOPP tool's -out_merged path). Empty when the search was target-only (decoys=ignore).

bool have_decoys = false True when the searched databases contained decoys (FDR possible).
vector< SearchResult > per_file
SharedSearchStats shared

Configuration / database / fragment-index facts shared across all input files (the index is built once and reused), for the end-of-search report.

◆ OpenMS::ProSEAlgorithm::MergedResult

struct OpenMS::ProSEAlgorithm::MergedResult

The pooled evaluation of a multi-file search (the ProSE tool's -out_merged).

Class Members
PeptideIdentificationList peptide_ids PSMs of all files; meta value 'id_merge_index' = input position of the file.
bool protein_fdr_applied = false picked-protein FDR applied and its filter at FDR:protein (and, with remove_decoys, the decoys removed)
vector< ProteinIdentification > protein_ids

one pooled run; empty if no file succeeded

◆ OpenMS::ProSEAlgorithm::SearchContext

struct OpenMS::ProSEAlgorithm::SearchContext

Prepared per-database state shared across multiple spectrum files.

Holds the (decoy-augmented) protein database and the built FragmentIndex so that searching N spectrum files against the same FASTA pays the index build cost only once. Construct via prepareContext() and pass to the context-taking search() overload.

Class Members
vector< FASTAEntry > db
bool decoy_is_prefix = true Position of decoy_string (true = prefix, false = suffix).
string decoy_string

Effective decoy marker carried by db (auto-detected for external decoys, or the configured prefix for internally generated ones). Empty when the search is target-only. Feeds PeptideIndexing and the protein-level FDR so they recognise the same decoys that were searched.

bool electron_ions = false

True when fragment_index also holds c and z+1 ions for electron-activated spectra (ions:by_activation); only those spectra are matched against them. See prepareContext(). search() does not add them to a context: for such spectra and a context without these ions, it builds a temporary index for the call.

FragmentIndex fragment_index
bool have_decoys = false

True when db contains decoy entries (generated or external), i.e. target-decoy FDR is possible.

bool release_fragment_index_after_scoring = false

When true, the context-taking search() overload will release fragment_index (via clear()) after scoreSpectraAgainstIndex_ returns, reclaiming its heap footprint before the PeptideIndexing Aho-Corasick pass — which is otherwise the RSS high-water mark on large databases. Set by single-use callers (e.g. the internal search(spectra, fasta_db, ...) wrapper that creates a throw-away ctx). Default false preserves the reuse contract for callers that built ctx via prepareContext() and want to run multiple search() calls against it.

◆ OpenMS::ProSEAlgorithm::DeisotopingSettings_

struct OpenMS::ProSEAlgorithm::DeisotopingSettings_

MS2 deisotoping rule of preprocessSpectra_().

Filled from the parameters fragment:deisotope_* by updateMembers_(), whose defaults are the Sage-like rule (min_peaks = 2, charge_cap_precursor: charges up to the precursor charge, at most 3, and sum_intensity). The member defaults are the behaviour before these parameters existed (envelopes of at least three peaks, charges 1-3 in every spectrum, the monoisotopic peak keeps its own intensity); the preprocessSpectra_() overload without settings uses them.

Class Members
bool charge_cap_precursor {false} fragment:deisotope_charge_cap = precursor
unsigned int min_peaks {3} fragment:deisotope_min_peaks
bool sum_intensity {false} fragment:deisotope_sum_intensity

◆ OpenMS::ProSEAlgorithm::DecoyStrategy_

struct OpenMS::ProSEAlgorithm::DecoyStrategy_

Resolved decoy handling for one concrete input database.

Produced by resolveDecoyStrategy_() and consumed by buildDecoyAugmentedDB_() and the downstream PeptideIndexing / FDR steps, so the same decoys that are searched are also the ones scored.

Class Members
string decoy_string effective marker for PeptideIndexing + protein FDR
bool generate {false} reverse target proteins to synthesise decoys
bool have_decoys {false} searched DB will contain decoys (FDR possible)
bool is_prefix {true} position of decoy_string
bool strip_existing {false} drop pre-existing decoy entries before searching
bool strip_is_prefix {true} position of strip_string
string strip_string marker of pre-existing decoys to strip

◆ OpenMS::ProSEAlgorithm::LocalFragmentEvidence_

struct OpenMS::ProSEAlgorithm::LocalFragmentEvidence_

Local fragment evidence of one candidate (annotate:local_fragment_evidence).

Class Members
double chance_match_surprise = 0.0
double mass_competition_evidence = 0.0

◆ OpenMS::ProSEAlgorithm::CoIsolatedPSM_

struct OpenMS::ProSEAlgorithm::CoIsolatedPSM_

The PSM of a precursor co-isolated with the selected one (chimeric:enabled), until its residual spectrum is built.

Class Members
Size parent = 0 index of its spectrum in the searched spectra
Precursor precursor the co-isolated precursor: that of the spectrum with its m/z and charge
vector< UInt32 > removed the peaks of the spectrum that its residual spectrum leaves out (ascending)

◆ OpenMS::ProSEAlgorithm::CalibrationResult_

struct OpenMS::ProSEAlgorithm::CalibrationResult_

Result of a calibration pass.

Holds the estimated precursor and fragment tolerances computed from confident PSMs during the calibration pass. When success is false, the tolerance values are undefined and should not be used.

Class Members
double cal_lower {0} calibrated lower magnitude (valid iff !extreme_bias && success)
double cal_upper {0} calibrated upper magnitude (valid iff !extreme_bias && success)
bool extreme_bias {false} |shift| >= spread — writeback skipped (test observability)
double fragment_shift {0} reserved for future fragment m/z shift correction
double fragment_tolerance {0} estimated fragment tolerance (same unit as configured)
double precursor_shift {0} signed median of precursor errors (calibration bias)
double precursor_spread {0} median(|e - shift|) + 3 * MAD(|e - shift|)
bool success {false} true if enough PSMs were found for reliable estimation

◆ OpenMS::ProSEAlgorithm::TransferStratum_

struct OpenMS::ProSEAlgorithm::TransferStratum_

Of a file of a multi-file search with 'rescore' that Percolator rescored on its own: what rescoreFilesTogether_() needs of its PSMs before the rescoring to train the model for the files it could not rescore on their own

Class Members
vector< Size > draw

per PSM of the file's SearchResult::pre_fdr_peptide_ids: its place in the reproducible random order in which the training draws the PSMs with hits (the training takes the first stratifiedQuotas_() of them); the largest Size for a PSM without hits

int max_charge = std::numeric_limits<int>::min()

the highest

int min_charge = std::numeric_limits<int>::max() the lowest precursor charge of their hits (charge features)
Size psms = 0 its PSMs with hits (the size of its stratum, stratifiedQuotas_())

◆ OpenMS::ProSEAlgorithm::SpectraCounts_

struct OpenMS::ProSEAlgorithm::SpectraCounts_

The MS2 spectra of a spectrum file, those recorded as profile spectra and those that are not searched because their precursor charge lies outside of precursor:min_charge..max_charge (FragmentIndex::precursorCharges())

Class Members
Size charge_out_of_range = 0
Size ms2 = 0
Size profile = 0