OpenMS
SimpleSearchEngineAlgorithm.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
11 
15 
16 #include <vector>
17 
18 namespace OpenMS
19 {
20 
21 class OPENMS_DLLAPI SimpleSearchEngineAlgorithm :
22  public DefaultParamHandler,
23  public ProgressLogger
24 {
25  public:
27 
29  enum class ExitCodes
30  {
31  EXECUTION_OK,
32  INPUT_FILE_EMPTY,
33  UNEXPECTED_RESULT,
34  UNKNOWN_ERROR,
35  ILLEGAL_PARAMETERS
36  };
37 
39  ExitCodes search(const String& in_mzML,
40  const String& in_db,
41  std::vector<ProteinIdentification>& prot_ids,
42  std::vector<PeptideIdentification>& pep_ids) const;
43  protected:
44  void updateMembers_() override;
45 
48  {
51  double score = 0;
52  std::vector<PeptideHit::PeakAnnotation> fragment_annotations;
53  double prefix_fraction = 0;
54  double suffix_fraction = 0;
55  double mean_error = 0.0;
56 
57  static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
58  {
59  if (a.score != b.score) return a.score > b.score;
60  // compare the mod_index first, as it is cheaper than the strncmp() of the sequences
61  // there doesn't have to be a certain ordering (that makes sense), we just need it to be thread-safe
63  return a.sequence < b.sequence;
64  }
65  };
66 
68  static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm);
69 
72  void postProcessHits_(const PeakMap& exp,
73  std::vector<std::vector<SimpleSearchEngineAlgorithm::AnnotatedHit_> >& annotated_hits,
74  std::vector<ProteinIdentification>& protein_ids,
75  std::vector<PeptideIdentification>& peptide_ids,
76  Size top_hits,
77  const ModifiedPeptideGenerator::MapToResidueType& fixed_modifications,
78  const ModifiedPeptideGenerator::MapToResidueType& variable_modifications,
79  Size max_variable_mods_per_peptide,
80  const StringList& modifications_fixed,
81  const StringList& modifications_variable,
82  Int peptide_missed_cleavages,
83  double precursor_mass_tolerance,
84  double fragment_mass_tolerance,
85  const String& precursor_mass_tolerance_unit_ppm,
86  const String& fragment_mass_tolerance_unit_ppm,
87  const Int precursor_min_charge,
88  const Int precursor_max_charge,
89  const String& enzyme,
90  const String& database_name) const;
91 
94 
97 
99 
101 
103 
105 
107 
109 
111 
112  bool decoys_;
113 
115 
119 
121 
123 };
124 
125 } // namespace
126 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
Definition: ModifiedPeptideGenerator.h:31
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Definition: SimpleSearchEngineAlgorithm.h:24
static void preprocessSpectra_(PeakMap &exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm)
filter, deisotope, decharge spectra
ExitCodes search(const String &in_mzML, const String &in_db, std::vector< ProteinIdentification > &prot_ids, std::vector< PeptideIdentification > &pep_ids) const
search spectra against database
Size peptide_max_size_
Definition: SimpleSearchEngineAlgorithm.h:117
Size precursor_max_charge_
Definition: SimpleSearchEngineAlgorithm.h:96
Size precursor_min_charge_
Definition: SimpleSearchEngineAlgorithm.h:95
void postProcessHits_(const PeakMap &exp, std::vector< std::vector< SimpleSearchEngineAlgorithm::AnnotatedHit_ > > &annotated_hits, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids, Size top_hits, const ModifiedPeptideGenerator::MapToResidueType &fixed_modifications, const ModifiedPeptideGenerator::MapToResidueType &variable_modifications, Size max_variable_mods_per_peptide, const StringList &modifications_fixed, const StringList &modifications_variable, Int peptide_missed_cleavages, double precursor_mass_tolerance, double fragment_mass_tolerance, const String &precursor_mass_tolerance_unit_ppm, const String &fragment_mass_tolerance_unit_ppm, const Int precursor_min_charge, const Int precursor_max_charge, const String &enzyme, const String &database_name) const
filter and annotate search results most of the parameters are used to properly add meta data to the i...
Size report_top_hits_
Definition: SimpleSearchEngineAlgorithm.h:122
Size modifications_max_variable_mods_per_peptide_
Definition: SimpleSearchEngineAlgorithm.h:108
String precursor_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:93
StringList modifications_fixed_
Definition: SimpleSearchEngineAlgorithm.h:104
String enzyme_
Definition: SimpleSearchEngineAlgorithm.h:110
Size peptide_min_size_
Definition: SimpleSearchEngineAlgorithm.h:116
String fragment_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:102
IntList precursor_isotopes_
Definition: SimpleSearchEngineAlgorithm.h:98
bool decoys_
Definition: SimpleSearchEngineAlgorithm.h:112
StringList annotate_psm_
Definition: SimpleSearchEngineAlgorithm.h:114
double precursor_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:92
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
ExitCodes
Exit codes.
Definition: SimpleSearchEngineAlgorithm.h:30
StringList modifications_variable_
Definition: SimpleSearchEngineAlgorithm.h:106
double fragment_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:100
String peptide_motif_
Definition: SimpleSearchEngineAlgorithm.h:120
Size peptide_missed_cleavages_
Definition: SimpleSearchEngineAlgorithm.h:118
StringView provides a non-owning view on an existing string.
Definition: StringView.h:30
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:108
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:29
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Slimmer structure as storing all scored candidates in PeptideHit objects takes too much space.
Definition: SimpleSearchEngineAlgorithm.h:48
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition: SimpleSearchEngineAlgorithm.h:57
double score
main score
Definition: SimpleSearchEngineAlgorithm.h:51
StringView sequence
Definition: SimpleSearchEngineAlgorithm.h:49
std::vector< PeptideHit::PeakAnnotation > fragment_annotations
Definition: SimpleSearchEngineAlgorithm.h:52
SignedSize peptide_mod_index
enumeration index of the non-RNA peptide modification
Definition: SimpleSearchEngineAlgorithm.h:50