OpenMS
Residue.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Andreas Bertsch, Jang Jang Jin$
7 // --------------------------------------------------------------------------
8 //
9 
10 #pragma once
11 
13 #include <OpenMS/CONCEPT/Types.h>
15 
16 #include <iosfwd>
17 #include <set>
18 #include <vector>
19 
20 namespace OpenMS
21 {
22  class ResidueModification;
23 
36  class OPENMS_DLLAPI Residue
37  {
38  friend class ResidueDB;
39 
40 public:
41 
55 
56  inline static const EmpiricalFormula& getInternalToFull()
57  {
58  static const EmpiricalFormula to_full = EmpiricalFormula("H2O");
59  return to_full;
60  }
61 
62  inline static const EmpiricalFormula& getInternalToNTerm()
63  {
64  static const EmpiricalFormula to_full = EmpiricalFormula("H");
65  return to_full;
66  }
67 
68  inline static const EmpiricalFormula& getInternalToCTerm()
69  {
70  static const EmpiricalFormula to_full = EmpiricalFormula("OH");
71  return to_full;
72  }
73 
74  inline static const EmpiricalFormula& getInternalToAIon()
75  {
76  // Mind the "-"
77  static const EmpiricalFormula to_full =
78  getInternalToNTerm() - EmpiricalFormula("CHO");
79  return to_full;
80  }
81 
82  inline static const EmpiricalFormula& getInternalToBIon()
83  {
84  // Mind the "-"
85  static const EmpiricalFormula to_full =
86  getInternalToNTerm() - EmpiricalFormula("H");
87  return to_full;
88  }
89 
90  inline static const EmpiricalFormula& getInternalToCIon()
91  {
92  static const EmpiricalFormula to_full =
93  getInternalToNTerm() + EmpiricalFormula("NH2");
94  return to_full;
95  }
96 
97  inline static const EmpiricalFormula& getInternalToXIon()
98  {
99  // Mind the "-"
100  static const EmpiricalFormula to_full =
101  getInternalToCTerm() + EmpiricalFormula("CO") - EmpiricalFormula("H");
102  return to_full;
103  }
104 
105  inline static const EmpiricalFormula& getInternalToYIon()
106  {
107  static const EmpiricalFormula to_full =
108  getInternalToCTerm() + EmpiricalFormula("H");
109  return to_full;
110  }
111 
112  inline static const EmpiricalFormula& getInternalToZIon()
113  {
114  // Mind the "-"
115  static const EmpiricalFormula to_full =
116  getInternalToCTerm() - EmpiricalFormula("NH2");
117  return to_full;
118  }
119 
121 
126  {
127  Full = 0,
144  SizeOfResidueType
145  };
147 
149  static String getResidueTypeName(const ResidueType res_type);
150 
154 
157 
159  Residue(const Residue&) = default;
160 
162  Residue(Residue&&) = default;
163 
164  // Detailed constructor
165  Residue(const String& name,
166  const String& three_letter_code,
167  const String& one_letter_code,
168  const EmpiricalFormula& formula,
169  double pka = 0,
170  double pkb = 0,
171  double pkc = -1,
172  double gb_sc = 0,
173  double gb_bb_l = 0,
174  double gb_bb_r = 0,
175  const std::set<String>& synonyms = std::set<String>());
176 
178  virtual ~Residue();
180 
184 
186  Residue& operator=(const Residue&) = default;
187 
189  Residue& operator=(Residue&&) & = default;
191 
196  void setName(const String& name);
197 
199  const String& getName() const;
200 
202  void setSynonyms(const std::set<String>& synonyms);
203 
205  void addSynonym(const String& synonym);
206 
208  const std::set<String>& getSynonyms() const;
209 
211  void setThreeLetterCode(const String& three_letter_code);
212 
214  const String& getThreeLetterCode() const;
215 
217  void setOneLetterCode(const String& one_letter_code);
218 
220  const String& getOneLetterCode() const;
221 
224 
226  void setLossFormulas(const std::vector<EmpiricalFormula>&);
227 
230 
232  void setNTermLossFormulas(const std::vector<EmpiricalFormula>&);
233 
235  const std::vector<EmpiricalFormula>& getLossFormulas() const;
236 
238  const std::vector<EmpiricalFormula>& getNTermLossFormulas() const;
239 
241  void setLossNames(const std::vector<String>& name);
242 
244  void setNTermLossNames(const std::vector<String>& name);
245 
247  void addLossName(const String& name);
248 
250  void addNTermLossName(const String& name);
251 
253  const std::vector<String>& getLossNames() const;
254 
256  const std::vector<String>& getNTermLossNames() const;
257 
259  void setFormula(const EmpiricalFormula& formula);
260 
262  EmpiricalFormula getFormula(ResidueType res_type = Full) const;
263 
265  void setAverageWeight(double weight);
266 
268  double getAverageWeight(ResidueType res_type = Full) const;
269 
271  void setMonoWeight(double weight);
272 
274  double getMonoWeight(ResidueType res_type = Full) const;
275 
278 
280  void setModification(const String& name);
281 
284 
288 
291  void setModificationByDiffMonoMass(double diffMonoMass);
292 
294  const String& getModificationName() const;
295 
297  void setLowMassIons(const std::vector<EmpiricalFormula>& low_mass_ions);
298 
300  const std::vector<EmpiricalFormula>& getLowMassIons() const;
301 
303  void setResidueSets(const std::set<String>& residues_sets);
304 
306  void addResidueSet(const String& residue_sets);
307 
309  const std::set<String>& getResidueSets() const;
310 
312  double getPka() const;
313 
315  double getPkb() const;
316 
318  double getPkc() const;
319 
321  double getPiValue() const;
322 
324  void setPka(double value);
325 
327  void setPkb(double value);
328 
330  void setPkc(double value);
331 
333  double getSideChainBasicity() const;
334 
336  void setSideChainBasicity(double gb_sc);
337 
339  double getBackboneBasicityLeft() const;
340 
342  void setBackboneBasicityLeft(double gb_bb_l);
343 
345  double getBackboneBasicityRight() const;
346 
348  void setBackboneBasicityRight(double gb_bb_r);
350 
355  bool hasNeutralLoss() const;
356 
358  bool hasNTermNeutralLosses() const;
359 
361  bool operator==(const Residue& residue) const;
362 
364  bool operator!=(const Residue& residue) const;
365 
367  bool operator==(char one_letter_code) const;
368 
370  bool operator!=(char one_letter_code) const;
371 
373  bool isModified() const;
374 
376  bool isInResidueSet(const String& residue_set);
378 
380  static char residueTypeToIonLetter(const ResidueType& res_type);
381 
384  String toString() const;
385 
387  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
388 
389 protected:
390 
393 
394  std::set<String> synonyms_;
395 
397 
399 
401 
403 
405 
406  double mono_weight_;
407 
410 
411  // loss
412  std::vector<String> loss_names_;
413 
414  std::vector<EmpiricalFormula> loss_formulas_;
415 
416  std::vector<String> NTerm_loss_names_;
417 
418  std::vector<EmpiricalFormula> NTerm_loss_formulas_;
419 
421 
423 
425  std::vector<EmpiricalFormula> low_mass_ions_;
426 
427  // pka values
428  double pka_;
429 
430  // pkb values
431  double pkb_;
432 
433  // pkc values
434  double pkc_;
435 
437  double gb_sc_;
438 
440  double gb_bb_l_;
441 
443  double gb_bb_r_;
444 
446  std::set<String> residue_sets_;
447 
448  // pre-calculated residue type delta weights for more efficient weight calculation
449  double internal_to_full_monoweight_ = getInternalToFull().getMonoWeight();
450  double internal_to_nterm_monoweight_ = getInternalToNTerm().getMonoWeight();
451  double internal_to_cterm_monoweight_ = getInternalToCTerm().getMonoWeight();
452  double internal_to_a_monoweight_ = getInternalToAIon().getMonoWeight();
453  double internal_to_b_monoweight_ = getInternalToBIon().getMonoWeight();
454  double internal_to_c_monoweight_ = getInternalToCIon().getMonoWeight();
455  double internal_to_x_monoweight_ = getInternalToXIon().getMonoWeight();
456  double internal_to_y_monoweight_ = getInternalToYIon().getMonoWeight();
457  double internal_to_z_monoweight_ = getInternalToZIon().getMonoWeight();
458  };
459 
460  // write 'name threelettercode onelettercode formula'
461  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
462 
463 }
Representation of an empirical formula.
Definition: EmpiricalFormula.h:59
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:32
Representation of a modification on an amino acid residue.
Definition: ResidueModification.h:53
Representation of an amino acid residue.
Definition: Residue.h:37
double gb_sc_
SideChainBasicity.
Definition: Residue.h:437
void setPkb(double value)
sets the pkb of the residue
double loss_mono_weight_
Definition: Residue.h:422
bool isInResidueSet(const String &residue_set)
true if the residue is contained in the set
void addLossName(const String &name)
add neutral loss molecule name
double loss_average_weight_
Definition: Residue.h:420
bool hasNTermNeutralLosses() const
true if N-terminal neutral losses are set
static char residueTypeToIonLetter(const ResidueType &res_type)
helper for mapping residue types to letters for Text annotations and labels
double pkb_
Definition: Residue.h:431
double getBackboneBasicityRight() const
returns the C-terminal direction backbone basicity
String toString() const
std::vector< String > loss_names_
Definition: Residue.h:412
Residue()
Default constructor (needed by pyOpenMS)
static const EmpiricalFormula & getInternalToCIon()
Definition: Residue.h:90
std::vector< EmpiricalFormula > NTerm_loss_formulas_
Definition: Residue.h:418
bool operator==(char one_letter_code) const
equality operator for one letter code
const std::vector< String > & getLossNames() const
gets neutral loss name (if there is one, else returns an empty string)
bool hasNeutralLoss() const
true if the residue has neutral loss
void setNTermLossNames(const std::vector< String > &name)
sets the N-terminal loss names
const String & getModificationName() const
returns the name (ID) of the modification, or an empty string if none is set
static const EmpiricalFormula & getInternalToNTerm()
Definition: Residue.h:62
Residue & operator=(Residue &&) &=default
Move assignment operator.
String name_
the name of the residue
Definition: Residue.h:392
static const EmpiricalFormula & getInternalToZIon()
Definition: Residue.h:112
EmpiricalFormula getFormula(ResidueType res_type=Full) const
returns the empirical formula of the residue
double getPiValue() const
calculates the isoelectric point using the pk* values
const ResidueModification * modification_
pointer to the modification
Definition: Residue.h:409
void setPkc(double value)
sets the pkc of the residue
static String getResidueTypeName(const ResidueType res_type)
returns the ion name given as a residue type
const String & getOneLetterCode() const
returns the name as one letter code (String of size 1)
const ResidueModification * getModification() const
returns a pointer to the modification, or a null pointer if none is set
void setSynonyms(const std::set< String > &synonyms)
sets the synonyms
static const EmpiricalFormula & getInternalToAIon()
Definition: Residue.h:74
bool operator==(const Residue &residue) const
equality operator
void setLossNames(const std::vector< String > &name)
set the neutral loss molecule name
bool isModified() const
true if the residue is a modified one
void setModification(const String &name)
sets the modification by name; the mod should be present in ModificationsDB
void setPka(double value)
sets the pka of the residue
std::vector< EmpiricalFormula > loss_formulas_
Definition: Residue.h:414
double getPkb() const
returns the pkb of the residue
ResidueType
Definition: Residue.h:126
@ CTerminal
only C-terminus
Definition: Residue.h:130
@ YIon
MS:1001220 peptide bond up to the C-terminus.
Definition: Residue.h:135
@ XIon
MS:1001228 amide/C-alpha bond up to the C-terminus.
Definition: Residue.h:134
@ ZIon
MS:1001230 C-alpha/carbonyl carbon bond.
Definition: Residue.h:136
@ BIonMinusH20
MS:1001222 b ion without water.
Definition: Residue.h:138
@ NTerminal
only N-terminus
Definition: Residue.h:129
@ BIonMinusNH3
MS:1001232 b ion without ammonia.
Definition: Residue.h:140
@ AIon
MS:1001229 N-terminus up to the C-alpha/carbonyl carbon bond.
Definition: Residue.h:131
@ Precursor
MS:1001523 Precursor ion.
Definition: Residue.h:137
@ YIonMinusH20
MS:1001223 y ion without water.
Definition: Residue.h:139
@ NonIdentified
MS:1001240 Non-identified ion.
Definition: Residue.h:142
@ BIon
MS:1001224 N-terminus up to the peptide bond.
Definition: Residue.h:132
@ CIon
MS:1001231 N-terminus up to the amide/C-alpha bond.
Definition: Residue.h:133
@ YIonMinusNH3
MS:1001233 y ion without ammonia.
Definition: Residue.h:141
@ Internal
internal, without any termini
Definition: Residue.h:128
@ Unannotated
no stored annotation
Definition: Residue.h:143
double pkc_
Definition: Residue.h:434
void setBackboneBasicityRight(double gb_bb_r)
sets the C-terminal direction backbone basicity
void setName(const String &name)
sets the name of the residue
const String & getThreeLetterCode() const
returns the name of the residue as three letter code (String of size 3)
const std::vector< EmpiricalFormula > & getLossFormulas() const
returns the neutral loss formulas
void setSideChainBasicity(double gb_sc)
sets the side chain basicity
std::vector< EmpiricalFormula > low_mass_ions_
low mass markers like immonium ions
Definition: Residue.h:425
double gb_bb_l_
BackboneBasicityLeft.
Definition: Residue.h:440
void setModification(const ResidueModification &mod)
void setLowMassIons(const std::vector< EmpiricalFormula > &low_mass_ions)
sets the low mass marker ions as a vector of formulas
double getSideChainBasicity() const
returns the side chain basicity
static const EmpiricalFormula & getInternalToCTerm()
Definition: Residue.h:68
const std::set< String > & getResidueSets() const
returns the residue sets this residue is contained in (e.g. Natural20)
const std::set< String > & getSynonyms() const
returns the synonyms
Residue(Residue &&)=default
Move constructor.
virtual ~Residue()
Destructor.
friend std::ostream & operator<<(std::ostream &os, const Residue &residue)
ostream iterator to write the residue to a stream
void addNTermLossName(const String &name)
adds a N-terminal loss name
const std::vector< String > & getNTermLossNames() const
returns the N-terminal loss names
std::vector< String > NTerm_loss_names_
Definition: Residue.h:416
void setResidueSets(const std::set< String > &residues_sets)
sets the residue sets the amino acid is contained in (e.g. Natural20)
void setOneLetterCode(const String &one_letter_code)
sets the name as one letter code (String of size 1)
double average_weight_
Definition: Residue.h:404
static const EmpiricalFormula & getInternalToXIon()
Definition: Residue.h:97
double getBackboneBasicityLeft() const
returns the backbone basicity if located in N-terminal direction
double pka_
Definition: Residue.h:428
void setModification(const ResidueModification *mod)
sets the modification by existing ResMod (make sure it exists in ModificationsDB)
static const EmpiricalFormula & getInternalToBIon()
Definition: Residue.h:82
String three_letter_code_
Definition: Residue.h:396
void setModificationByDiffMonoMass(double diffMonoMass)
const std::vector< EmpiricalFormula > & getLowMassIons() const
returns a vector of formulas with the low mass markers of the residue
String one_letter_code_
Definition: Residue.h:398
void setAverageWeight(double weight)
sets average weight of the residue (must be full, with N and C-terminus)
const String & getName() const
returns the name of the residue
std::set< String > synonyms_
Definition: Residue.h:394
static const EmpiricalFormula & getInternalToYIon()
Definition: Residue.h:105
double getPka() const
returns the pka of the residue
void setThreeLetterCode(const String &three_letter_code)
sets the name of the residue as three letter code (String of size 3)
bool operator!=(char one_letter_code) const
equality operator for one letter code
static const EmpiricalFormula & getInternalToFull()
Definition: Residue.h:56
void addNTermLossFormula(const EmpiricalFormula &)
adds N-terminal losses
void addLossFormula(const EmpiricalFormula &)
adds a neutral loss formula
double getAverageWeight(ResidueType res_type=Full) const
returns average weight of the residue
void addSynonym(const String &synonym)
adds a synonym
Residue(const Residue &)=default
Copy constructor.
double mono_weight_
Definition: Residue.h:406
EmpiricalFormula internal_formula_
Definition: Residue.h:402
double gb_bb_r_
BackboneBasicityRight.
Definition: Residue.h:443
void addResidueSet(const String &residue_sets)
adds a residue set to the residue sets (e.g. Natural20)
void setNTermLossFormulas(const std::vector< EmpiricalFormula > &)
sets the N-terminal losses
std::set< String > residue_sets_
residue sets this amino acid is contained in
Definition: Residue.h:446
EmpiricalFormula formula_
Definition: Residue.h:400
void setBackboneBasicityLeft(double gb_bb_l)
sets the N-terminal direction backbone basicity
Residue(const String &name, const String &three_letter_code, const String &one_letter_code, const EmpiricalFormula &formula, double pka=0, double pkb=0, double pkc=-1, double gb_sc=0, double gb_bb_l=0, double gb_bb_r=0, const std::set< String > &synonyms=std::set< String >())
double getPkc() const
returns the pkc of the residue if it exists otherwise -1
void setFormula(const EmpiricalFormula &formula)
set empirical formula of the residue (must be full, with N and C-terminus)
double getMonoWeight(ResidueType res_type=Full) const
returns monoisotopic weight of the residue
void setLossFormulas(const std::vector< EmpiricalFormula > &)
sets the neutral loss formulas
void setMonoWeight(double weight)
sets monoisotopic weight of the residue (must be full, with N and C-terminus)
bool operator!=(const Residue &residue) const
inequality operator
Residue & operator=(const Residue &)=default
Assignment operator.
const std::vector< EmpiricalFormula > & getNTermLossFormulas() const
returns N-terminal loss formulas
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
sets the modification of AA at index by providing a pointer to a in the