OpenMS
Residue.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, 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 
58 
59  inline static const EmpiricalFormula& getInternalToFull()
60  {
61  static const EmpiricalFormula to_full = EmpiricalFormula("H2O");
62  return to_full;
63  }
64 
65  inline static const EmpiricalFormula& getInternalToNTerm()
66  {
67  static const EmpiricalFormula to_full = EmpiricalFormula("H");
68  return to_full;
69  }
70 
71  inline static const EmpiricalFormula& getInternalToCTerm()
72  {
73  static const EmpiricalFormula to_full = EmpiricalFormula("OH");
74  return to_full;
75  }
76 
77  inline static const EmpiricalFormula& getInternalToAIon()
78  {
79  // Mind the "-"
80  static const EmpiricalFormula to_full =
81  getInternalToNTerm() - EmpiricalFormula("CHO");
82  return to_full;
83  }
84 
85  inline static const EmpiricalFormula& getInternalToBIon()
86  {
87  // Mind the "-"
88  static const EmpiricalFormula to_full =
89  getInternalToNTerm() - EmpiricalFormula("H");
90  return to_full;
91  }
92 
93  inline static const EmpiricalFormula& getInternalToCIon()
94  {
95  static const EmpiricalFormula to_full =
96  getInternalToNTerm() + EmpiricalFormula("NH2");
97  return to_full;
98  }
99 
100  inline static const EmpiricalFormula& getInternalToXIon()
101  {
102  // Mind the "-"
103  static const EmpiricalFormula to_full =
104  getInternalToCTerm() + EmpiricalFormula("CO") - EmpiricalFormula("H");
105  return to_full;
106  }
107 
108  inline static const EmpiricalFormula& getInternalToYIon()
109  {
110  static const EmpiricalFormula to_full =
111  getInternalToCTerm() + EmpiricalFormula("H");
112  return to_full;
113  }
114 
115  inline static const EmpiricalFormula& getInternalToZIon()
116  {
117  // Mind the "-"
118  static const EmpiricalFormula to_full =
119  getInternalToCTerm() - EmpiricalFormula("NH2");
120  return to_full;
121  }
122 
123  inline static const EmpiricalFormula& getInternalToZp1Ion()
124  {
125  // Mind the "-"
126  static const EmpiricalFormula to_full =
127  getInternalToCTerm() - EmpiricalFormula("NH");
128  return to_full;
129  }
130 
131  inline static const EmpiricalFormula& getInternalToZp2Ion()
132  {
133  // Mind the "-"
134  static const EmpiricalFormula to_full =
135  getInternalToCTerm() - EmpiricalFormula("N");
136  return to_full;
137  }
138 
140 
144 
149  {
150  Full = 0,
169  SizeOfResidueType
170  };
172 
174  static String getResidueTypeName(const ResidueType res_type);
175 
179 
182 
184  Residue(const Residue&) = default;
185 
187  Residue(Residue&&) = default;
188 
189  // Detailed constructor
190  Residue(const String& name,
191  const String& three_letter_code,
192  const String& one_letter_code,
193  const EmpiricalFormula& formula,
194  double pka = 0,
195  double pkb = 0,
196  double pkc = -1,
197  double gb_sc = 0,
198  double gb_bb_l = 0,
199  double gb_bb_r = 0,
200  const std::set<String>& synonyms = std::set<String>());
201 
203  virtual ~Residue();
205 
209 
211  Residue& operator=(const Residue&) = default;
212 
214  Residue& operator=(Residue&&) & = default;
216 
221  void setName(const String& name);
222 
224  const String& getName() const;
225 
227  void setSynonyms(const std::set<String>& synonyms);
228 
230  void addSynonym(const String& synonym);
231 
233  const std::set<String>& getSynonyms() const;
234 
236  void setThreeLetterCode(const String& three_letter_code);
237 
239  const String& getThreeLetterCode() const;
240 
242  void setOneLetterCode(const String& one_letter_code);
243 
245  const String& getOneLetterCode() const;
246 
249 
251  void setLossFormulas(const std::vector<EmpiricalFormula>&);
252 
255 
257  void setNTermLossFormulas(const std::vector<EmpiricalFormula>&);
258 
260  const std::vector<EmpiricalFormula>& getLossFormulas() const;
261 
263  const std::vector<EmpiricalFormula>& getNTermLossFormulas() const;
264 
266  void setLossNames(const std::vector<String>& name);
267 
269  void setNTermLossNames(const std::vector<String>& name);
270 
272  void addLossName(const String& name);
273 
275  void addNTermLossName(const String& name);
276 
278  const std::vector<String>& getLossNames() const;
279 
281  const std::vector<String>& getNTermLossNames() const;
282 
284  void setFormula(const EmpiricalFormula& formula);
285 
287  EmpiricalFormula getFormula(ResidueType res_type = Full) const;
288 
290  void setAverageWeight(double weight);
291 
293  double getAverageWeight(ResidueType res_type = Full) const;
294 
296  void setMonoWeight(double weight);
297 
299  double getMonoWeight(ResidueType res_type = Full) const;
300 
303 
305  void setModification(const String& name);
306 
309 
313 
316  void setModificationByDiffMonoMass(double diffMonoMass);
317 
319  const String& getModificationName() const;
320 
322  void setLowMassIons(const std::vector<EmpiricalFormula>& low_mass_ions);
323 
325  const std::vector<EmpiricalFormula>& getLowMassIons() const;
326 
328  void setResidueSets(const std::set<String>& residues_sets);
329 
331  void addResidueSet(const String& residue_sets);
332 
334  const std::set<String>& getResidueSets() const;
335 
337  double getPka() const;
338 
340  double getPkb() const;
341 
343  double getPkc() const;
344 
346  double getPiValue() const;
347 
349  void setPka(double value);
350 
352  void setPkb(double value);
353 
355  void setPkc(double value);
356 
358  double getSideChainBasicity() const;
359 
361  void setSideChainBasicity(double gb_sc);
362 
364  double getBackboneBasicityLeft() const;
365 
367  void setBackboneBasicityLeft(double gb_bb_l);
368 
370  double getBackboneBasicityRight() const;
371 
373  void setBackboneBasicityRight(double gb_bb_r);
375 
380  bool hasNeutralLoss() const;
381 
383  bool hasNTermNeutralLosses() const;
384 
386  bool operator==(const Residue& residue) const;
387 
389  bool operator!=(const Residue& residue) const;
390 
392  bool operator==(char one_letter_code) const;
393 
395  bool operator!=(char one_letter_code) const;
396 
398  bool isModified() const;
399 
401  bool isInResidueSet(const String& residue_set);
403 
405  static std::string residueTypeToIonLetter(const ResidueType& res_type);
406 
409  String toString() const;
410 
412  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
413 
414 protected:
415 
418 
419  std::set<String> synonyms_;
420 
422 
424 
426 
428 
430 
431  double mono_weight_;
432 
435 
436  // loss
437  std::vector<String> loss_names_;
438 
439  std::vector<EmpiricalFormula> loss_formulas_;
440 
441  std::vector<String> NTerm_loss_names_;
442 
443  std::vector<EmpiricalFormula> NTerm_loss_formulas_;
444 
446 
448 
450  std::vector<EmpiricalFormula> low_mass_ions_;
451 
452  // pka values
453  double pka_;
454 
455  // pkb values
456  double pkb_;
457 
458  // pkc values
459  double pkc_;
460 
462  double gb_sc_;
463 
465  double gb_bb_l_;
466 
468  double gb_bb_r_;
469 
471  std::set<String> residue_sets_;
472 
473  // pre-calculated residue type delta weights for more efficient weight calculation
474  static const double internal_to_full_monoweight_;
475  static const double internal_to_nterm_monoweight_;
476  static const double internal_to_cterm_monoweight_;
477  static const double internal_to_a_monoweight_;
478  static const double internal_to_b_monoweight_;
479  static const double internal_to_c_monoweight_;
480  static const double internal_to_x_monoweight_;
481  static const double internal_to_y_monoweight_;
482  static const double internal_to_z_monoweight_;
483  static const double internal_to_zp1_monoweight_;
484  static const double internal_to_zp2_monoweight_;
485  };
486 
487  // write 'name threelettercode onelettercode formula'
488  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
489 
490 }
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
static const double internal_to_b_monoweight_
Definition: Residue.h:478
static const double internal_to_x_monoweight_
Definition: Residue.h:480
double gb_sc_
SideChainBasicity.
Definition: Residue.h:462
void setPkb(double value)
sets the pkb of the residue
double loss_mono_weight_
Definition: Residue.h:447
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:445
bool hasNTermNeutralLosses() const
true if N-terminal neutral losses are set
static const double internal_to_z_monoweight_
Definition: Residue.h:482
double pkb_
Definition: Residue.h:456
double getBackboneBasicityRight() const
returns the C-terminal direction backbone basicity
static const double internal_to_a_monoweight_
Definition: Residue.h:477
static const double internal_to_zp1_monoweight_
Definition: Residue.h:483
String toString() const
std::vector< String > loss_names_
Definition: Residue.h:437
Residue()
Default constructor (needed by pyOpenMS)
static const EmpiricalFormula & getInternalToCIon()
Definition: Residue.h:93
std::vector< EmpiricalFormula > NTerm_loss_formulas_
Definition: Residue.h:443
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)
static const double internal_to_nterm_monoweight_
Definition: Residue.h:475
static const double internal_to_zp2_monoweight_
Definition: Residue.h:484
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:65
Residue & operator=(Residue &&) &=default
Move assignment operator.
String name_
the name of the residue
Definition: Residue.h:417
static const EmpiricalFormula & getInternalToZIon()
Definition: Residue.h:115
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:434
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
static const double internal_to_full_monoweight_
Definition: Residue.h:474
static const double internal_to_y_monoweight_
Definition: Residue.h:481
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
static const double internal_to_cterm_monoweight_
Definition: Residue.h:476
void setSynonyms(const std::set< String > &synonyms)
sets the synonyms
static const EmpiricalFormula & getInternalToAIon()
Definition: Residue.h:77
static const EmpiricalFormula & getInternalToZp2Ion()
Definition: Residue.h:131
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:439
double getPkb() const
returns the pkb of the residue
ResidueType
Definition: Residue.h:149
@ CTerminal
only C-terminus
Definition: Residue.h:153
@ YIon
MS:1001220 peptide bond up to the C-terminus.
Definition: Residue.h:158
@ XIon
MS:1001228 amide/C-alpha bond up to the C-terminus.
Definition: Residue.h:157
@ Zp2Ion
MS:1001230 C-alpha/carbonyl carbon bond (free radical, z+2 "ion" with additional abstracted hydrogen)...
Definition: Residue.h:161
@ ZIon
MS:1001230 C-alpha/carbonyl carbon bond [CID fragment].
Definition: Residue.h:159
@ BIonMinusH20
MS:1001222 b ion without water.
Definition: Residue.h:163
@ NTerminal
only N-terminus
Definition: Residue.h:152
@ BIonMinusNH3
MS:1001232 b ion without ammonia.
Definition: Residue.h:165
@ AIon
MS:1001229 N-terminus up to the C-alpha/carbonyl carbon bond.
Definition: Residue.h:154
@ Precursor
MS:1001523 Precursor ion.
Definition: Residue.h:162
@ YIonMinusH20
MS:1001223 y ion without water.
Definition: Residue.h:164
@ NonIdentified
MS:1001240 Non-identified ion.
Definition: Residue.h:167
@ BIon
MS:1001224 N-terminus up to the peptide bond.
Definition: Residue.h:155
@ Zp1Ion
MS:1001230 C-alpha/carbonyl carbon bond (free radical, z+1 "ion") [main EAD fragment].
Definition: Residue.h:160
@ CIon
MS:1001231 N-terminus up to the amide/C-alpha bond.
Definition: Residue.h:156
@ YIonMinusNH3
MS:1001233 y ion without ammonia.
Definition: Residue.h:166
@ Internal
internal residue, without any termini
Definition: Residue.h:151
@ Unannotated
no stored annotation
Definition: Residue.h:168
double pkc_
Definition: Residue.h:459
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:450
double gb_bb_l_
BackboneBasicityLeft.
Definition: Residue.h:465
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:71
static std::string residueTypeToIonLetter(const ResidueType &res_type)
helper for mapping residue types to letters for Text annotations and labels
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.
static const double internal_to_c_monoweight_
Definition: Residue.h:479
virtual ~Residue()
Destructor.
friend std::ostream & operator<<(std::ostream &os, const Residue &residue)
ostream iterator to write the residue to a stream
static const EmpiricalFormula & getInternalToZp1Ion()
Definition: Residue.h:123
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:441
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:429
static const EmpiricalFormula & getInternalToXIon()
Definition: Residue.h:100
double getBackboneBasicityLeft() const
returns the backbone basicity if located in N-terminal direction
double pka_
Definition: Residue.h:453
void setModification(const ResidueModification *mod)
sets the modification by existing ResMod (make sure it exists in ModificationsDB)
static const EmpiricalFormula & getInternalToBIon()
Definition: Residue.h:85
String three_letter_code_
Definition: Residue.h:421
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:423
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:419
static const EmpiricalFormula & getInternalToYIon()
Definition: Residue.h:108
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:59
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:431
EmpiricalFormula internal_formula_
Definition: Residue.h:427
double gb_bb_r_
BackboneBasicityRight.
Definition: Residue.h:468
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:471
EmpiricalFormula formula_
Definition: Residue.h:425
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: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)