OpenMS  2.7.0
SimpleSearchEngineAlgorithm.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Timo Sachsenberg $
33 // --------------------------------------------------------------------------
34 
37 
40 
41 #include <vector>
42 
43 namespace OpenMS
44 {
45 
46 class OPENMS_DLLAPI SimpleSearchEngineAlgorithm :
47  public DefaultParamHandler,
48  public ProgressLogger
49 {
50  public:
52 
54  enum class ExitCodes
55  {
56  EXECUTION_OK,
57  INPUT_FILE_EMPTY,
58  UNEXPECTED_RESULT,
59  UNKNOWN_ERROR,
60  ILLEGAL_PARAMETERS
61  };
62 
64  ExitCodes search(const String& in_mzML,
65  const String& in_db,
66  std::vector<ProteinIdentification>& prot_ids,
67  std::vector<PeptideIdentification>& pep_ids) const;
68  protected:
69  void updateMembers_() override;
70 
73  {
76  double score = 0;
77  std::vector<PeptideHit::PeakAnnotation> fragment_annotations;
78  double prefix_fraction = 0;
79  double suffix_fraction = 0;
80  double mean_error = 0.0;
81 
82  static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
83  {
84  if (a.score != b.score) return a.score > b.score;
85  // compare the mod_index first, as it is cheaper than the strncmp() of the sequences
86  // there doesn't have to be a certain ordering (that makes sense), we just need it to be thread-safe
88  return a.sequence < b.sequence;
89  }
90  };
91 
93  static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm);
94 
97  void postProcessHits_(const PeakMap& exp,
98  std::vector<std::vector<SimpleSearchEngineAlgorithm::AnnotatedHit_> >& annotated_hits,
99  std::vector<ProteinIdentification>& protein_ids,
100  std::vector<PeptideIdentification>& peptide_ids,
101  Size top_hits,
102  const ModifiedPeptideGenerator::MapToResidueType& fixed_modifications,
103  const ModifiedPeptideGenerator::MapToResidueType& variable_modifications,
104  Size max_variable_mods_per_peptide,
105  const StringList& modifications_fixed,
106  const StringList& modifications_variable,
107  Int peptide_missed_cleavages,
108  double precursor_mass_tolerance,
109  double fragment_mass_tolerance,
110  const String& precursor_mass_tolerance_unit_ppm,
111  const String& fragment_mass_tolerance_unit_ppm,
112  const Int precursor_min_charge,
113  const Int precursor_max_charge,
114  const String& enzyme,
115  const String& database_name) const;
116 
119 
122 
124 
126 
128 
130 
132 
134 
136 
137  bool decoys_;
138 
140 
144 
146 
148 };
149 
150 } // namespace
151 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
Definition: ModifiedPeptideGenerator.h:58
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
Definition: SimpleSearchEngineAlgorithm.h:49
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:142
Size precursor_max_charge_
Definition: SimpleSearchEngineAlgorithm.h:121
Size precursor_min_charge_
Definition: SimpleSearchEngineAlgorithm.h:120
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:147
Size modifications_max_variable_mods_per_peptide_
Definition: SimpleSearchEngineAlgorithm.h:133
String precursor_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:118
StringList modifications_fixed_
Definition: SimpleSearchEngineAlgorithm.h:129
String enzyme_
Definition: SimpleSearchEngineAlgorithm.h:135
Size peptide_min_size_
Definition: SimpleSearchEngineAlgorithm.h:141
String fragment_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:127
IntList precursor_isotopes_
Definition: SimpleSearchEngineAlgorithm.h:123
bool decoys_
Definition: SimpleSearchEngineAlgorithm.h:137
StringList annotate_psm_
Definition: SimpleSearchEngineAlgorithm.h:139
double precursor_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:117
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:55
StringList modifications_variable_
Definition: SimpleSearchEngineAlgorithm.h:131
double fragment_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:125
String peptide_motif_
Definition: SimpleSearchEngineAlgorithm.h:145
Size peptide_missed_cleavages_
Definition: SimpleSearchEngineAlgorithm.h:143
StringView provides a non-owning view on an existing string.
Definition: String.h:490
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Slimmer structure as storing all scored candidates in PeptideHit objects takes too much space.
Definition: SimpleSearchEngineAlgorithm.h:73
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition: SimpleSearchEngineAlgorithm.h:82
double score
main score
Definition: SimpleSearchEngineAlgorithm.h:76
StringView sequence
Definition: SimpleSearchEngineAlgorithm.h:74
std::vector< PeptideHit::PeakAnnotation > fragment_annotations
Definition: SimpleSearchEngineAlgorithm.h:77
SignedSize peptide_mod_index
enumeration index of the non-RNA peptide modification
Definition: SimpleSearchEngineAlgorithm.h:75