OpenMS
PeptideHit.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <iosfwd>
12 #include <vector>
13 
14 #include <OpenMS/CONCEPT/Types.h>
20 
21 namespace OpenMS
22 {
23  class PeptideHit;
24  using SpectrumMatch = PeptideHit; // better name that might become the default in future version
25 
48  class OPENMS_DLLAPI PeptideHit :
49  public MetaInfoInterface
50  {
51 public:
53  enum class TargetDecoyType
54  {
55  TARGET,
56  DECOY,
57  TARGET_DECOY,
58  UNKNOWN
59  };
60 
84  struct OPENMS_DLLAPI PeakAnnotation
85  {
86  String annotation = ""; // e.g. [alpha|ci$y3-H2O-NH3]
87  int charge = 0;
88  double mz = -1.;
89  double intensity = 0.;
90 
91  bool operator<(const PeptideHit::PeakAnnotation& other) const;
92 
93  bool operator==(const PeptideHit::PeakAnnotation& other) const;
94 
95  static void writePeakAnnotationsString_(String& annotation_string, std::vector<PeptideHit::PeakAnnotation> annotations);
96 
97  };
98 
99 public:
100 
102 
103  class OPENMS_DLLAPI ScoreMore
105  {
106 public:
107  template <typename Arg>
108  bool operator()(const Arg& a, const Arg& b)
109  {
110  return a.getScore() > b.getScore();
111  }
112 
113  };
114 
116  class OPENMS_DLLAPI ScoreLess
117  {
118 public:
119  template <typename Arg>
120  bool operator()(const Arg& a, const Arg& b)
121  {
122  return a.getScore() < b.getScore();
123  }
124 
125  };
126 
128  class OPENMS_DLLAPI RankLess
129  {
130 public:
131  template <typename Arg>
132  bool operator()(const Arg& a, const Arg& b)
133  {
134  return a.getRank() < b.getRank();
135  }
136 
137  };
139 
140 
142  class OPENMS_DLLAPI SequenceLessComparator
143  {
144  template <typename Arg>
145  bool operator()(const Arg& a, const Arg& b)
146  {
147  if (a.getSequence().toString() < b.getSequence().toString()) return true;
148  return false;
149  }
150  };
152 
154  class OPENMS_DLLAPI PepXMLAnalysisResult
155  {
156 public:
158  bool higher_is_better{};
159  double main_score{};
160  std::map<String, double> sub_scores;
161 
162  bool operator==(const PepXMLAnalysisResult& rhs) const
163  {
164  return score_type == rhs.score_type
165  && higher_is_better == rhs.higher_is_better
166  && main_score == rhs.main_score
167  && sub_scores == rhs.sub_scores;
168  }
169  };
170 
177  PeptideHit(double score,
178  UInt rank,
179  Int charge,
180  const AASequence& sequence);
182  PeptideHit(double score,
183  UInt rank,
184  Int charge,
185  AASequence&& sequence);
187  PeptideHit(const PeptideHit& source);
189  PeptideHit(PeptideHit&&) noexcept;
191  virtual ~PeptideHit();
192 
194  PeptideHit& operator=(const PeptideHit& source);
196  PeptideHit& operator=(PeptideHit&&) noexcept;
198 
200  bool operator==(const PeptideHit& rhs) const;
201 
203  bool operator!=(const PeptideHit& rhs) const;
204 
209  const AASequence& getSequence() const;
210 
212  AASequence& getSequence();
213 
215  void setSequence(const AASequence& sequence);
216 
218  void setSequence(AASequence&& sequence);
219 
221  Int getCharge() const;
222 
224  void setCharge(Int charge);
225 
227  const std::vector<PeptideEvidence>& getPeptideEvidences() const;
228 
230  void setPeptideEvidences(const std::vector<PeptideEvidence>& peptide_evidences);
231 
232  void setPeptideEvidences(std::vector<PeptideEvidence>&& peptide_evidences);
233 
235  void addPeptideEvidence(const PeptideEvidence& peptide_evidence);
236 
238  double getScore() const;
239 
241  void setScore(double score);
242 
244  void setAnalysisResults(const std::vector<PepXMLAnalysisResult>& aresult);
245 
247  void addAnalysisResults(const PepXMLAnalysisResult& aresult);
248 
250  std::vector<PepXMLAnalysisResult> getAnalysisResults() const;
251 
253  UInt getRank() const;
254 
256  void setRank(UInt newrank);
257 
259  std::vector<PeptideHit::PeakAnnotation>& getPeakAnnotations();
260  const std::vector<PeptideHit::PeakAnnotation>& getPeakAnnotations() const;
261 
262 
264  void setPeakAnnotations(std::vector<PeptideHit::PeakAnnotation> frag_annotations);
265 
271  bool isDecoy() const;
272 
287  void setTargetDecoyType(TargetDecoyType type);
288 
301  TargetDecoyType getTargetDecoyType() const;
302 
304 
306  std::set<String> extractProteinAccessionsSet() const;
307 
308 protected:
309  AASequence sequence_;
310 
312  double score_{};
313 
315  Int charge_{};
316 
318  std::vector<PeptideEvidence> peptide_evidences_;
319 
321  std::vector<PeptideHit::PeakAnnotation> fragment_annotations_;
322 
323 private:
326 
328  std::vector<PepXMLAnalysisResult> extractAnalysisResultsFromMetaValues_() const;
329  };
330 
332  OPENMS_DLLAPI std::ostream& operator<< (std::ostream& stream, const PeptideHit& hit);
333 } // namespace OpenMS
Representation of a peptide/protein sequence.
Definition: AASequence.h:86
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Representation of a peptide evidence.
Definition: PeptideEvidence.h:25
Analysis Result (containing search engine / prophet results)
Definition: PeptideHit.h:155
bool operator==(const PepXMLAnalysisResult &rhs) const
additional scores attached to the original, aggregated score
Definition: PeptideHit.h:162
String score_type
Definition: PeptideHit.h:157
bool higher_is_better
e.g. peptideprophet / interprophet
Definition: PeptideHit.h:158
std::map< String, double > sub_scores
posterior probability for example
Definition: PeptideHit.h:160
double main_score
is higher score better ?
Definition: PeptideHit.h:159
Lesser predicate for scores of hits.
Definition: PeptideHit.h:129
bool operator()(const Arg &a, const Arg &b)
Definition: PeptideHit.h:132
Lesser predicate for scores of hits.
Definition: PeptideHit.h:117
bool operator()(const Arg &a, const Arg &b)
Definition: PeptideHit.h:120
Greater predicate for scores of hits.
Definition: PeptideHit.h:105
bool operator()(const Arg &a, const Arg &b)
Definition: PeptideHit.h:108
Lesser predicate for (modified) sequence of hits.
Definition: PeptideHit.h:143
bool operator()(const Arg &a, const Arg &b)
Definition: PeptideHit.h:145
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition: PeptideHit.h:50
PeptideHit(PeptideHit &&) noexcept
Move constructor.
size_t getNumberOfAnalysisResultsFromMetaValues_() const
Get the number of analysis results stored as meta values (only for pepXML results)
PeptideHit(double score, UInt rank, Int charge, const AASequence &sequence)
Values constructor that copies sequence.
std::vector< PepXMLAnalysisResult > extractAnalysisResultsFromMetaValues_() const
Extract analysis results from meta values (only for pepXML results)
PeptideHit()
Default constructor.
std::vector< PeptideEvidence > peptide_evidences_
information on the potential peptides observed through this PSM.
Definition: PeptideHit.h:318
PeptideHit(const PeptideHit &source)
Copy constructor.
std::vector< PeptideHit::PeakAnnotation > fragment_annotations_
annotations of fragments in the corresponding spectrum
Definition: PeptideHit.h:321
PeptideHit(double score, UInt rank, Int charge, AASequence &&sequence)
Values constructor that moves sequence R-value.
TargetDecoyType
Enum for target/decoy annotation.
Definition: PeptideHit.h:54
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:72
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
const std::string TARGET_DECOY
Definition: Constants.h:352
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Contains annotations of a peak.
Definition: PeptideHit.h:85
bool operator==(const PeptideHit::PeakAnnotation &other) const
bool operator<(const PeptideHit::PeakAnnotation &other) const
static void writePeakAnnotationsString_(String &annotation_string, std::vector< PeptideHit::PeakAnnotation > annotations)