OpenMS
Loading...
Searching...
No Matches
ProSEAlgorithm.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: $
6// $Authors: Raphael Förster $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
22
23#include <algorithm> // std::min (used by inline computeModMatchTolerance_)
24#include <functional> // std::hash (ProteinMapping_)
25#include <iosfwd> // std::ostream (renderRunSummary / renderModificationSummary)
26#include <map>
27#include <string> // std::string (renderRunSummaryJson return / manifest)
28#include <string_view>
29#include <unordered_map>
30#include <unordered_set>
31#include <utility> // std::pair (renderRunSummaryJson manifest)
32#include <vector>
33
34namespace OpenMS
35{
36
37class TheoreticalSpectrumGenerator;
38
53class OPENMS_DLLAPI ProSEAlgorithm :
55 public ProgressLogger
56{
57 public:
59
61 enum class ExitCodes
62 {
63 EXECUTION_OK,
64 INPUT_FILE_EMPTY,
65 UNEXPECTED_RESULT,
66 UNKNOWN_ERROR,
67 ILLEGAL_PARAMETERS
68 };
69
80 {
81 std::string input_file;
82 Size ms2_spectra = 0;
83 Size matched_spectra = 0;
84 Size target_psms = 0;
85 Size decoy_psms = 0;
86 bool fdr_applied = false;
87 double achieved_psm_fdr = -1.0;
88 Size unique_peptides = 0;
89 Size unique_proteins = 0;
90 std::map<Int, Size> charge_histogram;
91 std::map<Size, Size> missed_cleavage_histogram;
92 bool score_stats_valid = false;
93 double hyperscore_min = 0.0;
94 double hyperscore_median = 0.0;
95 double hyperscore_max = 0.0;
96 bool prec_tol_valid = false;
97 double prec_err_median = 0.0, prec_err_mad = 0.0, prec_err_recommended = 0.0;
98 bool frag_tol_valid = false;
99 double frag_err_median = 0.0, frag_err_mad = 0.0, frag_err_recommended = 0.0;
100 double seconds_search = 0.0;
101 double seconds_calibration = 0.0;
102 double seconds_fdr = 0.0;
103 };
104
114 {
115 std::string database_file;
116 std::string enzyme;
117 double precursor_tol_lower = 0.0, precursor_tol_upper = 0.0;
119 double fragment_tol = 0.0;
120 std::string fragment_tol_unit;
121 Int min_charge = 0, max_charge = 0;
122 Size missed_cleavages = 0;
123 std::vector<std::string> fixed_mods, variable_mods, ion_series;
124 bool open_search = false;
125 bool calibration_enabled = false;
126 bool snes_mode = false;
127 bool chunked = false;
128 std::string decoy_mode;
129 double psm_fdr_threshold = 0.0, protein_fdr_threshold = 0.0;
130 Size db_target_proteins = 0;
131 Size db_decoy_proteins = 0;
132 Size indexed_peptides = 0;
133 Size indexed_fragments = 0;
134 double seconds_index_build = 0.0;
135 double seconds_total = 0.0;
136 };
137
148 {
149 ExitCodes exit_code = ExitCodes::EXECUTION_OK;
150 std::vector<ProteinIdentification> protein_ids;
153 bool is_open_search = false;
155 };
156
190 {
191 std::vector<SearchResult> per_file;
193
197 std::string decoy_string;
199 bool decoy_is_prefix = true;
201 bool have_decoys = false;
202
206 };
207
217 {
218 std::vector<FASTAFile::FASTAEntry> db;
220
230 bool release_fragment_index_after_scoring = false;
231
236 std::string decoy_string;
238 bool decoy_is_prefix = true;
241 bool have_decoys = false;
246 bool electron_ions = false;
247 };
248
270 ExitCodes search(const std::string& in_spectra,
271 const std::string& in_db,
272 std::vector<ProteinIdentification>& prot_ids,
273 PeptideIdentificationList& pep_ids) const;
274
299 static void applyCompleteSetProteinFDR(std::vector<ProteinIdentification>& protein_ids,
300 PeptideIdentificationList& peptide_ids,
301 const std::string& decoy_string,
302 bool decoy_is_prefix,
303 double protein_fdr);
304
317
363 SearchResult searchWithModificationAnalysis(const std::string& in_spectra,
364 const std::string& in_db,
365 const std::string& output_base_name = "") const;
366
385 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
386 std::vector<ProteinIdentification>& prot_ids,
387 PeptideIdentificationList& pep_ids) const;
388
409 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db) const;
410
424 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db, bool electron_ions) const;
425
447 SearchContext& ctx,
448 std::vector<ProteinIdentification>& prot_ids,
449 PeptideIdentificationList& pep_ids) const;
450
462 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
463 const std::string& output_base_name = "") const;
464
502 const std::vector<std::string>& in_spectra_files,
503 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
504 const std::vector<std::string>& output_base_names = {},
505 const std::string& aggregate_base_name = "",
506 bool build_pooled_aggregate = true) const;
507
522 const std::vector<std::string>& in_spectra_files,
523 const std::string& in_db,
524 const std::vector<std::string>& output_base_names = {},
525 const std::string& aggregate_base_name = "",
526 bool build_pooled_aggregate = true) const;
527
528 protected:
529 void updateMembers_() override;
530
533 {
535 /*
536 std::string_view sequence;
537 SignedSize peptide_mod_index; ///< enumeration index of the non-RNA peptide modification
538 */
539 // Layout: doubles first, then floats, then int, then uint16_t — minimizes padding (40 bytes excluding AASequence)
540 double score = 0;
541 double delta_mass = 0.0;
542 float prefix_fraction = 0;
543 float suffix_fraction = 0;
544 float mean_error = 0.0f;
545 int isotope_error = 0;
546 uint16_t applied_charge = 0;
547 uint16_t matched_prefix_ions = 0;
548 uint16_t matched_suffix_ions = 0;
549 UInt32 index_peptide = 0;
550
551 static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
552 {
553 if (a.score != b.score) return a.score > b.score;
554 return a.sequence < b.sequence;
555 }
556 };
557
578 {
579 double sum = 0.0;
580 double sumsq = 0.0;
581 double best = 0.0;
582 double second_best = 0.0;
583 Size count = 0;
586 std::unordered_set<std::string> seen_candidates;
587
589 void add(double score)
590 {
591 if (score > best) { second_best = best; best = score; }
592 else if (score > second_best) { second_best = score; }
593 sum += score;
594 sumsq += score * score;
595 ++count;
596 }
597
599 double deltaScore() const { return best - second_best; }
600
622 double zScore() const;
623 };
624
634 {
635 unsigned int min_peaks{3};
636 bool charge_cap_precursor{false};
637 bool sum_intensity{false};
638 };
639
654 static void preprocessSpectra_(PeakMap& exp,
655 double fragment_mass_tolerance,
656 bool fragment_mass_tolerance_unit_ppm,
657 bool deisotope_requested,
658 Size peaks_keep_n,
659 Int peaks_window_top,
660 const std::string& window_type,
661 const DeisotopingSettings_& deisotoping,
662 FragmentIonLikelihoodModel::PeakLists* ion_evidence = nullptr,
663 bool ion_evidence_scored_peaks = false,
664 PeakMap* evidence_spectra = nullptr,
665 PeakMap* query_spectra = nullptr);
666
668 static void preprocessSpectra_(PeakMap& exp,
669 double fragment_mass_tolerance,
670 bool fragment_mass_tolerance_unit_ppm,
671 bool deisotope_requested,
672 Size peaks_keep_n,
673 Int peaks_window_top,
674 const std::string& window_type = "auto");
675
702 void annotateIonPriors_(const PeakMap& spectra,
704 std::vector<ProteinIdentification>& protein_ids,
705 PeptideIdentificationList& peptide_ids) const;
706
709
711 static void filterLocalPeaks_(MSSpectrum& spectrum, Size peaks_per_window);
712
714 enum class DecoyMode_
715 {
716 AUTO,
717 GENERATE,
718 IGNORE
719 };
720
729 {
730 bool generate{false};
731 bool strip_existing{false};
732 bool have_decoys{false};
733 std::string decoy_string;
734 bool is_prefix{true};
735 std::string strip_string;
736 bool strip_is_prefix{true};
737 };
738
748 const std::vector<FASTAFile::FASTAEntry>& db) const;
749
762 Param fragmentIndexParameters_(bool electron_ions = false) const;
763
766 struct SpectrumGenerators_;
767
769 SpectrumGenerators_ spectrumGenerators_() const;
770
773 {
774 double chance_match_surprise = 0.0;
775 double mass_competition_evidence = 0.0;
776 };
777
779 static std::vector<double> localPeakDensities_(const MSSpectrum& spectrum);
780
800 const MSSpectrum& theoretical,
801 const std::vector<double>& densities,
802 double tolerance, bool ppm);
803
807 const MSSpectrum& theoretical,
808 int max_charge,
809 const std::vector<double>& densities,
810 double tolerance, bool ppm,
811 std::vector<double>& alternatives);
812
814 static bool isElectronActivated_(const MSSpectrum& spectrum);
815
817 Size countElectronActivated_(const PeakMap& spectra) const;
818
826 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
827 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
828 const DecoyStrategy_& strategy) const;
829
831 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
832 std::vector<FASTAFile::FASTAEntry>&& fasta_db,
833 const DecoyStrategy_& strategy) const;
834
838 SearchContext prepareContext_(std::vector<FASTAFile::FASTAEntry>&& fasta_db, bool electron_ions,
839 const std::function<const PeakMap*(Size)>& searched_spectra = {}) const;
840
843 bool restrictIndexToSpectra_() const { return !calibration_enabled_; }
844
858 std::vector<FASTAFile::FASTAEntry> buildCalibrationSample_(
859 const std::vector<FASTAFile::FASTAEntry>& full_db) const;
860
875 PeakMap& spectra,
876 std::vector<FASTAFile::FASTAEntry>& full_db,
877 const DecoyStrategy_& strategy,
878 std::vector<ProteinIdentification>& protein_ids,
879 PeptideIdentificationList& peptide_ids) const;
880
906 const PeakMap& spectra,
907 FragmentIndex& fi,
908 const std::vector<FASTAFile::FASTAEntry>& db,
909 const SpectrumGenerators_& generators,
910 double effective_fragment_tol,
911 bool fragment_mass_tolerance_unit_ppm,
912 bool open_search_mode,
913 std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
914 std::vector<CandidatePoolStats_>& pool_stats,
915 const std::string& progress_label,
916 const PeakMap* query_spectra = nullptr) const;
917
947 void postProcessHits_(const PeakMap& exp,
948 std::vector<std::vector<ProSEAlgorithm::AnnotatedHit_> >& annotated_hits,
949 const std::vector<CandidatePoolStats_>& pool_stats,
950 std::vector<ProteinIdentification>& protein_ids,
951 PeptideIdentificationList& peptide_ids,
952 Size top_hits,
953 const StringList& modifications_fixed,
954 const StringList& modifications_variable,
955 Int peptide_missed_cleavages,
956 double precursor_mass_tolerance,
957 double fragment_mass_tolerance,
958 const std::string& precursor_mass_tolerance_unit_ppm,
959 const std::string& fragment_mass_tolerance_unit_ppm,
960 const Int precursor_min_charge,
961 const Int precursor_max_charge,
962 const std::string& enzyme,
963 const std::string& database_name,
964 const PeakMap* evidence_spectra = nullptr) const;
965
969 mutable double precursor_mass_tolerance_lower_{10.0};
970 mutable double precursor_mass_tolerance_upper_{10.0};
971 std::string precursor_mass_tolerance_unit_{"ppm"};
972
975
977
979
984 bool deisotope_requested_{true};
985 bool scoring_multiple_charges_{false};
986 int scoring_max_charge_{2};
987 bool mass_accuracy_score_{false};
988 double mass_error_sd_ppm_{7.0};
989
991 int scoringMaxCharge_(int precursor_charge) const
992 {
993 return scoring_multiple_charges_ ? std::max(1, std::min(precursor_charge - 1, scoring_max_charge_)) : 1;
994 }
995 Size peaks_keep_n_{0};
996 Int peaks_window_top_{20};
997 std::string peaks_window_type_ {"auto"};
999 bool query_raw_spectrum_{false};
1000
1002
1004
1006
1007 std::string enzyme_;
1008
1009 DecoyMode_ decoy_mode_{DecoyMode_::AUTO};
1010 std::string decoy_prefix_;
1011
1012 double fdr_psm_{0.0};
1013 bool fdr_psm_by_scored_charges_{true};
1014 double fdr_protein_{0.0};
1015
1017
1018 bool self_trained_ion_priors_{false};
1019 FragmentIonLikelihoodModel::ContextSet ion_prior_model_{FragmentIonLikelihoodModel::ContextSet::RICH};
1020 bool ion_prior_scored_peaks_{false};
1021 int ion_prior_max_fragment_charge_{2};
1022 double ion_prior_train_fdr_{0.01};
1023 Size ion_prior_min_psms_{100};
1024 bool ion_prior_feature_llr_{true};
1025 bool ion_prior_feature_explained_{true};
1026 bool ion_prior_feature_topk_{false};
1027
1031 EnzymaticDigestion::Specificity peptide_enzyme_specificity_{EnzymaticDigestion::SPEC_FULL};
1032
1033 std::string peptide_motif_;
1034
1038 bool isotope_error_observed_minus_theoretical_{true};
1039
1040 bool add_a_ions_{false};
1041 bool add_b_ions_{true};
1042 bool add_c_ions_{false};
1043 bool add_x_ions_{false};
1044 bool add_y_ions_{true};
1045 bool add_z_ions_{false};
1046 bool add_zp1_ions_{false};
1047 bool ions_by_activation_{true};
1048 bool protein_mapping_from_index_{true};
1049
1050 Size database_chunk_size_{0};
1051
1052 bool calibration_enabled_{false};
1053 double calibration_subset_ratio_{0.1};
1054 Size calibration_min_psms_{50};
1055
1064 {
1065 double precursor_shift{0};
1066 double precursor_spread{0};
1067 double cal_lower{0};
1068 double cal_upper{0};
1069 double fragment_tolerance{0};
1070 double fragment_shift{0};
1071 bool extreme_bias{false};
1072 bool success{false};
1073 };
1074
1079
1086
1094 mutable double last_mod_match_tolerance_used_{-1.0};
1095
1107 {
1108 if (precursor_mass_tolerance_lower_ <= 0.0) return precursor_mass_tolerance_upper_;
1109 if (precursor_mass_tolerance_upper_ <= 0.0) return precursor_mass_tolerance_lower_;
1110 return std::min(precursor_mass_tolerance_lower_, precursor_mass_tolerance_upper_);
1111 }
1112
1127 FragmentIndex& fragment_index,
1128 const std::vector<FASTAFile::FASTAEntry>& db,
1129 const PeakMap* query_spectra = nullptr) const;
1130
1149 {
1151 static constexpr Size SHARDS = 64;
1153 std::vector<std::string_view> sequences;
1155 std::vector<std::vector<std::pair<UInt32, UInt32>>> occurrences;
1157 std::vector<std::unordered_map<std::string_view, Size>> entries;
1159 std::string fallback_reason;
1160
1162 Size find(std::string_view sequence) const
1163 {
1164 if (entries.empty()) return sequences.size();
1165 const auto& table = entries[std::hash<std::string_view>{}(sequence) % SHARDS];
1166 const auto entry = table.find(sequence);
1167 return entry == table.end() ? sequences.size() : entry->second;
1168 }
1169 };
1170
1181 const std::vector<FASTAFile::FASTAEntry>& db,
1182 std::vector<UInt32> candidates,
1183 const Param& indexer_parameters);
1184
1193 static bool applyProteinMapping_(const ProteinMapping_& mapping,
1194 const std::vector<FASTAFile::FASTAEntry>& db,
1195 const Param& indexer_parameters,
1196 std::vector<ProteinIdentification>& protein_ids,
1197 PeptideIdentificationList& peptide_ids,
1198 std::string& fallback_reason);
1199
1202 static bool accessionHasDecoyMarker_(const std::string& accession,
1203 const std::string& marker, bool is_prefix);
1204
1211 static void capturePreFdrStats_(const PeptideIdentificationList& peptide_ids,
1212 RunStatistics& stats);
1213
1217 static double maxRetainedScore_(const PeptideIdentificationList& peptide_ids);
1218
1224 void collectRunStatistics_(const PeakMap& spectra,
1225 const std::vector<ProteinIdentification>& protein_ids,
1226 const PeptideIdentificationList& peptide_ids,
1227 RunStatistics& stats) const;
1228
1229 public:
1240 const PeptideIdentificationList& peptide_ids,
1241 const std::string& enzyme,
1242 bool fdr_applied);
1243
1248 static void renderRunSummary(const RunStatistics& stats,
1249 const SharedSearchStats& shared,
1251 bool is_open_search,
1252 std::ostream& os);
1253
1257 std::ostream& os);
1258
1265 static std::string renderRunSummaryYaml(
1266 const MultiFileSearchResult& mfres,
1267 const std::vector<std::pair<std::string, std::vector<std::string>>>& manifest,
1268 Size files_failed,
1269 Size files_total);
1270
1271 private:
1272
1275 {
1276 return FragmentIndex::isOpenSearchMode(precursor_mass_tolerance_lower_,
1277 precursor_mass_tolerance_upper_,
1278 precursor_mass_tolerance_unit_ == "ppm");
1279 }
1280};
1281
1282} // namespace
Definition AASequence.h:96
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Specificity
when querying for valid digestion products, this determines if the specificity of the two peptide end...
Definition EnzymaticDigestion.h:41
Generates from a set of Fasta files a 2D-datastructure which stores all theoretical masses of all b a...
Definition FragmentIndex.h:35
Compact peak lists of the spectra of one run: per peak only its m/z and its intensity-rank bin.
Definition FragmentIonLikelihoodModel.h:82
ContextSet
Ion contexts and outcomes the model distinguishes.
Definition FragmentIonLikelihoodModel.h:60
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Combined result of open search modification analysis.
Definition OpenSearchModificationAnalysis.h:104
Management and storage of parameters / INI files.
Definition Param.h:46
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Fragment-index-based peptide database search algorithm (experimental).
Definition ProSEAlgorithm.h:56
ExitCodes search(PeakMap &spectra, const std::vector< FASTAFile::FASTAEntry > &fasta_db, std::vector< ProteinIdentification > &prot_ids, PeptideIdentificationList &pep_ids) const
In-memory search: search spectra against a protein database without file I/O.
static LocalFragmentEvidence_ localFragmentEvidence_(const MSSpectrum &spectrum, const MSSpectrum &theoretical, const std::vector< double > &densities, double tolerance, bool ppm)
Compute local fragment-match evidence on the spectrum before window/top-N peak filtering.
std::string enzyme_
Definition ProSEAlgorithm.h:1007
static std::string renderRunSummaryYaml(const MultiFileSearchResult &mfres, const std::vector< std::pair< std::string, std::vector< std::string > > > &manifest, Size files_failed, Size files_total)
static void preprocessSpectra_(PeakMap &exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, bool deisotope_requested, Size peaks_keep_n, Int peaks_window_top, const std::string &window_type, const DeisotopingSettings_ &deisotoping, FragmentIonLikelihoodModel::PeakLists *ion_evidence=nullptr, bool ion_evidence_scored_peaks=false, PeakMap *evidence_spectra=nullptr, PeakMap *query_spectra=nullptr)
filter, deisotope, decharge spectra
FragmentIndex fragment_index
Definition ProSEAlgorithm.h:219
std::string fragment_tol_unit
Definition ProSEAlgorithm.h:120
Size peptide_max_size_
Definition ProSEAlgorithm.h:1029
static void updateFinalStats(RunStatistics &stats, const PeptideIdentificationList &peptide_ids, const std::string &enzyme, bool fdr_applied)
static void preprocessSpectra_(PeakMap &exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, bool deisotope_requested, Size peaks_keep_n, Int peaks_window_top, const std::string &window_type="auto")
preprocessSpectra_() with the DeisotopingSettings_ defaults (the behaviour before its parameters exis...
SearchResult searchWithModificationAnalysis(const std::string &in_spectra, const std::string &in_db, const std::string &output_base_name="") const
Search with comprehensive results including modification analysis tables.
Size precursor_max_charge_
Definition ProSEAlgorithm.h:974
Size precursor_min_charge_
Definition ProSEAlgorithm.h:973
std::string decoy_prefix_
Definition ProSEAlgorithm.h:1010
RunStatistics stats
Definition ProSEAlgorithm.h:154
Size report_top_hits_
Definition ProSEAlgorithm.h:1035
Size modifications_max_variable_mods_per_peptide_
Definition ProSEAlgorithm.h:1005
static void renderModificationSummary(const OpenSearchModificationAnalysis::OpenSearchAnalysisResult &mod_analysis, std::ostream &os)
SearchResult searchWithModificationAnalysis(PeakMap &spectra, const std::vector< FASTAFile::FASTAEntry > &fasta_db, const std::string &output_base_name="") const
In-memory search with modification analysis: no file I/O required.
std::string peptide_motif_
Definition ProSEAlgorithm.h:1033
std::string input_file
spectrum file this run searched (basename or path)
Definition ProSEAlgorithm.h:81
SearchContext prepareContext_(std::vector< FASTAFile::FASTAEntry > &&fasta_db, bool electron_ions, const std::function< const PeakMap *(Size)> &searched_spectra={}) const
std::map< Int, Size > charge_histogram
precursor charge -> PSM count
Definition ProSEAlgorithm.h:90
SpectrumGenerators_ spectrumGenerators_() const
Generators for scoring, annotation and calibration, configured from the ions:* parameters.
StringList modifications_fixed_
Definition ProSEAlgorithm.h:1001
MultiFileSearchResult searchWithModificationAnalysis(const std::vector< std::string > &in_spectra_files, const std::vector< FASTAFile::FASTAEntry > &fasta_db, const std::vector< std::string > &output_base_names={}, const std::string &aggregate_base_name="", bool build_pooled_aggregate=true) const
Multi-file search with modification analysis (in-memory FASTA).
static void capturePreFdrStats_(const PeptideIdentificationList &peptide_ids, RunStatistics &stats)
void annotateIonPriors_(const PeakMap &spectra, const FragmentIonLikelihoodModel::PeakLists &evidence, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids) const
Learn per-run fragment ion likelihoods from confident PSMs and annotate every hit with them.
void annotatePsmQValues(PeptideIdentificationList &peptide_ids) const
Annotate PSM q-values by target-decoy competition of the best hit of each spectrum,...
std::vector< ProteinIdentification > protein_ids
Definition ProSEAlgorithm.h:150
bool restrictIndexToSpectra_() const
Definition ProSEAlgorithm.h:843
Size peptide_min_size_
Definition ProSEAlgorithm.h:1028
std::vector< FASTAFile::FASTAEntry > buildDecoyAugmentedDB_(const std::vector< FASTAFile::FASTAEntry > &fasta_db, const DecoyStrategy_ &strategy) const
Build the searched database according to strategy.
SearchResult aggregate
Definition ProSEAlgorithm.h:192
MultiFileSearchResult searchWithModificationAnalysis(const std::vector< std::string > &in_spectra_files, const std::string &in_db, const std::vector< std::string > &output_base_names={}, const std::string &aggregate_base_name="", bool build_pooled_aggregate=true) const
Multi-file search with modification analysis (FASTA file path).
std::string database_file
FASTA path (empty for in-memory db)
Definition ProSEAlgorithm.h:115
static AASequence reversedNoiseSequence_(const AASequence &sequence)
Reversed sequence keeping the C-terminal residue and every residue's modification: the noise hypothes...
CalibrationResult_ runCalibrationPass_(PeakMap &spectra, FragmentIndex &fragment_index, const std::vector< FASTAFile::FASTAEntry > &db, const PeakMap *query_spectra=nullptr) const
Run a fast calibration pass on a subset of spectra to estimate mass accuracy.
std::vector< FASTAFile::FASTAEntry > buildDecoyAugmentedDB_(std::vector< FASTAFile::FASTAEntry > &&fasta_db, const DecoyStrategy_ &strategy) const
As above, but takes the entries of fasta_db over instead of copying them.
std::string strip_string
marker of pre-existing decoys to strip
Definition ProSEAlgorithm.h:735
std::map< Size, Size > missed_cleavage_histogram
missed cleavages -> PSM count
Definition ProSEAlgorithm.h:91
static ProteinMapping_ buildProteinMapping_(const FragmentIndex &index, const std::vector< FASTAFile::FASTAEntry > &db, std::vector< UInt32 > candidates, const Param &indexer_parameters)
Collects the protein occurrences of the sequences of the index peptides candidates.
RunStatistics last_run_stats_
Definition ProSEAlgorithm.h:1085
std::string fragment_mass_tolerance_unit_
Definition ProSEAlgorithm.h:978
static bool applyProteinMapping_(const ProteinMapping_ &mapping, const std::vector< FASTAFile::FASTAEntry > &db, const Param &indexer_parameters, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, std::string &fallback_reason)
Writes what PeptideIndexing::run(db, protein_ids, peptide_ids) with indexer_parameters writes: the ev...
StringList annotate_psm_
Definition ProSEAlgorithm.h:1016
static void filterLocalPeaks_(MSSpectrum &spectrum, Size peaks_per_window)
Keep the strongest peaks in each non-overlapping 100 Da window, including a short final window.
static void applyCompleteSetProteinFDR(std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, const std::string &decoy_string, bool decoy_is_prefix, double protein_fdr)
Finalize protein-level FDR on a COMPLETE protein set (a single input file, or a merged cross-file agg...
Param fragmentIndexParameters_(bool electron_ions=false) const
ProSE parameters made safe to hand to a FragmentIndex.
OpenSearchModificationAnalysis::OpenSearchAnalysisResult modification_analysis
Definition ProSEAlgorithm.h:152
ExitCodes search(const std::string &in_spectra, const std::string &in_db, std::vector< ProteinIdentification > &prot_ids, PeptideIdentificationList &pep_ids) const
Search spectra in a spectrum file (mzML or Bruker .d) against a protein database using an FI-backed w...
std::vector< FASTAFile::FASTAEntry > db
Definition ProSEAlgorithm.h:218
static bool accessionHasDecoyMarker_(const std::string &accession, const std::string &marker, bool is_prefix)
static void renderRunSummary(const RunStatistics &stats, const SharedSearchStats &shared, const OpenSearchModificationAnalysis::OpenSearchAnalysisResult &mod_analysis, bool is_open_search, std::ostream &os)
ExitCodes search(PeakMap &spectra, SearchContext &ctx, std::vector< ProteinIdentification > &prot_ids, PeptideIdentificationList &pep_ids) const
In-memory search using a pre-built SearchContext.
SharedSearchStats shared
Definition ProSEAlgorithm.h:205
bool isOpenSearchMode_() const
Helper function to determine if open search should be used based on tolerance.
Definition ProSEAlgorithm.h:1274
ExitCodes searchChunked_(PeakMap &spectra, std::vector< FASTAFile::FASTAEntry > &full_db, const DecoyStrategy_ &strategy, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids) const
Chunked database search implementation.
std::string decoy_string
Definition ProSEAlgorithm.h:197
DecoyStrategy_ resolveDecoyStrategy_(const std::vector< FASTAFile::FASTAEntry > &db) const
Decide how to obtain/recognise decoys for db.
Size countElectronActivated_(const PeakMap &spectra) const
Number of spectra that ions:by_activation also scores with c and z+1 ions (0 if it is off)
DeisotopingSettings_ deisotoping_
MS2 deisotoping rule (fragment:deisotope_*)
Definition ProSEAlgorithm.h:998
std::vector< FASTAFile::FASTAEntry > buildCalibrationSample_(const std::vector< FASTAFile::FASTAEntry > &full_db) const
Build a strided protein sample for chunked calibration.
static std::vector< double > localPeakDensities_(const MSSpectrum &spectrum)
Peak counts per Da in a fixed +/-50 m/z window around each peak of a sorted spectrum.
void scoreSpectraAgainstIndex_(const PeakMap &spectra, FragmentIndex &fi, const std::vector< FASTAFile::FASTAEntry > &db, const SpectrumGenerators_ &generators, double effective_fragment_tol, bool fragment_mass_tolerance_unit_ppm, bool open_search_mode, std::vector< std::vector< AnnotatedHit_ > > &annotated_hits, std::vector< CandidatePoolStats_ > &pool_stats, const std::string &progress_label, const PeakMap *query_spectra=nullptr) const
Score all spectra against one FragmentIndex.
static bool isElectronActivated_(const MSSpectrum &spectrum)
True if the precursor of spectrum was activated by electrons (ETD, ECD, EThcD or ETciD)
std::string decoy_mode
"generated" | "external" | "none (target-only)"
Definition ProSEAlgorithm.h:128
PeptideIdentificationList peptide_ids
Definition ProSEAlgorithm.h:151
std::string enzyme
Definition ProSEAlgorithm.h:116
static LocalFragmentEvidence_ localFragmentEvidence_(const MSSpectrum &spectrum, const MSSpectrum &theoretical, int max_charge, const std::vector< double > &densities, double tolerance, bool ppm, std::vector< double > &alternatives)
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
void postProcessHits_(const PeakMap &exp, std::vector< std::vector< ProSEAlgorithm::AnnotatedHit_ > > &annotated_hits, const std::vector< CandidatePoolStats_ > &pool_stats, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, Size top_hits, const StringList &modifications_fixed, const StringList &modifications_variable, Int peptide_missed_cleavages, double precursor_mass_tolerance, double fragment_mass_tolerance, const std::string &precursor_mass_tolerance_unit_ppm, const std::string &fragment_mass_tolerance_unit_ppm, const Int precursor_min_charge, const Int precursor_max_charge, const std::string &enzyme, const std::string &database_name, const PeakMap *evidence_spectra=nullptr) const
Filter and annotate search results.
ExitCodes
Exit codes.
Definition ProSEAlgorithm.h:62
StringList modifications_variable_
Definition ProSEAlgorithm.h:1003
static double maxRetainedScore_(const PeptideIdentificationList &peptide_ids)
std::vector< SearchResult > per_file
Definition ProSEAlgorithm.h:191
double fragment_mass_tolerance_
Definition ProSEAlgorithm.h:976
SearchContext prepareContext(const std::vector< FASTAFile::FASTAEntry > &fasta_db) const
Build a SearchContext (decoy-augmented database + FragmentIndex) for reuse.
int scoringMaxCharge_(int precursor_charge) const
Fragment charges that score a candidate of the given precursor charge; also used by the calibration p...
Definition ProSEAlgorithm.h:991
SearchContext prepareContext(const std::vector< FASTAFile::FASTAEntry > &fasta_db, bool electron_ions) const
Build a SearchContext whose FragmentIndex also holds c and z+1 ions.
Size peptide_missed_cleavages_
Definition ProSEAlgorithm.h:1030
CalibrationResult_ last_calibration_result_
Definition ProSEAlgorithm.h:1078
double computeModMatchTolerance_() const
Definition ProSEAlgorithm.h:1106
void collectRunStatistics_(const PeakMap &spectra, const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, RunStatistics &stats) const
std::vector< std::string > fixed_mods
Definition ProSEAlgorithm.h:123
std::string precursor_tol_unit
Definition ProSEAlgorithm.h:118
DecoyMode_
How decoys are obtained/recognised for a search (parameter "decoys").
Definition ProSEAlgorithm.h:715
Result of a calibration pass.
Definition ProSEAlgorithm.h:1064
Resolved decoy handling for one concrete input database.
Definition ProSEAlgorithm.h:729
MS2 deisotoping rule of preprocessSpectra_().
Definition ProSEAlgorithm.h:634
Local fragment evidence of one candidate (annotate:local_fragment_evidence).
Definition ProSEAlgorithm.h:773
Multi-file search result bundle.
Definition ProSEAlgorithm.h:190
Per-run identification statistics for the end-of-search report.
Definition ProSEAlgorithm.h:80
Prepared per-database state shared across multiple spectrum files.
Definition ProSEAlgorithm.h:217
Comprehensive search result including modification analysis.
Definition ProSEAlgorithm.h:148
Configuration, database and fragment-index facts shared across all input files of one ProSE invocatio...
Definition ProSEAlgorithm.h:114
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
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
std::vector< std::string > StringList
Vector of String.
Definition TypeAliases.h:39
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Slimmer structure as storing all scored candidates in PeptideHit objects takes too much space.
Definition ProSEAlgorithm.h:533
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition ProSEAlgorithm.h:551
double score
main score
Definition ProSEAlgorithm.h:540
AASequence sequence
Definition ProSEAlgorithm.h:534
Running summary of the complete candidate pool of one spectrum.
Definition ProSEAlgorithm.h:578
std::unordered_set< std::string > seen_candidates
Definition ProSEAlgorithm.h:586
void add(double score)
Fold one freshly scored candidate into the summary.
Definition ProSEAlgorithm.h:589
double deltaScore() const
Best minus runner-up over the full pool.
Definition ProSEAlgorithm.h:599
double zScore() const
How much of an outlier the best score is within its own candidate pool.
The protein occurrences of the sequences of a search's hits (peptide:protein_mapping = index).
Definition ProSEAlgorithm.h:1149
std::vector< std::string_view > sequences
The unmodified hit sequences (views into the database), one entry each.
Definition ProSEAlgorithm.h:1153
std::string fallback_reason
Why PeptideIndexing has to run instead; empty if the mapping applies.
Definition ProSEAlgorithm.h:1159
Size find(std::string_view sequence) const
The entry of sequence, or sequences.size() if there is none.
Definition ProSEAlgorithm.h:1162
std::vector< std::vector< std::pair< UInt32, UInt32 > > > occurrences
Per entry: its occurrences {protein index, position}, ascending (PeptideIndexing's evidence order)
Definition ProSEAlgorithm.h:1155
std::vector< std::unordered_map< std::string_view, Size > > entries
Sequence -> entry, in SHARDS hash tables.
Definition ProSEAlgorithm.h:1157