OpenMS  2.5.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-2020.
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 <vector>
38 #include <functional>
39 #include <set>
40 #include <map>
41 
43 #include <OpenMS/CONCEPT/Types.h>
46 
47 namespace OpenMS
48 {
57  class OPENMS_DLLAPI ProteinHit :
58  public MetaInfoInterface
59  {
60 public:
61  static const double COVERAGE_UNKNOWN; // == -1
62 
64 
65  class OPENMS_DLLAPI ProteinHitAccessionHash
67  {
68  public:
69  size_t operator()(const ProteinHit & p)
70  {
71  return std::hash<std::string>{}(p.getAccession());
72  }
73 
74  };
75  class OPENMS_DLLAPI ProteinHitPtrAccessionHash
76  {
77  public:
78  size_t operator()(const ProteinHit * p)
79  {
80  return std::hash<std::string>{}(p->getAccession());
81  }
82 
83  };
85 
87 
88  class OPENMS_DLLAPI ScoreMore
90  {
91 public:
92  template <typename Arg>
93  bool operator()(const Arg & a, const Arg & b)
94  {
95 #pragma clang diagnostic push
96 #pragma clang diagnostic ignored "-Wfloat-equal"
97  if (a.getScore() != b.getScore())
98 #pragma clang diagnostic pop
99  {
100  return a.getScore() > b.getScore();
101  }
102  return a.getAccession() > b.getAccession();
103  }
104 
105  };
106 
108  class OPENMS_DLLAPI ScoreLess
109  {
110 public:
111  template <typename Arg>
112  bool operator()(const Arg & a, const Arg & b)
113  {
114 #pragma clang diagnostic push
115 #pragma clang diagnostic ignored "-Wfloat-equal"
116  if (a.getScore() != b.getScore())
117 #pragma clang diagnostic pop
118  {
119  return a.getScore() < b.getScore();
120  }
121  return a.getAccession() < b.getAccession();
122  }
123 
124  };
126 
129 
131  ProteinHit();
132 
134  ProteinHit(double score, UInt rank, String accession, String sequence);
135 
137  ProteinHit(const ProteinHit &) = default;
138 
140  ProteinHit(ProteinHit&&) = default;
141 
143 
145  ProteinHit & operator=(const ProteinHit &) = default;
146 
148  ProteinHit& operator=(ProteinHit&&) = default; // TODO: add noexcept (gcc 4.8 bug)
149 
151  ProteinHit & operator=(const MetaInfoInterface & source);
152 
154  bool operator==(const ProteinHit & rhs) const;
155 
157  bool operator!=(const ProteinHit & rhs) const;
158 
159 
162 
164  double getScore() const;
165 
167  UInt getRank() const;
168 
170  const String & getSequence() const;
171 
173  const String & getAccession() const;
174 
176  String getDescription() const;
177 
179  double getCoverage() const;
180 
182  void setScore(const double score);
183 
185  void setRank(UInt newrank);
186 
188  void setSequence(const String & sequence);
189 
191  void setAccession(const String & accession);
192 
194  void setDescription(const String & description);
195 
197  void setCoverage(const double coverage);
198 
200  const std::set<std::pair<Size, ResidueModification> >& getModifications() const;
201 
203  void setModifications(std::set<std::pair<Size, ResidueModification> >& mods);
205 
206 protected:
207  double score_;
211  double coverage_;
212  std::set<std::pair<Size, ResidueModification> > modifications_;
213  };
214 
215 } // namespace OpenMS
216 
OpenMS::ProteinHit::coverage_
double coverage_
coverage of the protein based upon the matched peptide sequences
Definition: ProteinHit.h:211
OpenMS::ProteinHit::ScoreLess
Lesser predicate for scores of hits.
Definition: ProteinHit.h:108
Types.h
OpenMS::ProteinHit::ScoreLess::operator()
bool operator()(const Arg &a, const Arg &b)
Definition: ProteinHit.h:112
OpenMS::ProteinHit::ProteinHitPtrAccessionHash::operator()
size_t operator()(const ProteinHit *p)
Definition: ProteinHit.h:78
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:57
OpenMS::ProteinHit::score_
double score_
the score of the protein hit
Definition: ProteinHit.h:207
OpenMS::ProteinHit::ProteinHitAccessionHash::operator()
size_t operator()(const ProteinHit &p)
Definition: ProteinHit.h:69
OpenMS::ProteinHit::ProteinHitPtrAccessionHash
Definition: ProteinHit.h:75
OpenMS::ProteinHit::getAccession
const String & getAccession() const
returns the accession of the protein
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
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:61
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:93
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
OpenMS::ProteinHit::modifications_
std::set< std::pair< Size, ResidueModification > > modifications_
modified positions in a protein
Definition: ProteinHit.h:212
MetaInfoInterface.h
String.h
ResidueModification.h
OpenMS::ProteinHit::ProteinHitAccessionHash
Hash of a ProteinHit based on its accession only!
Definition: ProteinHit.h:66
OpenMS::ProteinHit::sequence_
String sequence_
the amino acid sequence of the protein hit
Definition: ProteinHit.h:210
OpenMS::ProteinHit::accession_
String accession_
the protein identifier
Definition: ProteinHit.h:209
OpenMS::ProteinHit::rank_
UInt rank_
the position(rank) where the hit appeared in the hit list
Definition: ProteinHit.h:208