OpenMS  3.0.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-2022.
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 
41 
42 #include <vector>
43 
44 namespace OpenMS
45 {
46 
47 class OPENMS_DLLAPI SimpleSearchEngineAlgorithm :
48  public DefaultParamHandler,
49  public ProgressLogger
50 {
51  public:
53 
55  enum class ExitCodes
56  {
57  EXECUTION_OK,
58  INPUT_FILE_EMPTY,
59  UNEXPECTED_RESULT,
60  UNKNOWN_ERROR,
61  ILLEGAL_PARAMETERS
62  };
63 
65  ExitCodes search(const String& in_mzML,
66  const String& in_db,
67  std::vector<ProteinIdentification>& prot_ids,
68  std::vector<PeptideIdentification>& pep_ids) const;
69  protected:
70  void updateMembers_() override;
71 
74  {
77  double score = 0;
78  std::vector<PeptideHit::PeakAnnotation> fragment_annotations;
79  double prefix_fraction = 0;
80  double suffix_fraction = 0;
81  double mean_error = 0.0;
82 
83  static bool hasBetterScore(const AnnotatedHit_& a, const AnnotatedHit_& b)
84  {
85  if (a.score != b.score) return a.score > b.score;
86  // compare the mod_index first, as it is cheaper than the strncmp() of the sequences
87  // there doesn't have to be a certain ordering (that makes sense), we just need it to be thread-safe
89  return a.sequence < b.sequence;
90  }
91  };
92 
94  static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm);
95 
98  void postProcessHits_(const PeakMap& exp,
99  std::vector<std::vector<SimpleSearchEngineAlgorithm::AnnotatedHit_> >& annotated_hits,
100  std::vector<ProteinIdentification>& protein_ids,
101  std::vector<PeptideIdentification>& peptide_ids,
102  Size top_hits,
103  const ModifiedPeptideGenerator::MapToResidueType& fixed_modifications,
104  const ModifiedPeptideGenerator::MapToResidueType& variable_modifications,
105  Size max_variable_mods_per_peptide,
106  const StringList& modifications_fixed,
107  const StringList& modifications_variable,
108  Int peptide_missed_cleavages,
109  double precursor_mass_tolerance,
110  double fragment_mass_tolerance,
111  const String& precursor_mass_tolerance_unit_ppm,
112  const String& fragment_mass_tolerance_unit_ppm,
113  const Int precursor_min_charge,
114  const Int precursor_max_charge,
115  const String& enzyme,
116  const String& database_name) const;
117 
120 
123 
125 
127 
129 
131 
133 
135 
137 
138  bool decoys_;
139 
141 
145 
147 
149 };
150 
151 } // namespace
152 
DefaultParamHandler.h
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_::fragment_annotations
std::vector< PeptideHit::PeakAnnotation > fragment_annotations
Definition: SimpleSearchEngineAlgorithm.h:78
OpenMS::SimpleSearchEngineAlgorithm::peptide_max_size_
Size peptide_max_size_
Definition: SimpleSearchEngineAlgorithm.h:143
OpenMS::SimpleSearchEngineAlgorithm::peptide_motif_
String peptide_motif_
Definition: SimpleSearchEngineAlgorithm.h:146
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
OpenMS::SimpleSearchEngineAlgorithm::peptide_min_size_
Size peptide_min_size_
Definition: SimpleSearchEngineAlgorithm.h:142
OpenMS::IdXMLFile::store
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
OpenMS::Param::insert
void insert(const std::string &prefix, const Param &param)
OpenMS::SimpleSearchEngineAlgorithm::fragment_mass_tolerance_unit_
String fragment_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:128
OpenMS::File::basename
static String basename(const String &file)
OpenMS::SimpleSearchEngineAlgorithm::search
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
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
IdXMLFile.h
OpenMS::SimpleSearchEngineAlgorithm::precursor_mass_tolerance_
double precursor_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:118
OpenMS::SimpleSearchEngineAlgorithm::annotate_psm_
StringList annotate_psm_
Definition: SimpleSearchEngineAlgorithm.h:140
OpenMS::SimpleSearchEngineAlgorithm::report_top_hits_
Size report_top_hits_
Definition: SimpleSearchEngineAlgorithm.h:148
OpenMS::IntList
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
OpenMS::SimpleSearchEngineAlgorithm::modifications_variable_
StringList modifications_variable_
Definition: SimpleSearchEngineAlgorithm.h:132
OpenMS::SimpleSearchEngineAlgorithm::decoys_
bool decoys_
Definition: SimpleSearchEngineAlgorithm.h:138
OpenMS::SimpleSearchEngineAlgorithm::precursor_isotopes_
IntList precursor_isotopes_
Definition: SimpleSearchEngineAlgorithm.h:124
OpenMS::SimpleSearchEngineAlgorithm::modifications_fixed_
StringList modifications_fixed_
Definition: SimpleSearchEngineAlgorithm.h:130
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::SimpleSearchEngineAlgorithm::enzyme_
String enzyme_
Definition: SimpleSearchEngineAlgorithm.h:136
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
ProgressLogger.h
StringView.h
OpenMS::SimpleSearchEngineAlgorithm::ExitCodes::EXECUTION_OK
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_::score
double score
main score
Definition: SimpleSearchEngineAlgorithm.h:77
OpenMS::StringView
StringView provides a non-owning view on an existing string.
Definition: StringView.h:55
OpenMS::SimpleSearchEngineAlgorithm::modifications_max_variable_mods_per_peptide_
Size modifications_max_variable_mods_per_peptide_
Definition: SimpleSearchEngineAlgorithm.h:134
OpenMS::SimpleSearchEngineAlgorithm::peptide_missed_cleavages_
Size peptide_missed_cleavages_
Definition: SimpleSearchEngineAlgorithm.h:144
OpenMS::SimpleSearchEngineAlgorithm
Definition: SimpleSearchEngineAlgorithm.h:47
OpenMS::SimpleSearchEngineAlgorithm::precursor_mass_tolerance_unit_
String precursor_mass_tolerance_unit_
Definition: SimpleSearchEngineAlgorithm.h:119
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_
Slimmer structure as storing all scored candidates in PeptideHit objects takes too much space.
Definition: SimpleSearchEngineAlgorithm.h:73
OpenMS::DefaultParamHandler::setParameters
void setParameters(const Param &param)
Sets the parameters.
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_::peptide_mod_index
SignedSize peptide_mod_index
enumeration index of the non-RNA peptide modification
Definition: SimpleSearchEngineAlgorithm.h:76
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
MSExperiment.h
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::SimpleSearchEngineAlgorithm::precursor_min_charge_
Size precursor_min_charge_
Definition: SimpleSearchEngineAlgorithm.h:121
OpenMS::SimpleSearchEngineAlgorithm::precursor_max_charge_
Size precursor_max_charge_
Definition: SimpleSearchEngineAlgorithm.h:122
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_::sequence
StringView sequence
Definition: SimpleSearchEngineAlgorithm.h:75
OpenMS::ModifiedPeptideGenerator::MapToResidueType
Definition: ModifiedPeptideGenerator.h:58
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:69
ModifiedPeptideGenerator.h
OpenMS::SimpleSearchEngineAlgorithm::fragment_mass_tolerance_
double fragment_mass_tolerance_
Definition: SimpleSearchEngineAlgorithm.h:126
SimpleSearchEngineAlgorithm.h
OpenMS::SimpleSearchEngineAlgorithm::AnnotatedHit_::hasBetterScore
static bool hasBetterScore(const AnnotatedHit_ &a, const AnnotatedHit_ &b)
Definition: SimpleSearchEngineAlgorithm.h:83
OpenMS::SimpleSearchEngineAlgorithm::ExitCodes
ExitCodes
Exit codes.
Definition: SimpleSearchEngineAlgorithm.h:55
StandardTypes.h
File.h
OpenMS::ProgressLogger::setLogType
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
TOPPBase.h
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:68