OpenMS  2.8.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-2021.
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 
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 
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 
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 
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Hash of a ProteinHit based on its accession only!
Definition: ProteinHit.h:68
size_t operator()(const ProteinHit &p)
Definition: ProteinHit.h:70
size_t operator()(const ProteinHit *p)
Definition: ProteinHit.h:79
Lesser predicate for scores of hits.
Definition: ProteinHit.h:110
bool operator()(const Arg &a, const Arg &b)
Definition: ProteinHit.h:113
bool operator()(const Arg &a, const Arg &b)
Definition: ProteinHit.h:94
Representation of a protein hit.
Definition: ProteinHit.h:60
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:212
UInt rank_
the position(rank) where the hit appeared in the hit list
Definition: ProteinHit.h:210
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:214
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:211
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:213
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:209
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:62
ProteinHit(ProteinHit &&)=default
Move constructor.
ProteinHit(const ProteinHit &)=default
Copy constructor.
A more convenient string class.
Definition: String.h:60
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)