OpenMS
Loading...
Searching...
No Matches
Ribonucleotide.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: Hendrik Weisser $
6// $Authors: Hendrik Weisser $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14#include <functional>
15#include <iosfwd>
16
17namespace OpenMS
18{
27 class OPENMS_DLLAPI Ribonucleotide
28 {
29 friend class RibonucleotideDB;
30 public:
31
33 {
37 NUMBER_OF_TERM_SPECIFICITY
38 };
39
44 Ribonucleotide(const String& name = "unknown ribonucleotide",
45 const String& code = ".",
46 const String& new_code = "",
47 const String& html_code = ".",
48 const EmpiricalFormula& formula = EmpiricalFormula(),
49 char origin = '.',
50 double mono_mass = 0.0,
51 double avg_mass = 0.0,
52 enum TermSpecificityNuc term_spec = ANYWHERE,
53 const EmpiricalFormula& baseloss_formula =
54 default_baseloss_);
55
57 Ribonucleotide(const Ribonucleotide& ribo) = default;
58
60 virtual ~Ribonucleotide();
62
67 Ribonucleotide& operator=(const Ribonucleotide& ribo) = default;
69
70
75 bool operator==(const Ribonucleotide& ribonucleotide) const;
77
81
83 const String getCode() const;
84
86 void setCode(const String& code);
87
89 const String getName() const;
90
92 void setName(const String& name);
93
96
98 void setFormula(const EmpiricalFormula& formula);
99
101 double getMonoMass() const;
102
104 void setMonoMass(double mono_mass);
105
107 double getAvgMass() const;
108
110 void setAvgMass(double avg_mass);
111
113 const String getNewCode() const;
114
116 void setNewCode(const String &new_code);
117
119 friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Ribonucleotide& ribo);
120
122 char getOrigin() const;
123
125 void setOrigin(char origin);
126
129
131 void setHTMLCode(const String& html_code);
132
135
138
141
144
146
148 bool isModified() const;
149
151 bool isAmbiguous() const;
152
153 protected:
156
162 char origin_;
163 double mono_mass_;
164 double avg_mass_;
167 };
168
170 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Ribonucleotide& ribo);
171
174
175} // namespace OpenMS
176
177// Hash function specialization for Ribonucleotide
178// Placed in std namespace to allow use with std::unordered_map/set
179namespace std
180{
190 template<>
191 struct hash<OpenMS::Ribonucleotide>
192 {
193 std::size_t operator()(const OpenMS::Ribonucleotide& ribo) const noexcept
194 {
195 std::size_t seed = 0;
196
197 // Hash all fields used in operator==
198 // String fields: name_, code_, new_code_, html_code_
199 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(ribo.getName()));
200 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(ribo.getCode()));
201 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(ribo.getNewCode()));
202 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(ribo.getHTMLCode()));
203
204 // EmpiricalFormula fields: formula_, baseloss_formula_
205 OpenMS::hash_combine(seed, std::hash<OpenMS::EmpiricalFormula>{}(ribo.getFormula()));
206 OpenMS::hash_combine(seed, std::hash<OpenMS::EmpiricalFormula>{}(ribo.getBaselossFormula()));
207
208 // Primitive fields: origin_ (char), mono_mass_, avg_mass_ (double), term_spec_ (enum)
209 OpenMS::hash_combine(seed, OpenMS::hash_char(ribo.getOrigin()));
210 OpenMS::hash_combine(seed, OpenMS::hash_float(ribo.getMonoMass()));
211 OpenMS::hash_combine(seed, OpenMS::hash_float(ribo.getAvgMass()));
212 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(ribo.getTermSpecificity())));
213
214 return seed;
215 }
216 };
217} // namespace std
Representation of an empirical formula.
Definition EmpiricalFormula.h:63
Database of ribonucleotides (modified and unmodified)
Definition RibonucleotideDB.h:26
Representation of a ribonucleotide (modified or unmodified)
Definition Ribonucleotide.h:28
const EmpiricalFormula getBaselossFormula() const
Get sum formula after loss of the nucleobase.
double avg_mass_
average mass
Definition Ribonucleotide.h:164
const String getNewCode() const
Get the "new" (Modomics) code.
enum TermSpecificityNuc term_spec_
terminal specificity
Definition Ribonucleotide.h:165
virtual ~Ribonucleotide()
Destructor.
String new_code_
Modomics code.
Definition Ribonucleotide.h:159
void setAvgMass(double avg_mass)
Get the average mass of the ribonucleotide.
Ribonucleotide(const Ribonucleotide &ribo)=default
Copy constructor.
String name_
full name
Definition Ribonucleotide.h:157
EmpiricalFormula baseloss_formula_
sum formula after loss of the nucleobase
Definition Ribonucleotide.h:166
Ribonucleotide(const String &name="unknown ribonucleotide", const String &code=".", const String &new_code="", const String &html_code=".", const EmpiricalFormula &formula=EmpiricalFormula(), char origin='.', double mono_mass=0.0, double avg_mass=0.0, enum TermSpecificityNuc term_spec=ANYWHERE, const EmpiricalFormula &baseloss_formula=default_baseloss_)
Constructor.
void setNewCode(const String &new_code)
Set the "new" (Modomics) code.
bool isAmbiguous() const
Return whether this is an "ambiguous" modification (representing isobaric modifications on the base/r...
double mono_mass_
monoisotopic mass
Definition Ribonucleotide.h:163
bool isModified() const
Return true if this is a modified ribonucleotide and false otherwise.
void setCode(const String &code)
Set the short name.
void setMonoMass(double mono_mass)
Set the monoisotopic mass of the ribonucleotide.
TermSpecificityNuc
Definition Ribonucleotide.h:33
@ FIVE_PRIME
Definition Ribonucleotide.h:35
@ THREE_PRIME
Definition Ribonucleotide.h:36
@ ANYWHERE
Definition Ribonucleotide.h:34
void setName(const String &name)
Set the name of the ribonucleotide.
const EmpiricalFormula getFormula() const
Get formula for the ribonucleotide.
Ribonucleotide & operator=(const Ribonucleotide &ribo)=default
assignment operator
char origin_
character of unmodified version of ribonucleotide
Definition Ribonucleotide.h:162
static const EmpiricalFormula default_baseloss_
Default value for sum formula after nucleobase loss.
Definition Ribonucleotide.h:155
void setHTMLCode(const String &html_code)
Get the HTML (RNAMods) code.
String html_code_
RNAMods code.
Definition Ribonucleotide.h:160
void setTermSpecificity(enum TermSpecificityNuc term_spec)
Set the terminal specificity.
String getHTMLCode() const
Set the HTML (RNAMods) code.
enum TermSpecificityNuc getTermSpecificity() const
Get the terminal specificity.
char getOrigin() const
Get the code of the unmodified base (e.g., "A", "C", ...)
String code_
short name
Definition Ribonucleotide.h:158
double getMonoMass() const
Get the monoisotopic mass of the ribonucleotide.
void setOrigin(char origin)
Set the code of the unmodified base (e.g., "A", "C", ...)
void setBaselossFormula(const EmpiricalFormula &formula)
Set the sum formula after loss of the nucleobase.
bool operator==(const Ribonucleotide &ribonucleotide) const
Equality operator.
EmpiricalFormula formula_
sum formula
Definition Ribonucleotide.h:161
double getAvgMass() const
Set the average mass of the ribonucleotide.
const String getName() const
Get the name of the ribonucleotide.
friend std::ostream & operator<<(std::ostream &os, const Ribonucleotide &ribo)
ostream iterator to write the residue to a stream
void setFormula(const EmpiricalFormula &formula)
Set the empirical formula for the ribonucleotide.
const String getCode() const
Return the short name.
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
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 hash_char(char c) noexcept
Hash for a character.
Definition HashUtils.h:119
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
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::Ribonucleotide &ribo) const noexcept
Definition Ribonucleotide.h:193