OpenMS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ProteinHit.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 #include <functional>
14 #include <set>
15 #include <map>
16 
18 #include <OpenMS/CONCEPT/Types.h>
21 
22 namespace OpenMS
23 {
32  class OPENMS_DLLAPI ProteinHit :
33  public MetaInfoInterface
34  {
35 public:
36  static const double COVERAGE_UNKNOWN; // == -1
37 
39 
40  class OPENMS_DLLAPI ProteinHitAccessionHash
42  {
43  public:
44  size_t operator()(const ProteinHit & p)
45  {
46  return std::hash<std::string>{}(p.getAccession());
47  }
48 
49  };
50  class OPENMS_DLLAPI ProteinHitPtrAccessionHash
51  {
52  public:
53  size_t operator()(const ProteinHit * p)
54  {
55  return std::hash<std::string>{}(p->getAccession());
56  }
57 
58  };
60 
62 
63  class OPENMS_DLLAPI ScoreMore
65  {
66  public:
67  template<typename Arg>
68  bool operator()(const Arg& a, const Arg& b) const
69  {
70  return std::make_tuple(a.getScore(), a.getAccession()) > std::make_tuple(b.getScore(), b.getAccession());
71  }
72  };
73 
75  class OPENMS_DLLAPI ScoreLess
76  {
77 public:
78  template <typename Arg>
79  bool operator()(const Arg & a, const Arg & b) const
80  {
81  return std::make_tuple(a.getScore(), a.getAccession()) < std::make_tuple(b.getScore(), b.getAccession());
82  }
83 
84  };
86 
89 
92 
94  ProteinHit(double score, UInt rank, String accession, String sequence);
95 
97  ProteinHit(const ProteinHit &) = default;
98 
100  ProteinHit(ProteinHit&&) = default;
101 
103 
105  ProteinHit & operator=(const ProteinHit &) = default;
106 
108  ProteinHit& operator=(ProteinHit&&) = default; // TODO: add noexcept (gcc 4.8 bug)
109 
112 
114  bool operator==(const ProteinHit & rhs) const;
115 
117  bool operator!=(const ProteinHit & rhs) const;
118 
119 
122 
124  double getScore() const;
125 
127  UInt getRank() const;
128 
130  const String & getSequence() const;
131 
133  const String & getAccession() const;
134 
137 
139  double getCoverage() const;
140 
142  void setScore(const double score);
143 
145  void setRank(UInt newrank);
146 
148  void setSequence(const String & sequence);
149  void setSequence(String && sequence);
150 
152  void setAccession(const String & accession);
153 
155  void setDescription(const String & description);
156 
158  void setCoverage(const double coverage);
159 
161  const std::set<std::pair<Size, ResidueModification> >& getModifications() const;
162 
164  void setModifications(std::set<std::pair<Size, ResidueModification> >& mods);
166 
167 protected:
168  double score_;
172  double coverage_;
173  std::set<std::pair<Size, ResidueModification> > modifications_;
174  };
175 
177  OPENMS_DLLAPI std::ostream& operator<< (std::ostream& stream, const ProteinHit& hit);
178 
179 } // namespace OpenMS
180 
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Hash of a ProteinHit based on its accession only!
Definition: ProteinHit.h:42
size_t operator()(const ProteinHit &p)
Definition: ProteinHit.h:44
size_t operator()(const ProteinHit *p)
Definition: ProteinHit.h:53
Lesser predicate for scores of hits.
Definition: ProteinHit.h:76
bool operator()(const Arg &a, const Arg &b) const
Definition: ProteinHit.h:79
bool operator()(const Arg &a, const Arg &b) const
Definition: ProteinHit.h:68
Representation of a protein hit.
Definition: ProteinHit.h:34
double getScore() const
returns the score of the protein hit
double getCoverage() const
returns the coverage (in percent) of the protein hit based upon matched peptides
bool operator==(const ProteinHit &rhs) const
Equality operator.
void setSequence(const String &sequence)
sets the protein sequence
String sequence_
the amino acid sequence of the protein hit
Definition: ProteinHit.h:171
UInt rank_
the position(rank) where the hit appeared in the hit list
Definition: ProteinHit.h:169
void setModifications(std::set< std::pair< Size, ResidueModification > > &mods)
sets the set of modified protein positions
void setSequence(String &&sequence)
ProteinHit()
Default constructor.
void setScore(const double score)
sets the score of the protein hit
bool operator!=(const ProteinHit &rhs) const
Inequality operator.
const std::set< std::pair< Size, ResidueModification > > & getModifications() const
returns the set of modified protein positions
std::set< std::pair< Size, ResidueModification > > modifications_
modified positions in a protein
Definition: ProteinHit.h:173
void setRank(UInt newrank)
sets the rank
const String & getSequence() const
returns the protein sequence
UInt getRank() const
returns the rank of the protein hit
const String & getAccession() const
returns the accession of the protein
ProteinHit(double score, UInt rank, String accession, String sequence)
Values constructor.
String accession_
the protein identifier
Definition: ProteinHit.h:170
void setDescription(const String &description)
sets the description of the protein
void setAccession(const String &accession)
sets the accession of the protein
double coverage_
coverage of the protein based upon the matched peptide sequences
Definition: ProteinHit.h:172
ProteinHit & operator=(const MetaInfoInterface &source)
Assignment for MetaInfo.
ProteinHit & operator=(const ProteinHit &)=default
Assignment operator.
String getDescription() const
returns the description of the protein
double score_
the score of the protein hit
Definition: ProteinHit.h:168
ProteinHit & operator=(ProteinHit &&)=default
Move assignment operator.
void setCoverage(const double coverage)
sets the coverage (in percent) of the protein hit based upon matched peptides
static const double COVERAGE_UNKNOWN
Definition: ProteinHit.h:36
ProteinHit(ProteinHit &&)=default
Move constructor.
ProteinHit(const ProteinHit &)=default
Copy constructor.
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)