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
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 matched_spectra = 0;
88 Size target_psms = 0;
89 Size decoy_psms = 0;
90 bool fdr_applied = false;
91 double achieved_psm_fdr = -1.0;
92 Size unique_peptides = 0;
93 Size unique_proteins = 0;
94 std::map<Int, Size> charge_histogram;
95 std::map<Size, Size> missed_cleavage_histogram;
96 bool score_stats_valid = false;
97 double hyperscore_min = 0.0;
98 double hyperscore_median = 0.0;
99 double hyperscore_max = 0.0;
100 bool prec_tol_valid = false;
101 double prec_err_median = 0.0, prec_err_mad = 0.0, prec_err_recommended = 0.0;
102 bool frag_tol_valid = false;
103 double frag_err_median = 0.0, frag_err_mad = 0.0, frag_err_recommended = 0.0;
104 double seconds_search = 0.0;
105 double seconds_calibration = 0.0;
106 double seconds_fdr = 0.0;
107 };
108
118 {
119 std::string database_file;
120 std::string enzyme;
121 double precursor_tol_lower = 0.0, precursor_tol_upper = 0.0;
123 double fragment_tol = 0.0;
124 std::string fragment_tol_unit;
125 Int min_charge = 0, max_charge = 0;
126 Size missed_cleavages = 0;
127 std::vector<std::string> fixed_mods, variable_mods, ion_series;
128 bool open_search = false;
129 bool calibration_enabled = false;
130 bool peptide_mass_mode = false;
131 bool chunked = false;
132 std::string decoy_mode;
133 double psm_fdr_threshold = 0.0, protein_fdr_threshold = 0.0;
134 Size db_target_proteins = 0;
135 Size db_decoy_proteins = 0;
136 Size indexed_peptides = 0;
137 Size indexed_fragments = 0;
138 double seconds_index_build = 0.0;
139 double seconds_total = 0.0;
140 };
141
148 {
150 bool applied = false;
152 std::string skipped_reason;
155 std::string warning;
156 };
157
185
225 {
226 std::vector<SearchResult> per_file;
228
232 std::string decoy_string;
234 bool decoy_is_prefix = true;
236 bool have_decoys = false;
237
241 };
242
245 {
246 std::vector<ProteinIdentification> protein_ids;
250 bool protein_fdr_applied = false;
251 };
252
262 {
263 std::vector<FASTAFile::FASTAEntry> db;
265
275 bool release_fragment_index_after_scoring = false;
276
281 std::string decoy_string;
283 bool decoy_is_prefix = true;
286 bool have_decoys = false;
291 bool electron_ions = false;
292 };
293
315 ExitCodes search(const std::string& in_spectra,
316 const std::string& in_db,
317 std::vector<ProteinIdentification>& prot_ids,
318 PeptideIdentificationList& pep_ids) const;
319
365 static bool applyCompleteSetProteinFDR(std::vector<ProteinIdentification>& protein_ids,
366 PeptideIdentificationList& peptide_ids,
367 const std::string& decoy_string,
368 bool decoy_is_prefix,
369 double protein_fdr,
370 bool remove_decoys,
371 const PeptideIdentificationList& inference_only_psms);
372
390 static std::string inferProteins(std::vector<ProteinIdentification>& protein_ids,
391 const PeptideIdentificationList& peptide_ids,
392 const PeptideIdentificationList& inference_only_psms = PeptideIdentificationList());
393
406
440 static PercolatorRescoring rescoreWithPercolator(std::vector<ProteinIdentification>& protein_ids,
441 PeptideIdentificationList& peptide_ids,
442 int threads);
443
469 bool applyDeferredPsmFDR(const std::vector<ProteinIdentification>& protein_ids,
470 PeptideIdentificationList& peptide_ids,
471 bool rescored,
472 double psm_fdr,
473 PeptideIdentificationList* inference_only_psms = nullptr) const;
474
521 SearchResult searchWithModificationAnalysis(const std::string& in_spectra,
522 const std::string& in_db,
523 const std::string& output_base_name = "") const;
524
543 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
544 std::vector<ProteinIdentification>& prot_ids,
545 PeptideIdentificationList& pep_ids) const;
546
567 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db) const;
568
582 SearchContext prepareContext(const std::vector<FASTAFile::FASTAEntry>& fasta_db, bool electron_ions) const;
583
605 SearchContext& ctx,
606 std::vector<ProteinIdentification>& prot_ids,
607 PeptideIdentificationList& pep_ids) const;
608
620 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
621 const std::string& output_base_name = "") const;
622
674 const std::vector<std::string>& in_spectra_files,
675 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
676 const std::vector<std::string>& output_base_names = {},
677 const std::string& aggregate_base_name = "",
678 bool build_pooled_aggregate = true) const;
679
694 const std::vector<std::string>& in_spectra_files,
695 const std::string& in_db,
696 const std::vector<std::string>& output_base_names = {},
697 const std::string& aggregate_base_name = "",
698 bool build_pooled_aggregate = true) const;
699
745 bool remove_decoys = true) const;
746
750 void setKeepPreFdrPsms(bool keep)
751 {
752 keep_pre_fdr_psms_ = keep;
753 if (!keep) { pre_fdr_peptide_ids_ = PeptideIdentificationList(); }
754 }
755
756 protected:
757 void updateMembers_() override;
758
761 {
763 /*
764 std::string_view sequence;
765 SignedSize peptide_mod_index; ///< enumeration index of the non-RNA peptide modification
766 */
767 // Layout: doubles first, then floats, then int, then uint16_t — minimizes padding (40 bytes excluding AASequence)
768 double score = 0;
769 double delta_mass = 0.0;
770 float prefix_fraction = 0;
771 float suffix_fraction = 0;
772 float mean_error = 0.0f;
773 int isotope_error = 0;
774 uint16_t applied_charge = 0;
775 uint16_t matched_prefix_ions = 0;
776 uint16_t matched_suffix_ions = 0;
777 UInt32 index_peptide = 0;
778
779 static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
780 {
781 if (a.score != b.score) return a.score > b.score;
782 return a.sequence < b.sequence;
783 }
784 };
785
806 {
807 double sum = 0.0;
808 double sumsq = 0.0;
809 double best = 0.0;
810 double second_best = 0.0;
811 Size count = 0;
814 std::unordered_set<std::string> seen_candidates;
815
817 void add(double score)
818 {
819 if (score > best) { second_best = best; best = score; }
820 else if (score > second_best) { second_best = score; }
821 sum += score;
822 sumsq += score * score;
823 ++count;
824 }
825
827 double deltaScore() const { return best - second_best; }
828
850 double zScore() const;
851 };
852
862 {
863 unsigned int min_peaks{3};
864 bool charge_cap_precursor{false};
865 bool sum_intensity{false};
866 };
867
882 static void preprocessSpectra_(PeakMap& exp,
883 double fragment_mass_tolerance,
884 bool fragment_mass_tolerance_unit_ppm,
885 bool deisotope_requested,
886 Size peaks_keep_n,
887 Int peaks_window_top,
888 const std::string& window_type,
889 const DeisotopingSettings_& deisotoping,
890 FragmentIonLikelihoodModel::PeakLists* ion_evidence = nullptr,
891 bool ion_evidence_scored_peaks = false,
892 PeakMap* evidence_spectra = nullptr,
893 PeakMap* query_spectra = nullptr);
894
896 static void preprocessSpectra_(PeakMap& exp,
897 double fragment_mass_tolerance,
898 bool fragment_mass_tolerance_unit_ppm,
899 bool deisotope_requested,
900 Size peaks_keep_n,
901 Int peaks_window_top,
902 const std::string& window_type = "auto");
903
930 void annotateIonPriors_(const PeakMap& spectra,
932 std::vector<ProteinIdentification>& protein_ids,
933 PeptideIdentificationList& peptide_ids) const;
934
937
939 static void filterLocalPeaks_(MSSpectrum& spectrum, Size peaks_per_window);
940
942 enum class DecoyMode_
943 {
944 AUTO,
945 GENERATE,
946 IGNORE
947 };
948
957 {
958 bool generate{false};
959 bool strip_existing{false};
960 bool have_decoys{false};
961 std::string decoy_string;
962 bool is_prefix{true};
963 std::string strip_string;
964 bool strip_is_prefix{true};
965 };
966
976 const std::vector<FASTAFile::FASTAEntry>& db) const;
977
990 Param fragmentIndexParameters_(bool electron_ions = false) const;
991
994 struct SpectrumGenerators_;
995
997 SpectrumGenerators_ spectrumGenerators_() const;
998
1001 {
1002 double chance_match_surprise = 0.0;
1003 double mass_competition_evidence = 0.0;
1004 };
1005
1007 static std::vector<double> localPeakDensities_(const MSSpectrum& spectrum);
1008
1028 const MSSpectrum& theoretical,
1029 const std::vector<double>& densities,
1030 double tolerance, bool ppm);
1031
1035 const MSSpectrum& theoretical,
1036 int max_charge,
1037 const std::vector<double>& densities,
1038 double tolerance, bool ppm,
1039 std::vector<double>& alternatives);
1040
1042 static bool isElectronActivated_(const MSSpectrum& spectrum);
1043
1045 Size countElectronActivated_(const PeakMap& spectra) const;
1046
1054 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
1055 const std::vector<FASTAFile::FASTAEntry>& fasta_db,
1056 const DecoyStrategy_& strategy) const;
1057
1059 std::vector<FASTAFile::FASTAEntry> buildDecoyAugmentedDB_(
1060 std::vector<FASTAFile::FASTAEntry>&& fasta_db,
1061 const DecoyStrategy_& strategy) const;
1062
1066 SearchContext prepareContext_(std::vector<FASTAFile::FASTAEntry>&& fasta_db, bool electron_ions,
1067 const std::function<const PeakMap*(Size)>& searched_spectra = {}) const;
1068
1072 bool restrictIndexToSpectra_() const { return !calibration_enabled_ && !chimeric_enabled_; }
1073
1076 bool chimericSearch_() const { return chimeric_enabled_ && database_chunk_size_ == 0; }
1077
1080 {
1081 Size parent = 0;
1083 std::vector<UInt32> removed;
1084 };
1085
1110 void searchCoIsolated_(const PeakMap& spectra,
1111 const std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
1112 FragmentIndex& fi,
1113 const std::vector<FASTAFile::FASTAEntry>& db,
1114 const SpectrumGenerators_& generators,
1115 double fragment_tol,
1116 bool fragment_tol_ppm,
1117 bool open_search_mode,
1118 std::vector<CoIsolatedPSM_>& psms,
1119 std::vector<std::vector<AnnotatedHit_>>& hits,
1120 std::vector<CandidatePoolStats_>& pool_stats) const;
1121
1124 static MSSpectrum residualSpectrum_(const MSSpectrum& spectrum, const std::vector<UInt32>& removed, const Precursor& precursor);
1125
1139 std::vector<FASTAFile::FASTAEntry> buildCalibrationSample_(
1140 const std::vector<FASTAFile::FASTAEntry>& full_db) const;
1141
1156 PeakMap& spectra,
1157 std::vector<FASTAFile::FASTAEntry>& full_db,
1158 const DecoyStrategy_& strategy,
1159 std::vector<ProteinIdentification>& protein_ids,
1160 PeptideIdentificationList& peptide_ids) const;
1161
1187 const PeakMap& spectra,
1188 FragmentIndex& fi,
1189 const std::vector<FASTAFile::FASTAEntry>& db,
1190 const SpectrumGenerators_& generators,
1191 double effective_fragment_tol,
1192 bool fragment_mass_tolerance_unit_ppm,
1193 bool open_search_mode,
1194 std::vector<std::vector<AnnotatedHit_>>& annotated_hits,
1195 std::vector<CandidatePoolStats_>& pool_stats,
1196 const std::string& progress_label,
1197 const PeakMap* query_spectra = nullptr) const;
1198
1231 void postProcessHits_(const PeakMap& exp,
1232 std::vector<std::vector<ProSEAlgorithm::AnnotatedHit_> >& annotated_hits,
1233 const std::vector<CandidatePoolStats_>& pool_stats,
1234 std::vector<ProteinIdentification>& protein_ids,
1235 PeptideIdentificationList& peptide_ids,
1236 Size top_hits,
1237 const StringList& modifications_fixed,
1238 const StringList& modifications_variable,
1239 Int peptide_missed_cleavages,
1240 double precursor_mass_tolerance,
1241 double fragment_mass_tolerance,
1242 const std::string& precursor_mass_tolerance_unit_ppm,
1243 const std::string& fragment_mass_tolerance_unit_ppm,
1244 const Int precursor_min_charge,
1245 const Int precursor_max_charge,
1246 const std::string& enzyme,
1247 const std::string& database_name,
1248 const PeakMap* evidence_spectra = nullptr,
1249 const std::vector<Size>* evidence_parent = nullptr) const;
1250
1259 std::vector<ProteinIdentification>& protein_ids,
1260 PeptideIdentificationList& peptide_ids) const;
1261
1262 bool peptdeep_enable_{false};
1265 std::string peptdeep_instrument_{"QE"};
1266 double peptdeep_nce_{-1.0};
1267 std::string peptdeep_rt_model_type_{"b_spline"};
1268 int peptdeep_batch_size_{500};
1269
1273 mutable double precursor_mass_tolerance_lower_{10.0};
1274 mutable double precursor_mass_tolerance_upper_{10.0};
1275 std::string precursor_mass_tolerance_unit_{"ppm"};
1276
1279
1281
1283
1288 bool deisotope_requested_{true};
1289 bool scoring_multiple_charges_{false};
1290 int scoring_max_charge_{2};
1291 bool mass_accuracy_score_{false};
1292 double mass_error_sd_ppm_{7.0};
1293
1295 int scoringMaxCharge_(int precursor_charge) const
1296 {
1297 return scoring_multiple_charges_ ? std::max(1, std::min(precursor_charge - 1, scoring_max_charge_)) : 1;
1298 }
1299 Size peaks_keep_n_{0};
1300 Int peaks_window_top_{20};
1301 std::string peaks_window_type_ {"auto"};
1303 bool query_raw_spectrum_{false};
1304
1306
1308
1310
1311 std::string enzyme_;
1312
1313 DecoyMode_ decoy_mode_{DecoyMode_::AUTO};
1314 std::string decoy_prefix_;
1315
1316 bool rescore_{true};
1317 double fdr_psm_{0.0};
1318 bool fdr_psm_by_scored_charges_{true};
1319 double fdr_protein_{0.0};
1320 double fdr_protein_inference_psm_{0.1};
1321
1323
1324 bool self_trained_ion_priors_{false};
1325 FragmentIonLikelihoodModel::ContextSet ion_prior_model_{FragmentIonLikelihoodModel::ContextSet::RICH};
1326 bool ion_prior_scored_peaks_{false};
1327 int ion_prior_max_fragment_charge_{2};
1328 double ion_prior_train_fdr_{0.01};
1329 Size ion_prior_min_psms_{100};
1330 bool ion_prior_feature_llr_{true};
1331 bool ion_prior_feature_explained_{true};
1332 bool ion_prior_feature_topk_{false};
1333
1337 EnzymaticDigestion::Specificity peptide_enzyme_specificity_{EnzymaticDigestion::SPEC_FULL};
1338
1339 std::string peptide_motif_;
1340
1344 bool isotope_error_observed_minus_theoretical_{true};
1345
1346 bool add_a_ions_{false};
1347 bool add_b_ions_{true};
1348 bool add_c_ions_{false};
1349 bool add_x_ions_{false};
1350 bool add_y_ions_{true};
1351 bool add_z_ions_{false};
1352 bool add_zp1_ions_{false};
1353 bool ions_by_activation_{true};
1354 bool protein_mapping_from_index_{true};
1355
1356 Size database_chunk_size_{0};
1357
1358 bool calibration_enabled_{false};
1359 double calibration_subset_ratio_{0.1};
1360 bool chimeric_enabled_{false};
1361 Size calibration_min_psms_{50};
1362
1371 {
1372 double precursor_shift{0};
1373 double precursor_spread{0};
1374 double cal_lower{0};
1375 double cal_upper{0};
1376 double fragment_tolerance{0};
1377 double fragment_shift{0};
1378 bool extreme_bias{false};
1379 bool success{false};
1380 };
1381
1386
1393
1397 bool keep_pre_fdr_psms_ = false;
1404
1412 mutable double last_mod_match_tolerance_used_{-1.0};
1413
1425 {
1426 if (precursor_mass_tolerance_lower_ <= 0.0) return precursor_mass_tolerance_upper_;
1427 if (precursor_mass_tolerance_upper_ <= 0.0) return precursor_mass_tolerance_lower_;
1428 return std::min(precursor_mass_tolerance_lower_, precursor_mass_tolerance_upper_);
1429 }
1430
1445 FragmentIndex& fragment_index,
1446 const std::vector<FASTAFile::FASTAEntry>& db,
1447 const PeakMap* query_spectra = nullptr) const;
1448
1467 {
1469 static constexpr Size SHARDS = 64;
1471 std::vector<std::string_view> sequences;
1473 std::vector<std::vector<std::pair<UInt32, UInt32>>> occurrences;
1475 std::vector<std::unordered_map<std::string_view, Size>> entries;
1477 std::string fallback_reason;
1478
1480 Size find(std::string_view sequence) const
1481 {
1482 if (entries.empty()) return sequences.size();
1483 const auto& table = entries[std::hash<std::string_view>{}(sequence) % SHARDS];
1484 const auto entry = table.find(sequence);
1485 return entry == table.end() ? sequences.size() : entry->second;
1486 }
1487 };
1488
1499 const std::vector<FASTAFile::FASTAEntry>& db,
1500 std::vector<UInt32> candidates,
1501 const Param& indexer_parameters);
1502
1511 static bool applyProteinMapping_(const ProteinMapping_& mapping,
1512 const std::vector<FASTAFile::FASTAEntry>& db,
1513 const Param& indexer_parameters,
1514 std::vector<ProteinIdentification>& protein_ids,
1515 PeptideIdentificationList& peptide_ids,
1516 std::string& fallback_reason);
1517
1520 static bool accessionHasDecoyMarker_(const std::string& accession,
1521 const std::string& marker, bool is_prefix);
1522
1530 static void poolSearchedFiles_(std::vector<SearchResult>& per_file, bool move_psms, const StringList& in_spectra_files,
1531 std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids);
1532
1539 static void capturePreFdrStats_(const PeptideIdentificationList& peptide_ids,
1540 RunStatistics& stats);
1541
1545 static double maxRetainedScore_(const PeptideIdentificationList& peptide_ids);
1546
1555 PercolatorRescoring applyPsmFDR_(std::vector<ProteinIdentification>& protein_ids,
1556 PeptideIdentificationList& peptide_ids,
1557 bool has_decoys,
1558 RunStatistics& stats,
1559 PeptideIdentificationList* pre_fdr_psms = nullptr,
1560 PeptideIdentificationList* inference_only_psms = nullptr) const;
1561
1564 void collectInferenceOnlyPsms_(const PeptideIdentificationList& peptide_ids, double psm_fdr,
1565 PeptideIdentificationList& inference_only_psms) const;
1566
1572 void collectRunStatistics_(const PeakMap& spectra,
1573 const std::vector<ProteinIdentification>& protein_ids,
1574 const PeptideIdentificationList& peptide_ids,
1575 RunStatistics& stats) const;
1576
1577 public:
1588 const PeptideIdentificationList& peptide_ids,
1589 const std::string& enzyme,
1590 bool fdr_applied);
1591
1596 static void renderRunSummary(const RunStatistics& stats,
1597 const SharedSearchStats& shared,
1599 bool is_open_search,
1600 std::ostream& os);
1601
1605 std::ostream& os);
1606
1613 static std::string renderRunSummaryYaml(
1614 const MultiFileSearchResult& mfres,
1615 const std::vector<std::pair<std::string, std::vector<std::string>>>& manifest,
1616 Size files_failed,
1617 Size files_total);
1618
1619 private:
1620
1623 {
1624 return FragmentIndex::isOpenSearchMode(precursor_mass_tolerance_lower_,
1625 precursor_mass_tolerance_upper_,
1626 precursor_mass_tolerance_unit_ == "ppm");
1627 }
1628};
1629
1630} // 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
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:1311
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:1396
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:264
std::string fragment_tol_unit
Definition ProSEAlgorithm.h:124
Size peptide_max_size_
Definition ProSEAlgorithm.h:1335
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:176
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:1278
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:1277
std::string decoy_prefix_
Definition ProSEAlgorithm.h:1314
RunStatistics stats
Definition ProSEAlgorithm.h:174
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:1341
Size modifications_max_variable_mods_per_peptide_
Definition ProSEAlgorithm.h:1309
static void renderModificationSummary(const OpenSearchModificationAnalysis::OpenSearchAnalysisResult &mod_analysis, std::ostream &os)
std::string warning
Definition ProSEAlgorithm.h:155
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:750
std::string peptide_motif_
Definition ProSEAlgorithm.h:1339
Precursor precursor
the co-isolated precursor: that of the spectrum with its m/z and charge
Definition ProSEAlgorithm.h:1082
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:177
std::map< Int, Size > charge_histogram
precursor charge -> PSM count
Definition ProSEAlgorithm.h:94
SpectrumGenerators_ spectrumGenerators_() const
Generators for scoring, annotation and calibration, configured from the ions:* parameters.
StringList modifications_fixed_
Definition ProSEAlgorithm.h:1305
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:1083
std::vector< ProteinIdentification > protein_ids
Definition ProSEAlgorithm.h:170
bool restrictIndexToSpectra_() const
Definition ProSEAlgorithm.h:1072
bool chimericSearch_() const
Definition ProSEAlgorithm.h:1076
Size peptide_min_size_
Definition ProSEAlgorithm.h:1334
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:227
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:119
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:963
std::map< Size, Size > missed_cleavage_histogram
missed cleavages -> PSM count
Definition ProSEAlgorithm.h:95
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:1392
std::string fragment_mass_tolerance_unit_
Definition ProSEAlgorithm.h:1282
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:1322
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.
OpenSearchModificationAnalysis::OpenSearchAnalysisResult modification_analysis
Definition ProSEAlgorithm.h:172
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:263
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:240
bool isOpenSearchMode_() const
Helper function to determine if open search should be used based on tolerance.
Definition ProSEAlgorithm.h:1622
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:183
void collectInferenceOnlyPsms_(const PeptideIdentificationList &peptide_ids, double psm_fdr, PeptideIdentificationList &inference_only_psms) const
std::string decoy_string
Definition ProSEAlgorithm.h:232
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:1302
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:132
PeptideIdentificationList peptide_ids
Definition ProSEAlgorithm.h:171
std::string enzyme
Definition ProSEAlgorithm.h:120
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:152
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:1307
static double maxRetainedScore_(const PeptideIdentificationList &peptide_ids)
PeptideIdentificationList pre_fdr_peptide_ids_
Definition ProSEAlgorithm.h:1400
std::vector< SearchResult > per_file
Definition ProSEAlgorithm.h:226
double fragment_mass_tolerance_
Definition ProSEAlgorithm.h:1280
PeptideIdentificationList inference_only_peptide_ids_
Definition ProSEAlgorithm.h:1403
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:1295
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:1336
CalibrationResult_ last_calibration_result_
Definition ProSEAlgorithm.h:1385
double computeModMatchTolerance_() const
Definition ProSEAlgorithm.h:1424
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:127
std::string peptdeep_ms2_model_
Definition ProSEAlgorithm.h:1263
std::string precursor_tol_unit
Definition ProSEAlgorithm.h:122
DecoyMode_
How decoys are obtained/recognised for a search (parameter "decoys").
Definition ProSEAlgorithm.h:943
std::string peptdeep_rt_model_
Definition ProSEAlgorithm.h:1264
Result of a calibration pass.
Definition ProSEAlgorithm.h:1371
The PSM of a precursor co-isolated with the selected one (chimeric:enabled), until its residual spect...
Definition ProSEAlgorithm.h:1080
Resolved decoy handling for one concrete input database.
Definition ProSEAlgorithm.h:957
MS2 deisotoping rule of preprocessSpectra_().
Definition ProSEAlgorithm.h:862
Local fragment evidence of one candidate (annotate:local_fragment_evidence).
Definition ProSEAlgorithm.h:1001
The pooled evaluation of a multi-file search (the ProSE tool's -out_merged).
Definition ProSEAlgorithm.h:245
Multi-file search result bundle.
Definition ProSEAlgorithm.h:225
Outcome of the Percolator rescoring of one search run (see rescoreWithPercolator() and the parameter ...
Definition ProSEAlgorithm.h:148
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:262
Comprehensive search result including modification analysis.
Definition ProSEAlgorithm.h:168
Configuration, database and fragment-index facts shared across all input files of one ProSE invocatio...
Definition ProSEAlgorithm.h:118
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:761
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition ProSEAlgorithm.h:779
double score
main score
Definition ProSEAlgorithm.h:768
AASequence sequence
Definition ProSEAlgorithm.h:762
Running summary of the complete candidate pool of one spectrum.
Definition ProSEAlgorithm.h:806
std::unordered_set< std::string > seen_candidates
Definition ProSEAlgorithm.h:814
void add(double score)
Fold one freshly scored candidate into the summary.
Definition ProSEAlgorithm.h:817
double deltaScore() const
Best minus runner-up over the full pool.
Definition ProSEAlgorithm.h:827
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:1467
std::vector< std::string_view > sequences
The unmodified hit sequences (views into the database), one entry each.
Definition ProSEAlgorithm.h:1471
std::string fallback_reason
Why PeptideIndexing has to run instead; empty if the mapping applies.
Definition ProSEAlgorithm.h:1477
Size find(std::string_view sequence) const
The entry of sequence, or sequences.size() if there is none.
Definition ProSEAlgorithm.h:1480
std::vector< std::vector< std::pair< UInt32, UInt32 > > > occurrences
Per entry: its occurrences {protein index, position}, ascending (PeptideIndexing's evidence order)
Definition ProSEAlgorithm.h:1473
std::vector< std::unordered_map< std::string_view, Size > > entries
Sequence -> entry, in SHARDS hash tables.
Definition ProSEAlgorithm.h:1475