OpenMS  2.8.0
Residue.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: Andreas Bertsch, Jang Jang Jin$
33 // --------------------------------------------------------------------------
34 //
35 
36 #pragma once
37 
39 #include <OpenMS/CONCEPT/Types.h>
41 
42 #include <iosfwd>
43 #include <set>
44 #include <vector>
45 
46 namespace OpenMS
47 {
48  class ResidueModification;
49 
62  class OPENMS_DLLAPI Residue
63  {
64  friend class ResidueDB;
65 
66 public:
67 
81 
82  inline static const EmpiricalFormula& getInternalToFull()
83  {
84  static const EmpiricalFormula to_full = EmpiricalFormula("H2O");
85  return to_full;
86  }
87 
88  inline static const EmpiricalFormula& getInternalToNTerm()
89  {
90  static const EmpiricalFormula to_full = EmpiricalFormula("H");
91  return to_full;
92  }
93 
94  inline static const EmpiricalFormula& getInternalToCTerm()
95  {
96  static const EmpiricalFormula to_full = EmpiricalFormula("OH");
97  return to_full;
98  }
99 
100  inline static const EmpiricalFormula& getInternalToAIon()
101  {
102  // Mind the "-"
103  static const EmpiricalFormula to_full =
104  getInternalToNTerm() - EmpiricalFormula("CHO");
105  return to_full;
106  }
107 
108  inline static const EmpiricalFormula& getInternalToBIon()
109  {
110  // Mind the "-"
111  static const EmpiricalFormula to_full =
112  getInternalToNTerm() - EmpiricalFormula("H");
113  return to_full;
114  }
115 
116  inline static const EmpiricalFormula& getInternalToCIon()
117  {
118  static const EmpiricalFormula to_full =
119  getInternalToNTerm() + EmpiricalFormula("NH2");
120  return to_full;
121  }
122 
123  inline static const EmpiricalFormula& getInternalToXIon()
124  {
125  // Mind the "-"
126  static const EmpiricalFormula to_full =
127  getInternalToCTerm() + EmpiricalFormula("CO") - EmpiricalFormula("H");
128  return to_full;
129  }
130 
131  inline static const EmpiricalFormula& getInternalToYIon()
132  {
133  static const EmpiricalFormula to_full =
134  getInternalToCTerm() + EmpiricalFormula("H");
135  return to_full;
136  }
137 
138  inline static const EmpiricalFormula& getInternalToZIon()
139  {
140  // Mind the "-"
141  static const EmpiricalFormula to_full =
142  getInternalToCTerm() - EmpiricalFormula("NH2");
143  return to_full;
144  }
145 
147 
152  {
153  Full = 0,
170  SizeOfResidueType
171  };
173 
175  static String getResidueTypeName(const ResidueType res_type);
176 
177 
181 
184 
186  Residue(const Residue&) = default;
187 
189  Residue(Residue&&) = default;
190 
191  // Detailed constructor
192  Residue(const String& name,
193  const String& three_letter_code,
194  const String& one_letter_code,
195  const EmpiricalFormula& formula,
196  double pka = 0,
197  double pkb = 0,
198  double pkc = -1,
199  double gb_sc = 0,
200  double gb_bb_l = 0,
201  double gb_bb_r = 0,
202  const std::set<String>& synonyms = std::set<String>());
203 
205  virtual ~Residue();
207 
211 
213  Residue& operator=(const Residue&) = default;
214 
216  Residue& operator=(Residue&&) & = default;
218 
223  void setName(const String& name);
224 
226  const String& getName() const;
227 
229  void setSynonyms(const std::set<String>& synonyms);
230 
232  void addSynonym(const String& synonym);
233 
235  const std::set<String>& getSynonyms() const;
236 
238  void setThreeLetterCode(const String& three_letter_code);
239 
241  const String& getThreeLetterCode() const;
242 
244  void setOneLetterCode(const String& one_letter_code);
245 
247  const String& getOneLetterCode() const;
248 
251 
253  void setLossFormulas(const std::vector<EmpiricalFormula>&);
254 
257 
259  void setNTermLossFormulas(const std::vector<EmpiricalFormula>&);
260 
262  const std::vector<EmpiricalFormula>& getLossFormulas() const;
263 
265  const std::vector<EmpiricalFormula>& getNTermLossFormulas() const;
266 
268  void setLossNames(const std::vector<String>& name);
269 
271  void setNTermLossNames(const std::vector<String>& name);
272 
274  void addLossName(const String& name);
275 
277  void addNTermLossName(const String& name);
278 
280  const std::vector<String>& getLossNames() const;
281 
283  const std::vector<String>& getNTermLossNames() const;
284 
286  void setFormula(const EmpiricalFormula& formula);
287 
289  EmpiricalFormula getFormula(ResidueType res_type = Full) const;
290 
292  void setAverageWeight(double weight);
293 
295  double getAverageWeight(ResidueType res_type = Full) const;
296 
298  void setMonoWeight(double weight);
299 
301  double getMonoWeight(ResidueType res_type = Full) const;
302 
305 
307  void setModification(const String& name);
308 
311 
315 
318  void setModificationByDiffMonoMass(double diffMonoMass);
319 
321  const String& getModificationName() const;
322 
324  void setLowMassIons(const std::vector<EmpiricalFormula>& low_mass_ions);
325 
327  const std::vector<EmpiricalFormula>& getLowMassIons() const;
328 
330  void setResidueSets(const std::set<String>& residues_sets);
331 
333  void addResidueSet(const String& residue_sets);
334 
336  const std::set<String>& getResidueSets() const;
337 
339  double getPka() const;
340 
342  double getPkb() const;
343 
345  double getPkc() const;
346 
348  double getPiValue() const;
349 
351  void setPka(double value);
352 
354  void setPkb(double value);
355 
357  void setPkc(double value);
358 
360  double getSideChainBasicity() const;
361 
363  void setSideChainBasicity(double gb_sc);
364 
366  double getBackboneBasicityLeft() const;
367 
369  void setBackboneBasicityLeft(double gb_bb_l);
370 
372  double getBackboneBasicityRight() const;
373 
375  void setBackboneBasicityRight(double gb_bb_r);
377 
382  bool hasNeutralLoss() const;
383 
385  bool hasNTermNeutralLosses() const;
386 
388  bool operator==(const Residue& residue) const;
389 
391  bool operator!=(const Residue& residue) const;
392 
394  bool operator==(char one_letter_code) const;
395 
397  bool operator!=(char one_letter_code) const;
398 
400  bool isModified() const;
401 
403  bool isInResidueSet(const String& residue_set);
405 
407  static char residueTypeToIonLetter(const ResidueType& res_type);
408 
411  String toString() const;
412 
414  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
415 
416 protected:
417 
418  // basic
420 
421  std::set<String> synonyms_;
422 
424 
426 
428 
430 
432 
433  double mono_weight_;
434 
435  // modification
437 
438  // loss
439  std::vector<String> loss_names_;
440 
441  std::vector<EmpiricalFormula> loss_formulas_;
442 
443  std::vector<String> NTerm_loss_names_;
444 
445  std::vector<EmpiricalFormula> NTerm_loss_formulas_;
446 
448 
450 
451  // low mass markers like immonium ions
452  std::vector<EmpiricalFormula> low_mass_ions_;
453 
454  // pka values
455  double pka_;
456 
457  // pkb values
458  double pkb_;
459 
460  // pkc values
461  double pkc_;
462 
463  double gb_sc_;
464 
465  double gb_bb_l_;
466 
467  double gb_bb_r_;
468 
469  // residue sets this amino acid is contained in
470  std::set<String> residue_sets_;
471 
472  // precalculated residue type delta weights for more efficient weight calculation
473  double internal_to_full_monoweight_ = getInternalToFull().getMonoWeight();
474  double internal_to_nterm_monoweight_ = getInternalToNTerm().getMonoWeight();
475  double internal_to_cterm_monoweight_ = getInternalToCTerm().getMonoWeight();
476  double internal_to_a_monoweight_ = getInternalToAIon().getMonoWeight();
477  double internal_to_b_monoweight_ = getInternalToBIon().getMonoWeight();
478  double internal_to_c_monoweight_ = getInternalToCIon().getMonoWeight();
479  double internal_to_x_monoweight_ = getInternalToXIon().getMonoWeight();
480  double internal_to_y_monoweight_ = getInternalToYIon().getMonoWeight();
481  double internal_to_z_monoweight_ = getInternalToZIon().getMonoWeight();
482  };
483 
484  // write 'name threelettercode onelettercode formula'
485  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Residue& residue);
486 
487 }
Representation of an empirical formula.
Definition: EmpiricalFormula.h:82
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:58
Representation of a modification.
Definition: ResidueModification.h:77
Representation of a residue.
Definition: Residue.h:63
double gb_sc_
Definition: Residue.h:463
void setPkb(double value)
sets the pkb of the residue
double loss_mono_weight_
Definition: Residue.h:449
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:447
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:458
double getBackboneBasicityRight() const
returns the C-terminal direction backbone basicitiy
String toString() const
std::vector< String > loss_names_
Definition: Residue.h:439
Residue()
Default constructor (needed by pyOpenMS)
static const EmpiricalFormula & getInternalToCIon()
Definition: Residue.h:116
std::vector< EmpiricalFormula > NTerm_loss_formulas_
Definition: Residue.h:445
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:88
Residue & operator=(Residue &&) &=default
Move assignment operator.
String name_
Definition: Residue.h:419
static const EmpiricalFormula & getInternalToZIon()
Definition: Residue.h:138
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_
Definition: Residue.h:436
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 zero if none is set
void setSynonyms(const std::set< String > &synonyms)
sets the synonyms
static const EmpiricalFormula & getInternalToAIon()
Definition: Residue.h:100
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:441
double getPkb() const
returns the pkb of the residue
ResidueType
Definition: Residue.h:152
@ CTerminal
only C-terminus
Definition: Residue.h:156
@ YIon
MS:1001220 peptide bond up to the C-terminus.
Definition: Residue.h:161
@ XIon
MS:1001228 amide/C-alpha bond up to the C-terminus.
Definition: Residue.h:160
@ ZIon
MS:1001230 C-alpha/carbonyl carbon bond.
Definition: Residue.h:162
@ BIonMinusH20
MS:1001222 b ion without water.
Definition: Residue.h:164
@ NTerminal
only N-terminus
Definition: Residue.h:155
@ BIonMinusNH3
MS:1001232 b ion without ammonia.
Definition: Residue.h:166
@ AIon
MS:1001229 N-terminus up to the C-alpha/carbonyl carbon bond.
Definition: Residue.h:157
@ Precursor
MS:1001523 Precursor ion.
Definition: Residue.h:163
@ YIonMinusH20
MS:1001223 y ion without water.
Definition: Residue.h:165
@ NonIdentified
MS:1001240 Non-identified ion.
Definition: Residue.h:168
@ BIon
MS:1001224 N-terminus up to the peptide bond.
Definition: Residue.h:158
@ CIon
MS:1001231 N-terminus up to the amide/C-alpha bond.
Definition: Residue.h:159
@ YIonMinusNH3
MS:1001233 y ion without ammonia.
Definition: Residue.h:167
@ Internal
internal, without any termini
Definition: Residue.h:154
@ Unannotated
no stored annotation
Definition: Residue.h:169
double pkc_
Definition: Residue.h:461
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_
Definition: Residue.h:452
double gb_bb_l_
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:94
const std::set< String > & getResidueSets() const
returns the residue sets this residue is contained in
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:443
void setResidueSets(const std::set< String > &residues_sets)
sets the residue sets the amino acid is contained in
void setOneLetterCode(const String &one_letter_code)
sets the name as one letter code (String of size 1)
double average_weight_
Definition: Residue.h:431
static const EmpiricalFormula & getInternalToXIon()
Definition: Residue.h:123
double getBackboneBasicityLeft() const
returns the backbone basicitiy if located in N-terminal direction
double pka_
Definition: Residue.h:455
void setModification(const ResidueModification *mod)
sets the modification by existing ResMod (make sure it exists in ModificationDB)
static const EmpiricalFormula & getInternalToBIon()
Definition: Residue.h:108
String three_letter_code_
Definition: Residue.h:423
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:425
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:421
static const EmpiricalFormula & getInternalToYIon()
Definition: Residue.h:131
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:82
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:433
EmpiricalFormula internal_formula_
Definition: Residue.h:429
double gb_bb_r_
Definition: Residue.h:467
void addResidueSet(const String &residue_sets)
adds a residue set to the residue sets
void setNTermLossFormulas(const std::vector< EmpiricalFormula > &)
sets the N-terminal losses
std::set< String > residue_sets_
Definition: Residue.h:470
EmpiricalFormula formula_
Definition: Residue.h:427
void setBackboneBasicityLeft(double gb_bb_l)
sets the N-terminal direction backbone basicitiy
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:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
sets the modification of AA at index by providing a pointer to a in the