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 peptide_mass_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
144 {
146 bool applied = false;
148 std::string skipped_reason;
151 std::string warning;
152 };
153
175
215 {
216 std::vector<SearchResult> per_file;
218
222 std::string decoy_string;
224 bool decoy_is_prefix = true;
226 bool have_decoys = false;
227
231 };
232
235 {
236 std::vector<ProteinIdentification> protein_ids;
240 bool protein_fdr_applied = false;
241 };
242
252 {
253 std::vector<FASTAFile::FASTAEntry> db;
255
265 bool release_fragment_index_after_scoring = false;
266
271 std::string decoy_string;
273 bool decoy_is_prefix = true;
276 bool have_decoys = false;
281 bool electron_ions = false;
282 };
283
305 ExitCodes search(const std::string& in_spectra,
306 const std::string& in_db,
307 std::vector<ProteinIdentification>& prot_ids,
308 PeptideIdentificationList& pep_ids) const;
309
334 static void applyCompleteSetProteinFDR(std::vector<ProteinIdentification>& protein_ids,
335 PeptideIdentificationList& peptide_ids,
336 const std::string& decoy_string,
337 bool decoy_is_prefix,
338 double protein_fdr);
339
352
386 static PercolatorRescoring rescoreWithPercolator(std::vector<ProteinIdentification>& protein_ids,
387 PeptideIdentificationList& peptide_ids,
388 int threads);
389
412 bool applyDeferredPsmFDR(const std::vector<ProteinIdentification>& protein_ids,
413 PeptideIdentificationList& peptide_ids,
414 bool rescored,
415 double psm_fdr) const;
416
463 SearchResult searchWithModificationAnalysis(const std::string& in_spectra,
464 const std::string& in_db,
465 const std::string& output_base_name = "") const;
466
485 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
486 std::vector<ProteinIdentification>& prot_ids,
487 PeptideIdentificationList& pep_ids) const;
488
509 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db) const;
510
524 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db, bool electron_ions) const;
525
547 SearchContext& ctx,
548 std::vector<ProteinIdentification>& prot_ids,
549 PeptideIdentificationList& pep_ids) const;
550
562 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
563 const std::string& output_base_name = "") const;
564
616 const std::vector<std::string>& in_spectra_files,
617 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
618 const std::vector<std::string>& output_base_names = {},
619 const std::string& aggregate_base_name = "",
620 bool build_pooled_aggregate = true) const;
621
636 const std::vector<std::string>& in_spectra_files,
637 const std::string& in_db,
638 const std::vector<std::string>& output_base_names = {},
639 const std::string& aggregate_base_name = "",
640 bool build_pooled_aggregate = true) const;
641
684 bool remove_decoys = true) const;
685
689 void setKeepPreFdrPsms(bool keep)
690 {
691 keep_pre_fdr_psms_ = keep;
692 if (!keep) { pre_fdr_peptide_ids_ = PeptideIdentificationList(); }
693 }
694
695 protected:
696 void updateMembers_() override;
697
700 {
702 /*
703 std::string_view sequence;
704 SignedSize peptide_mod_index; ///< enumeration index of the non-RNA peptide modification
705 */
706 // Layout: doubles first, then floats, then int, then uint16_t — minimizes padding (40 bytes excluding AASequence)
707 double score = 0;
708 double delta_mass = 0.0;
709 float prefix_fraction = 0;
710 float suffix_fraction = 0;
711 float mean_error = 0.0f;
712 int isotope_error = 0;
713 uint16_t applied_charge = 0;
714 uint16_t matched_prefix_ions = 0;
715 uint16_t matched_suffix_ions = 0;
716 UInt32 index_peptide = 0;
717
718 static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
719 {
720 if (a.score != b.score) return a.score > b.score;
721 return a.sequence < b.sequence;
722 }
723 };
724
745 {
746 double sum = 0.0;
747 double sumsq = 0.0;
748 double best = 0.0;
749 double second_best = 0.0;
750 Size count = 0;
753 std::unordered_set<std::string> seen_candidates;
754
756 void add(double score)
757 {
758 if (score > best) { second_best = best; best = score; }
759 else if (score > second_best) { second_best = score; }
760 sum += score;
761 sumsq += score * score;
762 ++count;
763 }
764
766 double deltaScore() const { return best - second_best; }
767
789 double zScore() const;
790 };
791
801 {
802 unsigned int min_peaks{3};
803 bool charge_cap_precursor{false};
804 bool sum_intensity{false};
805 };
806
821 static void preprocessSpectra_(PeakMap& exp,
822 double fragment_mass_tolerance,
823 bool fragment_mass_tolerance_unit_ppm,
824 bool deisotope_requested,
825 Size peaks_keep_n,
826 Int peaks_window_top,
827 const std::string& window_type,
828 const DeisotopingSettings_& deisotoping,
829 FragmentIonLikelihoodModel::PeakLists* ion_evidence = nullptr,
830 bool ion_evidence_scored_peaks = false,
831 PeakMap* evidence_spectra = nullptr,
832 PeakMap* query_spectra = nullptr);
833
835 static void preprocessSpectra_(PeakMap& exp,
836 double fragment_mass_tolerance,
837 bool fragment_mass_tolerance_unit_ppm,
838 bool deisotope_requested,
839 Size peaks_keep_n,
840 Int peaks_window_top,
841 const std::string& window_type = "auto");
842
869 void annotateIonPriors_(const PeakMap& spectra,
871 std::vector<ProteinIdentification>& protein_ids,
872 PeptideIdentificationList& peptide_ids) const;
873
876
878 static void filterLocalPeaks_(MSSpectrum& spectrum, Size peaks_per_window);
879
881 enum class DecoyMode_
882 {
883 AUTO,
884 GENERATE,
885 IGNORE
886 };
887
896 {
897 bool generate{false};
898 bool strip_existing{false};
899 bool have_decoys{false};
900 std::string decoy_string;
901 bool is_prefix{true};
902 std::string strip_string;
903 bool strip_is_prefix{true};
904 };
905
915 const std::vector<FASTAFile::FASTAEntry>& db) const;
916
929 Param fragmentIndexParameters_(bool electron_ions = false) const;
930
933 struct SpectrumGenerators_;
934
936 SpectrumGenerators_ spectrumGenerators_() const;
937
940 {
941 double chance_match_surprise = 0.0;
942 double mass_competition_evidence = 0.0;
943 };
944
946 static std::vector<double> localPeakDensities_(const MSSpectrum& spectrum);
947
967 const MSSpectrum& theoretical,
968 const std::vector<double>& densities,
969 double tolerance, bool ppm);
970
974 const MSSpectrum& theoretical,
975 int max_charge,
976 const std::vector<double>& densities,
977 double tolerance, bool ppm,
978 std::vector<double>& alternatives);
979
981 static bool isElectronActivated_(const MSSpectrum& spectrum);
982
984 Size countElectronActivated_(const PeakMap& spectra) const;
985
993 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
994 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
995 const DecoyStrategy_& strategy) const;
996
998 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
999 std::vector<FASTAFile::FASTAEntry>&& fasta_db,
1000 const DecoyStrategy_& strategy) const;
1001
1005 SearchContext prepareContext_(std::vector<FASTAFile::FASTAEntry>&& fasta_db, bool electron_ions,
1006 const std::function<const PeakMap*(Size)>& searched_spectra = {}) const;
1007
1010 bool restrictIndexToSpectra_() const { return !calibration_enabled_; }
1011
1025 std::vector<FASTAFile::FASTAEntry> buildCalibrationSample_(
1026 const std::vector<FASTAFile::FASTAEntry>& full_db) const;
1027
1042 PeakMap& spectra,
1043 std::vector<FASTAFile::FASTAEntry>& full_db,
1044 const DecoyStrategy_& strategy,
1045 std::vector<ProteinIdentification>& protein_ids,
1046 PeptideIdentificationList& peptide_ids) const;
1047
1073 const PeakMap& spectra,
1074 FragmentIndex& fi,
1075 const std::vector<FASTAFile::FASTAEntry>& db,
1076 const SpectrumGenerators_& generators,
1077 double effective_fragment_tol,
1078 bool fragment_mass_tolerance_unit_ppm,
1079 bool open_search_mode,
1080 std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
1081 std::vector<CandidatePoolStats_>& pool_stats,
1082 const std::string& progress_label,
1083 const PeakMap* query_spectra = nullptr) const;
1084
1114 void postProcessHits_(const PeakMap& exp,
1115 std::vector<std::vector<ProSEAlgorithm::AnnotatedHit_> >& annotated_hits,
1116 const std::vector<CandidatePoolStats_>& pool_stats,
1117 std::vector<ProteinIdentification>& protein_ids,
1118 PeptideIdentificationList& peptide_ids,
1119 Size top_hits,
1120 const StringList& modifications_fixed,
1121 const StringList& modifications_variable,
1122 Int peptide_missed_cleavages,
1123 double precursor_mass_tolerance,
1124 double fragment_mass_tolerance,
1125 const std::string& precursor_mass_tolerance_unit_ppm,
1126 const std::string& fragment_mass_tolerance_unit_ppm,
1127 const Int precursor_min_charge,
1128 const Int precursor_max_charge,
1129 const std::string& enzyme,
1130 const std::string& database_name,
1131 const PeakMap* evidence_spectra = nullptr) const;
1132
1141 std::vector<ProteinIdentification>& protein_ids,
1142 PeptideIdentificationList& peptide_ids) const;
1143
1144 bool peptdeep_enable_{false};
1147 std::string peptdeep_instrument_{"QE"};
1148 double peptdeep_nce_{-1.0};
1149 std::string peptdeep_rt_model_type_{"b_spline"};
1150 int peptdeep_batch_size_{500};
1151
1155 mutable double precursor_mass_tolerance_lower_{10.0};
1156 mutable double precursor_mass_tolerance_upper_{10.0};
1157 std::string precursor_mass_tolerance_unit_{"ppm"};
1158
1161
1163
1165
1170 bool deisotope_requested_{true};
1171 bool scoring_multiple_charges_{false};
1172 int scoring_max_charge_{2};
1173 bool mass_accuracy_score_{false};
1174 double mass_error_sd_ppm_{7.0};
1175
1177 int scoringMaxCharge_(int precursor_charge) const
1178 {
1179 return scoring_multiple_charges_ ? std::max(1, std::min(precursor_charge - 1, scoring_max_charge_)) : 1;
1180 }
1181 Size peaks_keep_n_{0};
1182 Int peaks_window_top_{20};
1183 std::string peaks_window_type_ {"auto"};
1185 bool query_raw_spectrum_{false};
1186
1188
1190
1192
1193 std::string enzyme_;
1194
1195 DecoyMode_ decoy_mode_{DecoyMode_::AUTO};
1196 std::string decoy_prefix_;
1197
1198 bool rescore_{true};
1199 double fdr_psm_{0.0};
1200 bool fdr_psm_by_scored_charges_{true};
1201 double fdr_protein_{0.0};
1202
1204
1205 bool self_trained_ion_priors_{false};
1206 FragmentIonLikelihoodModel::ContextSet ion_prior_model_{FragmentIonLikelihoodModel::ContextSet::RICH};
1207 bool ion_prior_scored_peaks_{false};
1208 int ion_prior_max_fragment_charge_{2};
1209 double ion_prior_train_fdr_{0.01};
1210 Size ion_prior_min_psms_{100};
1211 bool ion_prior_feature_llr_{true};
1212 bool ion_prior_feature_explained_{true};
1213 bool ion_prior_feature_topk_{false};
1214
1218 EnzymaticDigestion::Specificity peptide_enzyme_specificity_{EnzymaticDigestion::SPEC_FULL};
1219
1220 std::string peptide_motif_;
1221
1225 bool isotope_error_observed_minus_theoretical_{true};
1226
1227 bool add_a_ions_{false};
1228 bool add_b_ions_{true};
1229 bool add_c_ions_{false};
1230 bool add_x_ions_{false};
1231 bool add_y_ions_{true};
1232 bool add_z_ions_{false};
1233 bool add_zp1_ions_{false};
1234 bool ions_by_activation_{true};
1235 bool protein_mapping_from_index_{true};
1236
1237 Size database_chunk_size_{0};
1238
1239 bool calibration_enabled_{false};
1240 double calibration_subset_ratio_{0.1};
1241 Size calibration_min_psms_{50};
1242
1251 {
1252 double precursor_shift{0};
1253 double precursor_spread{0};
1254 double cal_lower{0};
1255 double cal_upper{0};
1256 double fragment_tolerance{0};
1257 double fragment_shift{0};
1258 bool extreme_bias{false};
1259 bool success{false};
1260 };
1261
1266
1273
1277 bool keep_pre_fdr_psms_ = false;
1281
1289 mutable double last_mod_match_tolerance_used_{-1.0};
1290
1302 {
1303 if (precursor_mass_tolerance_lower_ <= 0.0) return precursor_mass_tolerance_upper_;
1304 if (precursor_mass_tolerance_upper_ <= 0.0) return precursor_mass_tolerance_lower_;
1305 return std::min(precursor_mass_tolerance_lower_, precursor_mass_tolerance_upper_);
1306 }
1307
1322 FragmentIndex& fragment_index,
1323 const std::vector<FASTAFile::FASTAEntry>& db,
1324 const PeakMap* query_spectra = nullptr) const;
1325
1344 {
1346 static constexpr Size SHARDS = 64;
1348 std::vector<std::string_view> sequences;
1350 std::vector<std::vector<std::pair<UInt32, UInt32>>> occurrences;
1352 std::vector<std::unordered_map<std::string_view, Size>> entries;
1354 std::string fallback_reason;
1355
1357 Size find(std::string_view sequence) const
1358 {
1359 if (entries.empty()) return sequences.size();
1360 const auto& table = entries[std::hash<std::string_view>{}(sequence) % SHARDS];
1361 const auto entry = table.find(sequence);
1362 return entry == table.end() ? sequences.size() : entry->second;
1363 }
1364 };
1365
1376 const std::vector<FASTAFile::FASTAEntry>& db,
1377 std::vector<UInt32> candidates,
1378 const Param& indexer_parameters);
1379
1388 static bool applyProteinMapping_(const ProteinMapping_& mapping,
1389 const std::vector<FASTAFile::FASTAEntry>& db,
1390 const Param& indexer_parameters,
1391 std::vector<ProteinIdentification>& protein_ids,
1392 PeptideIdentificationList& peptide_ids,
1393 std::string& fallback_reason);
1394
1397 static bool accessionHasDecoyMarker_(const std::string& accession,
1398 const std::string& marker, bool is_prefix);
1399
1407 static void poolSearchedFiles_(std::vector<SearchResult>& per_file, bool move_psms, const StringList& in_spectra_files,
1408 std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids);
1409
1416 static void capturePreFdrStats_(const PeptideIdentificationList& peptide_ids,
1417 RunStatistics& stats);
1418
1422 static double maxRetainedScore_(const PeptideIdentificationList& peptide_ids);
1423
1430 PercolatorRescoring applyPsmFDR_(std::vector<ProteinIdentification>& protein_ids,
1431 PeptideIdentificationList& peptide_ids,
1432 bool has_decoys,
1433 RunStatistics& stats,
1434 PeptideIdentificationList* pre_fdr_psms = nullptr) const;
1435
1441 void collectRunStatistics_(const PeakMap& spectra,
1442 const std::vector<ProteinIdentification>& protein_ids,
1443 const PeptideIdentificationList& peptide_ids,
1444 RunStatistics& stats) const;
1445
1446 public:
1457 const PeptideIdentificationList& peptide_ids,
1458 const std::string& enzyme,
1459 bool fdr_applied);
1460
1465 static void renderRunSummary(const RunStatistics& stats,
1466 const SharedSearchStats& shared,
1468 bool is_open_search,
1469 std::ostream& os);
1470
1474 std::ostream& os);
1475
1482 static std::string renderRunSummaryYaml(
1483 const MultiFileSearchResult& mfres,
1484 const std::vector<std::pair<std::string, std::vector<std::string>>>& manifest,
1485 Size files_failed,
1486 Size files_total);
1487
1488 private:
1489
1492 {
1493 return FragmentIndex::isOpenSearchMode(precursor_mass_tolerance_lower_,
1494 precursor_mass_tolerance_upper_,
1495 precursor_mass_tolerance_unit_ == "ppm");
1496 }
1497};
1498
1499} // 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.
PercolatorRescoring applyPsmFDR_(std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool has_decoys, RunStatistics &stats, PeptideIdentificationList *pre_fdr_psms=nullptr) const
std::string enzyme_
Definition ProSEAlgorithm.h:1193
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
PercolatorRescoring last_percolator_
Definition ProSEAlgorithm.h:1276
FragmentIndex fragment_index
Definition ProSEAlgorithm.h:254
std::string fragment_tol_unit
Definition ProSEAlgorithm.h:120
Size peptide_max_size_
Definition ProSEAlgorithm.h:1216
static void updateFinalStats(RunStatistics &stats, const PeptideIdentificationList &peptide_ids, const std::string &enzyme, bool fdr_applied)
PercolatorRescoring percolator
Outcome of the Percolator rescoring of this run (parameter 'rescore')
Definition ProSEAlgorithm.h:172
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:1160
Size precursor_min_charge_
Definition ProSEAlgorithm.h:1159
std::string decoy_prefix_
Definition ProSEAlgorithm.h:1196
RunStatistics stats
Definition ProSEAlgorithm.h:170
Size report_top_hits_
Definition ProSEAlgorithm.h:1222
Size modifications_max_variable_mods_per_peptide_
Definition ProSEAlgorithm.h:1191
static void renderModificationSummary(const OpenSearchModificationAnalysis::OpenSearchAnalysisResult &mod_analysis, std::ostream &os)
std::string warning
Definition ProSEAlgorithm.h:151
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.
void setKeepPreFdrPsms(bool keep)
Definition ProSEAlgorithm.h:689
std::string peptide_motif_
Definition ProSEAlgorithm.h:1220
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
PeptideIdentificationList pre_fdr_peptide_ids
the PSMs before rescoring and FDR:PSM; only filled with setKeepPreFdrPsms(true)
Definition ProSEAlgorithm.h:173
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:1187
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:166
bool restrictIndexToSpectra_() const
Definition ProSEAlgorithm.h:1010
Size peptide_min_size_
Definition ProSEAlgorithm.h:1215
std::vector< FASTAFile::FASTAEntry > buildDecoyAugmentedDB_(const std::vector< FASTAFile::FASTAEntry > &fasta_db, const DecoyStrategy_ &strategy) const
Build the searched database according to strategy.
MergedResult mergeFileResults(MultiFileSearchResult &result, const StringList &in_spectra_files, bool remove_decoys=true) const
Pools result (moving its PSMs out), infers proteins across files, applies FDR:protein of this instanc...
SearchResult aggregate
Definition ProSEAlgorithm.h:217
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).
void annotatePeptDeepFeatures_(const PeakMap &spectra, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids) const
Adds PeptDeep-prediction-derived rescoring features to the PSMs.
static PercolatorRescoring rescoreWithPercolator(std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, int threads)
Rescore the PSMs of one search run in-process with Percolator, as the parameter 'rescore' does in eve...
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:902
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:1272
std::string fragment_mass_tolerance_unit_
Definition ProSEAlgorithm.h:1164
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:1203
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:168
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:253
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:230
bool isOpenSearchMode_() const
Helper function to determine if open search should be used based on tolerance.
Definition ProSEAlgorithm.h:1491
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:222
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:1184
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:167
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)
std::string skipped_reason
Why the PSMs were not rescored, as a sentence to show to the user (empty if applied or not attempted)
Definition ProSEAlgorithm.h:148
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:1189
static double maxRetainedScore_(const PeptideIdentificationList &peptide_ids)
PeptideIdentificationList pre_fdr_peptide_ids_
Definition ProSEAlgorithm.h:1280
std::vector< SearchResult > per_file
Definition ProSEAlgorithm.h:216
double fragment_mass_tolerance_
Definition ProSEAlgorithm.h:1162
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:1177
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:1217
CalibrationResult_ last_calibration_result_
Definition ProSEAlgorithm.h:1265
double computeModMatchTolerance_() const
Definition ProSEAlgorithm.h:1301
static void poolSearchedFiles_(std::vector< SearchResult > &per_file, bool move_psms, const StringList &in_spectra_files, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids)
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
bool applyDeferredPsmFDR(const std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool rescored, double psm_fdr) const
Apply the PSM-level FDR that a search with Percolator rescoring deferred.
std::string peptdeep_ms2_model_
Definition ProSEAlgorithm.h:1145
std::string precursor_tol_unit
Definition ProSEAlgorithm.h:118
DecoyMode_
How decoys are obtained/recognised for a search (parameter "decoys").
Definition ProSEAlgorithm.h:882
std::string peptdeep_rt_model_
Definition ProSEAlgorithm.h:1146
Result of a calibration pass.
Definition ProSEAlgorithm.h:1251
Resolved decoy handling for one concrete input database.
Definition ProSEAlgorithm.h:896
MS2 deisotoping rule of preprocessSpectra_().
Definition ProSEAlgorithm.h:801
Local fragment evidence of one candidate (annotate:local_fragment_evidence).
Definition ProSEAlgorithm.h:940
The pooled evaluation of a multi-file search (the ProSE tool's -out_merged).
Definition ProSEAlgorithm.h:235
Multi-file search result bundle.
Definition ProSEAlgorithm.h:215
Outcome of the Percolator rescoring of one search run (see rescoreWithPercolator() and the parameter ...
Definition ProSEAlgorithm.h:144
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:252
Comprehensive search result including modification analysis.
Definition ProSEAlgorithm.h:164
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:700
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition ProSEAlgorithm.h:718
double score
main score
Definition ProSEAlgorithm.h:707
AASequence sequence
Definition ProSEAlgorithm.h:701
Running summary of the complete candidate pool of one spectrum.
Definition ProSEAlgorithm.h:745
std::unordered_set< std::string > seen_candidates
Definition ProSEAlgorithm.h:753
void add(double score)
Fold one freshly scored candidate into the summary.
Definition ProSEAlgorithm.h:756
double deltaScore() const
Best minus runner-up over the full pool.
Definition ProSEAlgorithm.h:766
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:1344
std::vector< std::string_view > sequences
The unmodified hit sequences (views into the database), one entry each.
Definition ProSEAlgorithm.h:1348
std::string fallback_reason
Why PeptideIndexing has to run instead; empty if the mapping applies.
Definition ProSEAlgorithm.h:1354
Size find(std::string_view sequence) const
The entry of sequence, or sequences.size() if there is none.
Definition ProSEAlgorithm.h:1357
std::vector< std::vector< std::pair< UInt32, UInt32 > > > occurrences
Per entry: its occurrences {protein index, position}, ascending (PeptideIndexing's evidence order)
Definition ProSEAlgorithm.h:1350
std::vector< std::unordered_map< std::string_view, Size > > entries
Sequence -> entry, in SHARDS hash tables.
Definition ProSEAlgorithm.h:1352