OpenMS
Loading...
Searching...
No Matches
PeptideEvidence.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: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <functional>
16
17namespace OpenMS
18{
19
27 class OPENMS_DLLAPI PeptideEvidence
28 {
29public:
30 static const int UNKNOWN_POSITION; // == -1
31
32 // Note: we use 0 as position of the N-terminus while e.g. mzTab or other formats start counting at 1.
33 static const int N_TERMINAL_POSITION;
34 static const char UNKNOWN_AA; // PeptideEvidence::UNKNOWN_AA = 'X';
35
36 // Note: we use '[' and ']' instead of e.g. '-' as in mzTab specification
37 static const char N_TERMINAL_AA;
38 static const char C_TERMINAL_AA;
39
42
44 explicit PeptideEvidence(const String& accession, Int start=UNKNOWN_POSITION, Int end=UNKNOWN_POSITION, char aa_before=UNKNOWN_AA, char aa_after=UNKNOWN_AA);
45
48
50 PeptideEvidence(PeptideEvidence&&) noexcept = default;
51
53 ~PeptideEvidence() = default;
55
57 PeptideEvidence& operator=(const PeptideEvidence&) = default;
59 PeptideEvidence& operator=(PeptideEvidence&&) = default; // TODO: add noexcept (gcc 4.8 bug)
60
62 bool operator==(const PeptideEvidence& rhs) const;
63
65 bool operator<(const PeptideEvidence& rhs) const;
66
68 bool operator!=(const PeptideEvidence& rhs) const;
69
71 bool hasValidLimits() const;
72
74 const String& getProteinAccession() const;
75
77 void setProteinAccession(const String& s);
78
80 void setStart(const Int a);
81
83 Int getStart() const;
84
86 void setEnd(const Int a);
87
89 Int getEnd() const;
90
92 void setAABefore(const char acid);
93
95 char getAABefore() const;
96
98 void setAAAfter(const char acid);
99
101 char getAAAfter() const;
102
103protected:
104 String accession_;
105
106 Int start_;
107
108 Int end_;
109
110 char aa_before_;
111
112 char aa_after_;
113 };
114
115} // namespace OpenMS
116
117// Hash function specialization for PeptideEvidence
118namespace std
119{
120 template<>
121 struct hash<OpenMS::PeptideEvidence>
122 {
123 std::size_t operator()(const OpenMS::PeptideEvidence& pe) const noexcept
124 {
125 std::size_t seed = OpenMS::fnv1a_hash_string(pe.getProteinAccession());
126 OpenMS::hash_combine(seed, OpenMS::hash_int(pe.getStart()));
127 OpenMS::hash_combine(seed, OpenMS::hash_int(pe.getEnd()));
128 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(pe.getAABefore())));
129 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(pe.getAAAfter())));
130 return seed;
131 }
132 };
133}
134
Representation of a peptide evidence.
Definition PeptideEvidence.h:28
static const char C_TERMINAL_AA
Definition PeptideEvidence.h:38
static const char N_TERMINAL_AA
Definition PeptideEvidence.h:37
static const int UNKNOWN_POSITION
Definition PeptideEvidence.h:30
static const int N_TERMINAL_POSITION
Definition PeptideEvidence.h:33
PeptideEvidence(const String &accession, Int start=UNKNOWN_POSITION, Int end=UNKNOWN_POSITION, char aa_before=UNKNOWN_AA, char aa_after=UNKNOWN_AA)
Constructor.
PeptideEvidence(PeptideEvidence &&) noexcept=default
Move constructor.
PeptideEvidence()
Constructor.
PeptideEvidence(const PeptideEvidence &)=default
Copy constructor.
static const char UNKNOWN_AA
Definition PeptideEvidence.h:34
A more convenient string class.
Definition String.h:34
int Int
Signed integer type.
Definition Types.h:72
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::size_t hash_int(T value) noexcept
Hash for an integer type.
Definition HashUtils.h:107
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
std::size_t operator()(const OpenMS::PeptideEvidence &pe) const noexcept
Definition PeptideEvidence.h:123