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_), std::function (loadSpectra)
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
62 static constexpr const char* CHIMERIC_RANK = "chimeric_rank";
63
65 enum class ExitCodes
66 {
67 EXECUTION_OK,
68 INPUT_FILE_EMPTY,
69 UNEXPECTED_RESULT,
70 UNKNOWN_ERROR,
71 ILLEGAL_PARAMETERS
72 };
73
84 {
85 std::string input_file;
86 Size ms2_spectra = 0;
87 Size profile_spectra = 0;
88 Size charge_out_of_range_spectra = 0;
89 Size matched_spectra = 0;
90 Size target_psms = 0;
91 Size decoy_psms = 0;
92 bool fdr_applied = false;
93 double achieved_psm_fdr = -1.0;
94 Size unique_peptides = 0;
95 Size unique_proteins = 0;
96 std::map<Int, Size> charge_histogram;
97 std::map<Size, Size> missed_cleavage_histogram;
98 bool score_stats_valid = false;
99 double hyperscore_min = 0.0;
100 double hyperscore_median = 0.0;
101 double hyperscore_max = 0.0;
106 bool prec_tol_valid = false;
107 double prec_err_median = 0.0, prec_err_mad = 0.0, prec_err_recommended = 0.0;
110 bool frag_tol_valid = false;
111 double frag_err_median = 0.0, frag_err_mad = 0.0, frag_err_recommended = 0.0;
112 double seconds_search = 0.0;
113 double seconds_calibration = 0.0;
114 double seconds_fdr = 0.0;
115 };
116
126 {
127 std::string database_file;
128 std::string enzyme;
129 double precursor_tol_lower = 0.0, precursor_tol_upper = 0.0;
131 double fragment_tol = 0.0;
132 std::string fragment_tol_unit;
133 Int min_charge = 0, max_charge = 0;
134 Size missed_cleavages = 0;
135 std::vector<std::string> fixed_mods, variable_mods, ion_series;
136 bool open_search = false;
137 bool calibration_enabled = false;
138 bool peptide_mass_mode = false;
139 bool chunked = false;
140 std::string decoy_mode;
141 double psm_fdr_threshold = 0.0, protein_fdr_threshold = 0.0;
142 Size db_target_proteins = 0;
143 Size db_decoy_proteins = 0;
144 Size indexed_peptides = 0;
145 Size indexed_fragments = 0;
146 double seconds_index_build = 0.0;
147 double seconds_total = 0.0;
148 double seconds_output = 0.0;
149 double seconds_qpx_extended = 0.0;
150 };
151
158 {
160 bool applied = false;
162 std::string skipped_reason;
165 std::string warning;
166 };
167
195
235 {
236 std::vector<SearchResult> per_file;
238
242 std::string decoy_string;
244 bool decoy_is_prefix = true;
246 bool have_decoys = false;
247
251 };
252
255 {
256 std::vector<ProteinIdentification> protein_ids;
260 bool protein_fdr_applied = false;
261 };
262
272 {
273 std::vector<FASTAFile::FASTAEntry> db;
275
285 bool release_fragment_index_after_scoring = false;
286
291 std::string decoy_string;
293 bool decoy_is_prefix = true;
296 bool have_decoys = false;
301 bool electron_ions = false;
302 };
303
325 ExitCodes search(const std::string& in_spectra,
326 const std::string& in_db,
327 std::vector<ProteinIdentification>& prot_ids,
328 PeptideIdentificationList& pep_ids) const;
329
375 static bool applyCompleteSetProteinFDR(std::vector<ProteinIdentification>& protein_ids,
376 PeptideIdentificationList& peptide_ids,
377 const std::string& decoy_string,
378 bool decoy_is_prefix,
379 double protein_fdr,
380 bool remove_decoys,
381 const PeptideIdentificationList& inference_only_psms);
382
400 static std::string inferProteins(std::vector<ProteinIdentification>& protein_ids,
401 const PeptideIdentificationList& peptide_ids,
402 const PeptideIdentificationList& inference_only_psms = PeptideIdentificationList());
403
416
450 static PercolatorRescoring rescoreWithPercolator(std::vector<ProteinIdentification>& protein_ids,
451 PeptideIdentificationList& peptide_ids,
452 int threads);
453
469 static PeakMap loadSpectra(const std::string& filename, const std::function<bool(const MSSpectrum&)>& keep = {});
470
496 bool applyDeferredPsmFDR(const std::vector<ProteinIdentification>& protein_ids,
497 PeptideIdentificationList& peptide_ids,
498 bool rescored,
499 double psm_fdr,
500 PeptideIdentificationList* inference_only_psms = nullptr) const;
501
548 SearchResult searchWithModificationAnalysis(const std::string& in_spectra,
549 const std::string& in_db,
550 const std::string& output_base_name = "") const;
551
570 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
571 std::vector<ProteinIdentification>& prot_ids,
572 PeptideIdentificationList& pep_ids) const;
573
594 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db) const;
595
609 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db, bool electron_ions) const;
610
632 SearchContext& ctx,
633 std::vector<ProteinIdentification>& prot_ids,
634 PeptideIdentificationList& pep_ids) const;
635
647 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
648 const std::string& output_base_name = "") const;
649
701 const std::vector<std::string>& in_spectra_files,
702 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
703 const std::vector<std::string>& output_base_names = {},
704 const std::string& aggregate_base_name = "",
705 bool build_pooled_aggregate = true) const;
706
721 const std::vector<std::string>& in_spectra_files,
722 const std::string& in_db,
723 const std::vector<std::string>& output_base_names = {},
724 const std::string& aggregate_base_name = "",
725 bool build_pooled_aggregate = true) const;
726
772 bool remove_decoys = true) const;
773
777 void setKeepPreFdrPsms(bool keep)
778 {
779 keep_pre_fdr_psms_ = keep;
780 if (!keep) { pre_fdr_peptide_ids_ = PeptideIdentificationList(); }
781 }
782
783 protected:
784 void updateMembers_() override;
785
788 {
790 /*
791 std::string_view sequence;
792 SignedSize peptide_mod_index; ///< enumeration index of the non-RNA peptide modification
793 */
794 // Layout: doubles first, then floats, then int, then uint16_t — minimizes padding (40 bytes excluding AASequence)
795 double score = 0;
796 double delta_mass = 0.0;
797 float prefix_fraction = 0;
798 float suffix_fraction = 0;
799 float mean_error = 0.0f;
800 int isotope_error = 0;
801 uint16_t applied_charge = 0;
802 uint16_t matched_prefix_ions = 0;
803 uint16_t matched_suffix_ions = 0;
804 UInt32 index_peptide = 0;
805
806 static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
807 {
808 if (a.score != b.score) return a.score > b.score;
809 return a.sequence < b.sequence;
810 }
811 };
812
833 {
834 double sum = 0.0;
835 double sumsq = 0.0;
836 double best = 0.0;
837 double second_best = 0.0;
838 Size count = 0;
841 std::unordered_set<std::string> seen_candidates;
842
844 void add(double score)
845 {
846 if (score > best) { second_best = best; best = score; }
847 else if (score > second_best) { second_best = score; }
848 sum += score;
849 sumsq += score * score;
850 ++count;
851 }
852
854 double deltaScore() const { return best - second_best; }
855
877 double zScore() const;
878 };
879
889 {
890 unsigned int min_peaks{3};
891 bool charge_cap_precursor{false};
892 bool sum_intensity{false};
893 };
894
909 static void preprocessSpectra_(PeakMap& exp,
910 double fragment_mass_tolerance,
911 bool fragment_mass_tolerance_unit_ppm,
912 bool deisotope_requested,
913 Size peaks_keep_n,
914 Int peaks_window_top,
915 const std::string& window_type,
916 const DeisotopingSettings_& deisotoping,
917 FragmentIonLikelihoodModel::PeakLists* ion_evidence = nullptr,
918 bool ion_evidence_scored_peaks = false,
919 PeakMap* evidence_spectra = nullptr,
920 PeakMap* query_spectra = nullptr);
921
923 static void preprocessSpectra_(PeakMap& exp,
924 double fragment_mass_tolerance,
925 bool fragment_mass_tolerance_unit_ppm,
926 bool deisotope_requested,
927 Size peaks_keep_n,
928 Int peaks_window_top,
929 const std::string& window_type = "auto");
930
957 void annotateIonPriors_(const PeakMap& spectra,
959 std::vector<ProteinIdentification>& protein_ids,
960 PeptideIdentificationList& peptide_ids) const;
961
964
966 static void filterLocalPeaks_(MSSpectrum& spectrum, Size peaks_per_window);
967
969 enum class DecoyMode_
970 {
971 AUTO,
972 GENERATE,
973 IGNORE
974 };
975
984 {
985 bool generate{false};
986 bool strip_existing{false};
987 bool have_decoys{false};
988 std::string decoy_string;
989 bool is_prefix{true};
990 std::string strip_string;
991 bool strip_is_prefix{true};
992 };
993
1003 const std::vector<FASTAFile::FASTAEntry>& db) const;
1004
1017 Param fragmentIndexParameters_(bool electron_ions = false) const;
1018
1021 struct SpectrumGenerators_;
1022
1024 SpectrumGenerators_ spectrumGenerators_() const;
1025
1028 {
1029 double chance_match_surprise = 0.0;
1030 double mass_competition_evidence = 0.0;
1031 };
1032
1034 static std::vector<double> localPeakDensities_(const MSSpectrum& spectrum);
1035
1055 const MSSpectrum& theoretical,
1056 const std::vector<double>& densities,
1057 double tolerance, bool ppm);
1058
1062 const MSSpectrum& theoretical,
1063 int max_charge,
1064 const std::vector<double>& densities,
1065 double tolerance, bool ppm,
1066 std::vector<double>& alternatives);
1067
1069 static bool isElectronActivated_(const MSSpectrum& spectrum);
1070
1072 Size countElectronActivated_(const PeakMap& spectra) const;
1073
1081 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
1082 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
1083 const DecoyStrategy_& strategy) const;
1084
1086 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
1087 std::vector<FASTAFile::FASTAEntry>&& fasta_db,
1088 const DecoyStrategy_& strategy) const;
1089
1093 SearchContext prepareContext_(std::vector<FASTAFile::FASTAEntry>&& fasta_db, bool electron_ions,
1094 const std::function<const PeakMap*(Size)>& searched_spectra = {}) const;
1095
1099 bool restrictIndexToSpectra_() const { return !calibration_enabled_ && !chimeric_enabled_; }
1100
1103 bool chimericSearch_() const { return chimeric_enabled_ && database_chunk_size_ == 0; }
1104
1107 {
1108 Size parent = 0;
1110 std::vector<UInt32> removed;
1111 };
1112
1137 void searchCoIsolated_(const PeakMap& spectra,
1138 const std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
1139 FragmentIndex& fi,
1140 const std::vector<FASTAFile::FASTAEntry>& db,
1141 const SpectrumGenerators_& generators,
1142 double fragment_tol,
1143 bool fragment_tol_ppm,
1144 bool open_search_mode,
1145 std::vector<CoIsolatedPSM_>& psms,
1146 std::vector<std::vector<AnnotatedHit_>>& hits,
1147 std::vector<CandidatePoolStats_>& pool_stats) const;
1148
1151 static MSSpectrum residualSpectrum_(const MSSpectrum& spectrum, const std::vector<UInt32>& removed, const Precursor& precursor);
1152
1166 std::vector<FASTAFile::FASTAEntry> buildCalibrationSample_(
1167 const std::vector<FASTAFile::FASTAEntry>& full_db) const;
1168
1183 PeakMap& spectra,
1184 std::vector<FASTAFile::FASTAEntry>& full_db,
1185 const DecoyStrategy_& strategy,
1186 std::vector<ProteinIdentification>& protein_ids,
1187 PeptideIdentificationList& peptide_ids) const;
1188
1214 const PeakMap& spectra,
1215 FragmentIndex& fi,
1216 const std::vector<FASTAFile::FASTAEntry>& db,
1217 const SpectrumGenerators_& generators,
1218 double effective_fragment_tol,
1219 bool fragment_mass_tolerance_unit_ppm,
1220 bool open_search_mode,
1221 std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
1222 std::vector<CandidatePoolStats_>& pool_stats,
1223 const std::string& progress_label,
1224 const PeakMap* query_spectra = nullptr) const;
1225
1258 void postProcessHits_(const PeakMap& exp,
1259 std::vector<std::vector<ProSEAlgorithm::AnnotatedHit_> >& annotated_hits,
1260 const std::vector<CandidatePoolStats_>& pool_stats,
1261 std::vector<ProteinIdentification>& protein_ids,
1262 PeptideIdentificationList& peptide_ids,
1263 Size top_hits,
1264 const StringList& modifications_fixed,
1265 const StringList& modifications_variable,
1266 Int peptide_missed_cleavages,
1267 double precursor_mass_tolerance,
1268 double fragment_mass_tolerance,
1269 const std::string& precursor_mass_tolerance_unit_ppm,
1270 const std::string& fragment_mass_tolerance_unit_ppm,
1271 const Int precursor_min_charge,
1272 const Int precursor_max_charge,
1273 const std::string& enzyme,
1274 const std::string& database_name,
1275 const PeakMap* evidence_spectra = nullptr,
1276 const std::vector<Size>* evidence_parent = nullptr) const;
1277
1286 std::vector<ProteinIdentification>& protein_ids,
1287 PeptideIdentificationList& peptide_ids) const;
1288
1289 bool peptdeep_enable_{false};
1292 std::string peptdeep_instrument_{"QE"};
1293 double peptdeep_nce_{-1.0};
1294 std::string peptdeep_rt_model_type_{"b_spline"};
1295 int peptdeep_batch_size_{500};
1296
1300 mutable double precursor_mass_tolerance_lower_{10.0};
1301 mutable double precursor_mass_tolerance_upper_{10.0};
1302 std::string precursor_mass_tolerance_unit_{"ppm"};
1303
1306
1308
1310
1315 bool deisotope_requested_{true};
1316 bool scoring_multiple_charges_{false};
1317 int scoring_max_charge_{2};
1318 bool mass_accuracy_score_{false};
1319 double mass_error_sd_ppm_{7.0};
1320
1322 int scoringMaxCharge_(int precursor_charge) const
1323 {
1324 return scoring_multiple_charges_ ? std::max(1, std::min(precursor_charge - 1, scoring_max_charge_)) : 1;
1325 }
1326 Size peaks_keep_n_{0};
1327 Int peaks_window_top_{20};
1328 std::string peaks_window_type_ {"auto"};
1330 bool query_raw_spectrum_{false};
1331
1333
1335
1337
1338 std::string enzyme_;
1339
1340 DecoyMode_ decoy_mode_{DecoyMode_::AUTO};
1341 std::string decoy_prefix_;
1342
1343 bool rescore_{true};
1344 double fdr_psm_{0.0};
1345 bool fdr_psm_by_scored_charges_{true};
1346 double fdr_protein_{0.0};
1347 double fdr_protein_inference_psm_{0.1};
1348
1350
1351 bool self_trained_ion_priors_{false};
1352 FragmentIonLikelihoodModel::ContextSet ion_prior_model_{FragmentIonLikelihoodModel::ContextSet::RICH};
1353 bool ion_prior_scored_peaks_{false};
1354 int ion_prior_max_fragment_charge_{2};
1355 double ion_prior_train_fdr_{0.01};
1356 Size ion_prior_min_psms_{100};
1357 bool ion_prior_feature_llr_{true};
1358 bool ion_prior_feature_explained_{true};
1359 bool ion_prior_feature_topk_{false};
1360
1364 EnzymaticDigestion::Specificity peptide_enzyme_specificity_{EnzymaticDigestion::SPEC_FULL};
1365
1366
1370 bool isotope_error_observed_minus_theoretical_{true};
1371
1372 bool add_a_ions_{false};
1373 bool add_b_ions_{true};
1374 bool add_c_ions_{false};
1375 bool add_x_ions_{false};
1376 bool add_y_ions_{true};
1377 bool add_z_ions_{false};
1378 bool add_zp1_ions_{false};
1379 bool ions_by_activation_{true};
1380 bool protein_mapping_from_index_{true};
1381
1382 Size database_chunk_size_{0};
1383
1384 bool calibration_enabled_{false};
1385 double calibration_subset_ratio_{0.1};
1386 bool chimeric_enabled_{false};
1387 Size calibration_min_psms_{50};
1388
1397 {
1398 double precursor_shift{0};
1399 double precursor_spread{0};
1400 double cal_lower{0};
1401 double cal_upper{0};
1402 double fragment_tolerance{0};
1403 double fragment_shift{0};
1404 bool extreme_bias{false};
1405 bool success{false};
1406 };
1407
1412
1419
1423 bool keep_pre_fdr_psms_ = false;
1430
1438 mutable double last_mod_match_tolerance_used_{-1.0};
1439
1451 {
1452 if (precursor_mass_tolerance_lower_ <= 0.0) return precursor_mass_tolerance_upper_;
1453 if (precursor_mass_tolerance_upper_ <= 0.0) return precursor_mass_tolerance_lower_;
1454 return std::min(precursor_mass_tolerance_lower_, precursor_mass_tolerance_upper_);
1455 }
1456
1471 FragmentIndex& fragment_index,
1472 const std::vector<FASTAFile::FASTAEntry>& db,
1473 const PeakMap* query_spectra = nullptr) const;
1474
1493 {
1495 static constexpr Size SHARDS = 64;
1497 std::vector<std::string_view> sequences;
1499 std::vector<std::vector<std::pair<UInt32, UInt32>>> occurrences;
1501 std::vector<std::unordered_map<std::string_view, Size>> entries;
1503 std::string fallback_reason;
1504
1506 Size find(std::string_view sequence) const
1507 {
1508 if (entries.empty()) return sequences.size();
1509 const auto& table = entries[std::hash<std::string_view>{}(sequence) % SHARDS];
1510 const auto entry = table.find(sequence);
1511 return entry == table.end() ? sequences.size() : entry->second;
1512 }
1513 };
1514
1525 const std::vector<FASTAFile::FASTAEntry>& db,
1526 std::vector<UInt32> candidates,
1527 const Param& indexer_parameters);
1528
1537 static bool applyProteinMapping_(const ProteinMapping_& mapping,
1538 const std::vector<FASTAFile::FASTAEntry>& db,
1539 const Param& indexer_parameters,
1540 std::vector<ProteinIdentification>& protein_ids,
1541 PeptideIdentificationList& peptide_ids,
1542 std::string& fallback_reason);
1543
1546 static bool accessionHasDecoyMarker_(const std::string& accession,
1547 const std::string& marker, bool is_prefix);
1548
1556 static void poolSearchedFiles_(std::vector<SearchResult>& per_file, bool move_psms, const StringList& in_spectra_files,
1557 std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids);
1558
1565 static void capturePreFdrStats_(const PeptideIdentificationList& peptide_ids,
1566 RunStatistics& stats);
1567
1571 static double maxRetainedScore_(const PeptideIdentificationList& peptide_ids);
1572
1581 PercolatorRescoring applyPsmFDR_(std::vector<ProteinIdentification>& protein_ids,
1582 PeptideIdentificationList& peptide_ids,
1583 bool has_decoys,
1584 RunStatistics& stats,
1585 PeptideIdentificationList* pre_fdr_psms = nullptr,
1586 PeptideIdentificationList* inference_only_psms = nullptr) const;
1587
1590 void collectInferenceOnlyPsms_(const PeptideIdentificationList& peptide_ids, double psm_fdr,
1591 PeptideIdentificationList& inference_only_psms) const;
1592
1598 void collectRunStatistics_(const PeakMap& spectra,
1599 const std::vector<ProteinIdentification>& protein_ids,
1600 const PeptideIdentificationList& peptide_ids,
1601 RunStatistics& stats) const;
1602
1606 {
1607 Size ms2 = 0;
1608 Size profile = 0;
1609 Size charge_out_of_range = 0;
1610 };
1611
1613 SpectraCounts_ countSpectra_(const PeakMap& spectra) const;
1614
1619 void preprocessSearchedSpectra_(PeakMap& spectra, const std::string& input,
1621 PeakMap* evidence_spectra, PeakMap* query_spectra) const;
1622
1623 public:
1634 const PeptideIdentificationList& peptide_ids,
1635 const std::string& enzyme,
1636 bool fdr_applied);
1637
1644 static std::string renderTotalTime(const SharedSearchStats& sh);
1645
1650 static void renderRunSummary(const RunStatistics& stats,
1651 const SharedSearchStats& shared,
1653 bool is_open_search,
1654 std::ostream& os);
1655
1659 std::ostream& os);
1660
1667 static std::string renderRunSummaryYaml(
1668 const MultiFileSearchResult& mfres,
1669 const std::vector<std::pair<std::string, std::vector<std::string>>>& manifest,
1670 Size files_failed,
1671 Size files_total);
1672
1673 private:
1674
1677 {
1678 return FragmentIndex::isOpenSearchMode(precursor_mass_tolerance_lower_,
1679 precursor_mass_tolerance_upper_,
1680 precursor_mass_tolerance_unit_ == "ppm");
1681 }
1682};
1683
1684} // 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:36
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:106
Management and storage of parameters / INI files.
Definition Param.h:46
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Precursor meta information.
Definition Precursor.h:37
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:1338
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 MSSpectrum residualSpectrum_(const MSSpectrum &spectrum, const std::vector< UInt32 > &removed, const Precursor &precursor)
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:1422
static std::string inferProteins(std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const PeptideIdentificationList &inference_only_psms=PeptideIdentificationList())
The protein inference of the protein FDR (applyCompleteSetProteinFDR()) and of mergeFileResults().
FragmentIndex fragment_index
Definition ProSEAlgorithm.h:274
std::string fragment_tol_unit
Definition ProSEAlgorithm.h:132
Size peptide_max_size_
Definition ProSEAlgorithm.h:1362
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:186
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:1305
bool applyDeferredPsmFDR(const std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool rescored, double psm_fdr, PeptideIdentificationList *inference_only_psms=nullptr) const
Apply the PSM-level FDR that a search with Percolator rescoring deferred.
Size precursor_min_charge_
Definition ProSEAlgorithm.h:1304
std::string decoy_prefix_
Definition ProSEAlgorithm.h:1341
RunStatistics stats
Definition ProSEAlgorithm.h:184
PercolatorRescoring applyPsmFDR_(std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool has_decoys, RunStatistics &stats, PeptideIdentificationList *pre_fdr_psms=nullptr, PeptideIdentificationList *inference_only_psms=nullptr) const
Size report_top_hits_
Definition ProSEAlgorithm.h:1367
Size modifications_max_variable_mods_per_peptide_
Definition ProSEAlgorithm.h:1336
static void renderModificationSummary(const OpenSearchModificationAnalysis::OpenSearchAnalysisResult &mod_analysis, std::ostream &os)
std::string warning
Definition ProSEAlgorithm.h:165
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:777
Precursor precursor
the co-isolated precursor: that of the spectrum with its m/z and charge
Definition ProSEAlgorithm.h:1109
void searchCoIsolated_(const PeakMap &spectra, const std::vector< std::vector< AnnotatedHit_ > > &annotated_hits, FragmentIndex &fi, const std::vector< FASTAFile::FASTAEntry > &db, const SpectrumGenerators_ &generators, double fragment_tol, bool fragment_tol_ppm, bool open_search_mode, std::vector< CoIsolatedPSM_ > &psms, std::vector< std::vector< AnnotatedHit_ > > &hits, std::vector< CandidatePoolStats_ > &pool_stats) const
Search the precursors co-isolated with the selected one in what the spectrum's other PSMs leave of it...
std::string input_file
spectrum file this run searched (basename or path)
Definition ProSEAlgorithm.h:85
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
Definition ProSEAlgorithm.h:187
std::map< Int, Size > charge_histogram
precursor charge -> PSM count
Definition ProSEAlgorithm.h:96
SpectrumGenerators_ spectrumGenerators_() const
Generators for scoring, annotation and calibration, configured from the ions:* parameters.
StringList modifications_fixed_
Definition ProSEAlgorithm.h:1332
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< UInt32 > removed
the peaks of the spectrum that its residual spectrum leaves out (ascending)
Definition ProSEAlgorithm.h:1110
std::vector< ProteinIdentification > protein_ids
Definition ProSEAlgorithm.h:180
bool restrictIndexToSpectra_() const
Definition ProSEAlgorithm.h:1099
bool chimericSearch_() const
Definition ProSEAlgorithm.h:1103
Size peptide_min_size_
Definition ProSEAlgorithm.h:1361
SpectraCounts_ countSpectra_(const PeakMap &spectra) const
Helper: the SpectraCounts_ of spectra.
std::vector< FASTAFile::FASTAEntry > buildDecoyAugmentedDB_(const std::vector< FASTAFile::FASTAEntry > &fasta_db, const DecoyStrategy_ &strategy) const
Build the searched database according to strategy.
static bool applyCompleteSetProteinFDR(std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, const std::string &decoy_string, bool decoy_is_prefix, double protein_fdr, bool remove_decoys, const PeptideIdentificationList &inference_only_psms)
Finalize protein-level FDR on a COMPLETE protein set (a single input file, or a merged cross-file agg...
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:237
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:127
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:990
std::map< Size, Size > missed_cleavage_histogram
missed cleavages -> PSM count
Definition ProSEAlgorithm.h:97
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:1418
std::string fragment_mass_tolerance_unit_
Definition ProSEAlgorithm.h:1309
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:1349
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.
Param fragmentIndexParameters_(bool electron_ions=false) const
ProSE parameters made safe to hand to a FragmentIndex.
static PeakMap loadSpectra(const std::string &filename, const std::function< bool(const MSSpectrum &)> &keep={})
The MS2 spectra of a spectrum file as the searches of this class read them.
OpenSearchModificationAnalysis::OpenSearchAnalysisResult modification_analysis
Definition ProSEAlgorithm.h:182
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:273
static std::string renderTotalTime(const SharedSearchStats &sh)
The total time of a run, by part: "total <s>s | search of the file(s) <s>s | outputs <s>s (of ...
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:250
bool isOpenSearchMode_() const
Helper function to determine if open search should be used based on tolerance.
Definition ProSEAlgorithm.h:1676
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.
PeptideIdentificationList inference_only_peptide_ids
Definition ProSEAlgorithm.h:193
void collectInferenceOnlyPsms_(const PeptideIdentificationList &peptide_ids, double psm_fdr, PeptideIdentificationList &inference_only_psms) const
std::string decoy_string
Definition ProSEAlgorithm.h:242
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:1329
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:140
PeptideIdentificationList peptide_ids
Definition ProSEAlgorithm.h:181
std::string enzyme
Definition ProSEAlgorithm.h:128
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:162
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
ExitCodes
Exit codes.
Definition ProSEAlgorithm.h:66
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 std::vector< Size > *evidence_parent=nullptr) const
Filter and annotate search results.
StringList modifications_variable_
Definition ProSEAlgorithm.h:1334
static double maxRetainedScore_(const PeptideIdentificationList &peptide_ids)
PeptideIdentificationList pre_fdr_peptide_ids_
Definition ProSEAlgorithm.h:1426
std::vector< SearchResult > per_file
Definition ProSEAlgorithm.h:236
double fragment_mass_tolerance_
Definition ProSEAlgorithm.h:1307
PeptideIdentificationList inference_only_peptide_ids_
Definition ProSEAlgorithm.h:1429
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:1322
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:1363
CalibrationResult_ last_calibration_result_
Definition ProSEAlgorithm.h:1411
double computeModMatchTolerance_() const
Definition ProSEAlgorithm.h:1450
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:135
std::string peptdeep_ms2_model_
Definition ProSEAlgorithm.h:1290
std::string precursor_tol_unit
Definition ProSEAlgorithm.h:130
DecoyMode_
How decoys are obtained/recognised for a search (parameter "decoys").
Definition ProSEAlgorithm.h:970
std::string peptdeep_rt_model_
Definition ProSEAlgorithm.h:1291
void preprocessSearchedSpectra_(PeakMap &spectra, const std::string &input, FragmentIonLikelihoodModel::PeakLists &ion_evidence, PeakMap *evidence_spectra, PeakMap *query_spectra) const
Result of a calibration pass.
Definition ProSEAlgorithm.h:1397
The PSM of a precursor co-isolated with the selected one (chimeric:enabled), until its residual spect...
Definition ProSEAlgorithm.h:1107
Resolved decoy handling for one concrete input database.
Definition ProSEAlgorithm.h:984
MS2 deisotoping rule of preprocessSpectra_().
Definition ProSEAlgorithm.h:889
Local fragment evidence of one candidate (annotate:local_fragment_evidence).
Definition ProSEAlgorithm.h:1028
The pooled evaluation of a multi-file search (the ProSE tool's -out_merged).
Definition ProSEAlgorithm.h:255
Multi-file search result bundle.
Definition ProSEAlgorithm.h:235
Outcome of the Percolator rescoring of one search run (see rescoreWithPercolator() and the parameter ...
Definition ProSEAlgorithm.h:158
Per-run identification statistics for the end-of-search report.
Definition ProSEAlgorithm.h:84
Prepared per-database state shared across multiple spectrum files.
Definition ProSEAlgorithm.h:272
Comprehensive search result including modification analysis.
Definition ProSEAlgorithm.h:178
Configuration, database and fragment-index facts shared across all input files of one ProSE invocatio...
Definition ProSEAlgorithm.h:126
Definition ProSEAlgorithm.h:1606
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:788
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition ProSEAlgorithm.h:806
double score
main score
Definition ProSEAlgorithm.h:795
AASequence sequence
Definition ProSEAlgorithm.h:789
Running summary of the complete candidate pool of one spectrum.
Definition ProSEAlgorithm.h:833
std::unordered_set< std::string > seen_candidates
Definition ProSEAlgorithm.h:841
void add(double score)
Fold one freshly scored candidate into the summary.
Definition ProSEAlgorithm.h:844
double deltaScore() const
Best minus runner-up over the full pool.
Definition ProSEAlgorithm.h:854
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:1493
std::vector< std::string_view > sequences
The unmodified hit sequences (views into the database), one entry each.
Definition ProSEAlgorithm.h:1497
std::string fallback_reason
Why PeptideIndexing has to run instead; empty if the mapping applies.
Definition ProSEAlgorithm.h:1503
Size find(std::string_view sequence) const
The entry of sequence, or sequences.size() if there is none.
Definition ProSEAlgorithm.h:1506
std::vector< std::vector< std::pair< UInt32, UInt32 > > > occurrences
Per entry: its occurrences {protein index, position}, ascending (PeptideIndexing's evidence order)
Definition ProSEAlgorithm.h:1499
std::vector< std::unordered_map< std::string_view, Size > > entries
Sequence -> entry, in SHARDS hash tables.
Definition ProSEAlgorithm.h:1501