OpenMS  3.0.0
ProteinHit.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: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <iosfwd>
38 #include <vector>
39 #include <functional>
40 #include <set>
41 #include <map>
42 
44 #include <OpenMS/CONCEPT/Types.h>
47 
48 namespace OpenMS
49 {
58  class OPENMS_DLLAPI ProteinHit :
59  public MetaInfoInterface
60  {
61 public:
62  static const double COVERAGE_UNKNOWN; // == -1
63 
65 
66  class OPENMS_DLLAPI ProteinHitAccessionHash
68  {
69  public:
70  size_t operator()(const ProteinHit & p)
71  {
72  return std::hash<std::string>{}(p.getAccession());
73  }
74 
75  };
76  class OPENMS_DLLAPI ProteinHitPtrAccessionHash
77  {
78  public:
79  size_t operator()(const ProteinHit * p)
80  {
81  return std::hash<std::string>{}(p->getAccession());
82  }
83 
84  };
86 
88 
89  class OPENMS_DLLAPI ScoreMore
91  {
92 public:
93  template <typename Arg>
94  bool operator()(const Arg & a, const Arg & b)
95  {
96 #pragma clang diagnostic push
97 #pragma clang diagnostic ignored "-Wfloat-equal"
98  if (a.getScore() != b.getScore())
99 #pragma clang diagnostic pop
100  {
101  return a.getScore() > b.getScore();
102  }
103  return a.getAccession() > b.getAccession();
104  }
105 
106  };
107 
109  class OPENMS_DLLAPI ScoreLess
110  {
111 public:
112  template <typename Arg>
113  bool operator()(const Arg & a, const Arg & b)
114  {
115 #pragma clang diagnostic push
116 #pragma clang diagnostic ignored "-Wfloat-equal"
117  if (a.getScore() != b.getScore())
118 #pragma clang diagnostic pop
119  {
120  return a.getScore() < b.getScore();
121  }
122  return a.getAccession() < b.getAccession();
123  }
124 
125  };
127 
130 
132  ProteinHit();
133 
135  ProteinHit(double score, UInt rank, String accession, String sequence);
136 
138  ProteinHit(const ProteinHit &) = default;
139 
141  ProteinHit(ProteinHit&&) = default;
142 
144 
146  ProteinHit & operator=(const ProteinHit &) = default;
147 
149  ProteinHit& operator=(ProteinHit&&) = default; // TODO: add noexcept (gcc 4.8 bug)
150 
152  ProteinHit & operator=(const MetaInfoInterface & source);
153 
155  bool operator==(const ProteinHit & rhs) const;
156 
158  bool operator!=(const ProteinHit & rhs) const;
159 
160 
163 
165  double getScore() const;
166 
168  UInt getRank() const;
169 
171  const String & getSequence() const;
172 
174  const String & getAccession() const;
175 
177  String getDescription() const;
178 
180  double getCoverage() const;
181 
183  void setScore(const double score);
184 
186  void setRank(UInt newrank);
187 
189  void setSequence(const String & sequence);
190  void setSequence(String && sequence);
191 
193  void setAccession(const String & accession);
194 
196  void setDescription(const String & description);
197 
199  void setCoverage(const double coverage);
200 
202  const std::set<std::pair<Size, ResidueModification> >& getModifications() const;
203 
205  void setModifications(std::set<std::pair<Size, ResidueModification> >& mods);
207 
208 protected:
209  double score_;
213  double coverage_;
214  std::set<std::pair<Size, ResidueModification> > modifications_;
215  };
216 
218  OPENMS_DLLAPI std::ostream& operator<< (std::ostream& stream, const ProteinHit& hit);
219 
220 } // namespace OpenMS
221 
OpenMS::ProteinHit::coverage_
double coverage_
coverage of the protein based upon the matched peptide sequences
Definition: ProteinHit.h:213
OpenMS::ProteinHit::ScoreLess
Lesser predicate for scores of hits.
Definition: ProteinHit.h:109
Types.h
OpenMS::ProteinHit::ScoreLess::operator()
bool operator()(const Arg &a, const Arg &b)
Definition: ProteinHit.h:113
OpenMS::ProteinHit::ProteinHitPtrAccessionHash::operator()
size_t operator()(const ProteinHit *p)
Definition: ProteinHit.h:79
OpenMS::String
A more convenient string class.
Definition: String.h:58
KDTree::operator!=
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
OpenMS::ProteinHit
Representation of a protein hit.
Definition: ProteinHit.h:58
OpenMS::ProteinHit::score_
double score_
the score of the protein hit
Definition: ProteinHit.h:209
OpenMS::ProteinHit::ProteinHitAccessionHash::operator()
size_t operator()(const ProteinHit &p)
Definition: ProteinHit.h:70
OpenMS::ProteinHit::ProteinHitPtrAccessionHash
Definition: ProteinHit.h:76
OpenMS::ProteinHit::getAccession
const String & getAccession() const
returns the accession of the protein
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::ProteinHit::COVERAGE_UNKNOWN
static const double COVERAGE_UNKNOWN
Definition: ProteinHit.h:62
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::ProteinHit::ScoreMore::operator()
bool operator()(const Arg &a, const Arg &b)
Definition: ProteinHit.h:94
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::ProteinHit::modifications_
std::set< std::pair< Size, ResidueModification > > modifications_
modified positions in a protein
Definition: ProteinHit.h:214
MetaInfoInterface.h
String.h
ResidueModification.h
OpenMS::ProteinHit::ProteinHitAccessionHash
Hash of a ProteinHit based on its accession only!
Definition: ProteinHit.h:67
OpenMS::ProteinHit::sequence_
String sequence_
the amino acid sequence of the protein hit
Definition: ProteinHit.h:212
OpenMS::ProteinHit::accession_
String accession_
the protein identifier
Definition: ProteinHit.h:211
OpenMS::ProteinHit::rank_
UInt rank_
the position(rank) where the hit appeared in the hit list
Definition: ProteinHit.h:210