Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
AASequence.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-2013.
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: Andreas Bertsch $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_CHEMISTRY_AASEQUENCE_H
36 #define OPENMS_CHEMISTRY_AASEQUENCE_H
37 
41 #include <OpenMS/CONCEPT/Types.h>
44 
45 #include <vector>
46 #include <iostream>
47 
48 namespace OpenMS
49 {
50  class ResidueDB;
84  class OPENMS_DLLAPI AASequence
85  {
86 
87 public:
88  class Iterator;
89 
94  class OPENMS_DLLAPI ConstIterator
95  {
96 public:
97 
98  // TODO Iterator constructor for ConstIterator
99 
100  typedef const Residue & const_reference;
101  typedef Residue & reference;
102  typedef const Residue * const_pointer;
103  typedef std::vector<const Residue *>::difference_type difference_type;
105  typedef const Residue * pointer;
106  typedef std::random_access_iterator_tag iterator_category;
107 
111  ConstIterator()
113  {
114  }
115 
117  ConstIterator(const std::vector<const Residue *> * vec_ptr, difference_type position)
118  {
119  vector_ = vec_ptr;
120  position_ = position;
121  }
122 
125  vector_(rhs.vector_),
126  position_(rhs.position_)
127  {
128  }
129 
132  vector_(rhs.vector_),
133  position_(rhs.position_)
134  {
135  }
136 
138  virtual ~ConstIterator()
139  {
140  }
141 
143 
146  {
147  if (this != &rhs)
148  {
149  position_ = rhs.position_;
150  vector_ = rhs.vector_;
151  }
152  return *this;
153  }
154 
158  const_reference operator*() const
160  {
161  return *(*vector_)[position_];
162  }
163 
166  {
167  return (*vector_)[position_];
168  }
169 
172  {
173  return ConstIterator(vector_, position_ + diff);
174  }
175 
177  {
178  return position_ - rhs.position_;
179  }
180 
183  {
184  return ConstIterator(vector_, position_ - diff);
185  }
186 
188  bool operator==(const ConstIterator & rhs) const
189  {
190  return vector_ == rhs.vector_ && position_ == rhs.position_;
191  }
192 
194  bool operator!=(const ConstIterator & rhs) const
195  {
196  return vector_ != rhs.vector_ || position_ != rhs.position_;
197  }
198 
201  {
202  ++position_;
203  return *this;
204  }
205 
208  {
209  --position_;
210  return *this;
211  }
212 
214 
215 protected:
216 
217  // pointer to the AASequence vector
218  const std::vector<const Residue *> * vector_;
219 
220  // position in the AASequence vector
222  };
223 
224 
229  class OPENMS_DLLAPI Iterator
230  {
231 public:
232 
234 
235  typedef const Residue & const_reference;
236  typedef Residue & reference;
237  typedef const Residue * const_pointer;
238  typedef const Residue * pointer;
239  typedef std::vector<const Residue *>::difference_type difference_type;
240 
244  Iterator()
246  {
247  }
248 
250  Iterator(std::vector<const Residue *> * vec_ptr, difference_type position)
251  {
252  vector_ = vec_ptr;
253  position_ = position;
254  }
255 
257  Iterator(const Iterator & rhs) :
258  vector_(rhs.vector_),
259  position_(rhs.position_)
260  {
261  }
262 
264  virtual ~Iterator()
265  {
266  }
267 
269 
271  Iterator & operator=(const Iterator & rhs)
272  {
273  if (this != &rhs)
274  {
275  position_ = rhs.position_;
276  vector_ = rhs.vector_;
277  }
278  return *this;
279  }
280 
284  const_reference operator*() const
286  {
287  return *(*vector_)[position_];
288  }
289 
292  {
293  return (*vector_)[position_];
294  }
295 
298  {
299  return (*vector_)[position_];
300  }
301 
304  {
305  return Iterator(vector_, position_ + diff);
306  }
307 
309  {
310  return position_ - rhs.position_;
311  }
312 
315  {
316  return Iterator(vector_, position_ - diff);
317  }
318 
320  bool operator==(const Iterator & rhs) const
321  {
322  return vector_ == rhs.vector_ && position_ == rhs.position_;
323  }
324 
326  bool operator!=(const Iterator & rhs) const
327  {
328  return vector_ != rhs.vector_ || position_ != rhs.position_;
329  }
330 
333  {
334  ++position_;
335  return *this;
336  }
337 
340  {
341  --position_;
342  return *this;
343  }
344 
346 
347 protected:
348 
349  // pointer to the AASequence vector
350  std::vector<const Residue *> * vector_;
351 
352  // position in the AASequence vector
354  };
355 
356 
357 
361  AASequence();
363 
365  AASequence(const AASequence & rhs);
366 
368  AASequence(const String & rhs);
369 
371  AASequence(const char * rhs);
372 
374  virtual ~AASequence();
376 
378  AASequence & operator=(const AASequence & rhs);
379 
381  bool empty() const;
382 
386  String toString() const;
388 
390  String toUnmodifiedString() const;
391 
393  void setModification(Size index, const String & modification);
394 
396  void setNTerminalModification(const String & modification);
397 
399  const String & getNTerminalModification() const;
400 
402  void setCTerminalModification(const String & modification);
403 
405  const String & getCTerminalModification() const;
406 
408  bool setStringSequence(const String & sequence);
409 
411  const Residue & getResidue(SignedSize index) const;
412 
414  const Residue & getResidue(Size index) const;
415 
417  EmpiricalFormula getFormula(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
418 
420  DoubleReal getAverageWeight(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
421 
423  DoubleReal getMonoWeight(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
424 
426  const Residue & operator[](SignedSize index) const;
427 
429  const Residue & operator[](Size index) const;
430 
432  AASequence operator+(const AASequence & peptide) const;
433 
435  AASequence operator+(const String & peptide) const;
436 
438  AASequence operator+(const char * rhs) const;
439 
441  AASequence operator+(const Residue * residue) const;
442 
444  AASequence & operator+=(const AASequence &);
445 
447  AASequence & operator+=(const String &);
448 
450  AASequence & operator+=(const char * rhs);
451 
453  AASequence & operator+=(const Residue * residue);
454 
456  Size size() const;
457 
459  AASequence getPrefix(Size index) const;
460 
462  AASequence getSuffix(Size index) const;
463 
465  AASequence getSubsequence(Size index, UInt number) const;
466 
468  Size getNumberOf(const String & residue) const;
469 
471  void getAAFrequencies(Map<String, Size> & frequency_table) const;
472 
474 
484  bool isValid() const;
485 
487  bool has(const Residue & residue) const;
488 
490  bool has(const String & name) const;
491 
494  bool hasSubsequence(const AASequence & peptide) const;
495 
498  bool hasSubsequence(const String & peptide) const;
499 
502  bool hasPrefix(const AASequence & peptide) const;
503 
506  bool hasPrefix(const String & peptide) const;
507 
510  bool hasSuffix(const AASequence & peptide) const;
511 
514  bool hasSuffix(const String & peptide) const;
515 
517  bool hasNTerminalModification() const;
518 
520  bool hasCTerminalModification() const;
521 
522  // returns true if any of the residues is modified
523  bool isModified() const;
524 
526  bool isModified(Size index) const;
527 
529  bool operator==(const AASequence & rhs) const;
530 
532  bool operator==(const String & rhs) const;
533 
535  bool operator==(const char * rhs) const;
536 
538  bool operator<(const AASequence & rhs) const;
539 
541  bool operator!=(const AASequence & rhs) const;
542 
544  bool operator!=(const String & rhs) const;
545 
547  bool operator!=(const char * rhs) const;
549 
553  inline Iterator begin() { return Iterator(&peptide_, 0); }
554 
555  inline ConstIterator begin() const { return ConstIterator(&peptide_, 0); }
556 
557  inline Iterator end() { return Iterator(&peptide_, (Int) peptide_.size()); }
558 
559  inline ConstIterator end() const { return ConstIterator(&peptide_, (Int) peptide_.size()); }
561 
565  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const AASequence & peptide);
567 
569  friend OPENMS_DLLAPI std::istream & operator>>(std::istream & is, const AASequence & peptide);
571 
572 protected:
573 
574  std::vector<const Residue *> peptide_;
575 
577 
578  void parseString_(std::vector<const Residue *> & sequence, const String & peptide);
579 
580  ResidueDB * getResidueDB_() const;
581 
582  bool valid_;
583 
585 
587  };
588 
589  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const AASequence & peptide);
590 
591  OPENMS_DLLAPI std::istream & operator>>(std::istream & os, const AASequence & peptide);
592 
593 } // namespace OpenMS
594 
595 #endif
String sequence_string_
Definition: AASequence.h:576
Iterator & operator=(const Iterator &rhs)
assignment operator
Definition: AASequence.h:271
virtual ~ConstIterator()
destructor
Definition: AASequence.h:138
std::vector< const Residue * >::difference_type difference_type
Definition: AASequence.h:239
A more convenient string class.
Definition: String.h:56
std::vector< const Residue * > * vector_
Definition: AASequence.h:350
difference_type position_
Definition: AASequence.h:221
const Residue & const_reference
Definition: AASequence.h:235
ConstIterator & operator=(const ConstIterator &rhs)
assignment operator
Definition: AASequence.h:145
Iterator end()
Definition: AASequence.h:557
Residue & reference
Definition: AASequence.h:101
Representation of a modification.
Definition: ResidueModification.h:58
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
difference_type operator-(ConstIterator rhs) const
Definition: AASequence.h:176
const Residue * const_pointer
Definition: AASequence.h:102
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:151
Representation of a peptide/protein sequence.
Definition: AASequence.h:84
Iterator begin()
Definition: AASequence.h:553
Iterator & operator++()
increment operator
Definition: AASequence.h:332
std::random_access_iterator_tag iterator_category
Definition: AASequence.h:106
Representation of a residue.
Definition: Residue.h:64
difference_type position_
Definition: AASequence.h:353
ConstIterator(const ConstIterator &rhs)
copy constructor
Definition: AASequence.h:124
Representation of an empirical formula.
Definition: EmpiricalFormula.h:78
void setModification(int location, int max_size, String modification, OpenMS::AASequence &aas)
helper function that sets a modifiction on a AASequence object
Residue value_type
Definition: AASequence.h:104
bool operator!=(const ConstIterator &rhs) const
inequality operator
Definition: AASequence.h:194
Iterator(const Iterator &rhs)
copy constructor
Definition: AASequence.h:257
const_pointer operator->() const
dereference operator
Definition: AASequence.h:291
pointer operator->()
mutable dereference operator
Definition: AASequence.h:297
DPosition< D, TCoordinateType > operator*(DPosition< D, TCoordinateType > position, typename DPosition< D, TCoordinateType >::CoordinateType scalar)
Scalar multiplication (a bit inefficient)
Definition: DPosition.h:415
const Iterator operator-(difference_type diff) const
backward jump operator
Definition: AASequence.h:314
Definition: Residue.h:363
ConstIterator for AASequence.
Definition: AASequence.h:94
const ConstIterator operator-(difference_type diff) const
backward jump operator
Definition: AASequence.h:182
const Iterator operator+(difference_type diff) const
forward jump operator
Definition: AASequence.h:303
bool operator!=(const Iterator &rhs) const
inequality operator
Definition: AASequence.h:326
Iterator & operator--()
decrement operator
Definition: AASequence.h:339
const std::vector< const Residue * > * vector_
Definition: AASequence.h:218
Residue & reference
Definition: AASequence.h:236
bool valid_
Definition: AASequence.h:582
const Residue * const_pointer
Definition: AASequence.h:237
std::vector< const Residue * >::difference_type difference_type
Definition: AASequence.h:103
residue data base which holds residues
Definition: ResidueDB.h:60
std::istream & operator>>(std::istream &os, const AASequence &peptide)
ConstIterator & operator--()
decrement operator
Definition: AASequence.h:207
ResidueType
Definition: Residue.h:361
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
ConstIterator(const AASequence::Iterator &rhs)
copy constructor from Iterator
Definition: AASequence.h:131
const ResidueModification * n_term_mod_
Definition: AASequence.h:584
bool operator==(const ConstIterator &rhs) const
equality comparator
Definition: AASequence.h:188
std::vector< const Residue * > peptide_
Definition: AASequence.h:574
const ResidueModification * c_term_mod_
Definition: AASequence.h:586
const ConstIterator operator+(difference_type diff) const
forward jump operator
Definition: AASequence.h:171
difference_type operator-(Iterator rhs) const
Definition: AASequence.h:308
Iterator class for AASequence.
Definition: AASequence.h:229
ConstIterator(const std::vector< const Residue * > *vec_ptr, difference_type position)
detailed constructor with pointer to the vector and offset position
Definition: AASequence.h:117
const Residue * pointer
Definition: AASequence.h:238
Iterator(std::vector< const Residue * > *vec_ptr, difference_type position)
detailed constructor with pointer to the vector and offset position
Definition: AASequence.h:250
const Residue & const_reference
Definition: AASequence.h:100
const_pointer operator->() const
dereference operator
Definition: AASequence.h:165
const Residue * pointer
Definition: AASequence.h:105
int Int
Signed integer type.
Definition: Types.h:100
ConstIterator end() const
Definition: AASequence.h:559
bool operator==(const Iterator &rhs) const
equality comparator
Definition: AASequence.h:320
Map class based on the STL map (containing serveral convenience functions)
Definition: Map.h:50
ConstIterator begin() const
Definition: AASequence.h:555
virtual ~Iterator()
destructor
Definition: AASequence.h:264
ConstIterator & operator++()
increment operator
Definition: AASequence.h:200

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:11 using doxygen 1.8.5