00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OPENMS_CHEMISTRY_AASEQUENCE_H
00028 #define OPENMS_CHEMISTRY_AASEQUENCE_H
00029
00030 #include <OpenMS/CHEMISTRY/EmpiricalFormula.h>
00031 #include <OpenMS/DATASTRUCTURES/String.h>
00032 #include <OpenMS/DATASTRUCTURES/HashMap.h>
00033 #include <OpenMS/CONCEPT/Types.h>
00034 #include <OpenMS/CHEMISTRY/Residue.h>
00035
00036 #include <vector>
00037 #include <iostream>
00038
00039 namespace OpenMS
00040 {
00041 class ResidueDB;
00042
00048 class AASequence
00049 {
00050 public:
00051
00055 typedef std::vector<const Residue*>::iterator iterator;
00056 typedef std::vector<const Residue*>::const_iterator const_iterator;
00057 typedef std::vector<const Residue*>::iterator Iterator;
00058 typedef std::vector<const Residue*>::const_iterator ConstIterator;
00060
00064
00065 AASequence();
00066
00068 AASequence(const AASequence& rhs);
00069
00071 AASequence(const String& rhs) throw(Exception::ParseError);
00072
00074 AASequence(ResidueDB* res_db);
00075
00077 AASequence(ConstIterator begin, ConstIterator end);
00078
00080 virtual ~AASequence();
00082
00084 AASequence& operator = (const AASequence& rhs);
00085
00089
00090 const Residue* getResidue(Int index) const throw(Exception::IndexUnderflow, Exception::IndexOverflow);
00091
00093 const Residue* getResidue(UInt index) const throw(Exception::IndexOverflow);
00094
00096 EmpiricalFormula getFormula(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
00097
00099 DoubleReal getAverageWeight(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
00100
00102 DoubleReal getMonoWeight(Residue::ResidueType type = Residue::Full, Int charge = 0) const;
00103
00105 HashMap<const EmpiricalFormula*, UInt> getNeutralLosses() const;
00106
00108 const Residue* operator [] (Int index) const throw(Exception::IndexUnderflow, Exception::IndexOverflow);
00109
00111 const Residue* operator [] (UInt index) const throw(Exception::IndexOverflow);
00112
00114 AASequence operator + (const AASequence& peptide) const;
00115
00117 AASequence operator + (const String& peptide) const throw(Exception::ParseError);
00118
00120 AASequence& operator += (const AASequence&);
00121
00123 AASequence& operator += (const String&) throw(Exception::ParseError);
00124
00128 void setResidueDB(ResidueDB* res_db = 0);
00129
00131 UInt size() const;
00132
00134 AASequence getPrefix(UInt index) const throw(Exception::IndexOverflow);
00135
00137 AASequence getSuffix(UInt index) const throw(Exception::IndexOverflow);
00138
00140 AASequence getSubsequence(UInt index, UInt number) const throw(Exception::IndexOverflow);
00142
00146
00147 bool has(const Residue* residue) const;
00148
00150 bool has(const String& name) const;
00151
00153 bool hasSubsequence(const AASequence& peptide) const;
00154
00156 bool hasSubsequence(const String& peptide) const throw(Exception::ParseError);
00157
00159 bool hasPrefix(const AASequence& peptide) const;
00160
00162 bool hasPrefix(const String& peptide) const throw(Exception::ParseError);
00163
00165 bool hasSuffix(const AASequence& peptide) const;
00166
00168 bool hasSuffix(const String& peptide) const throw(Exception::ParseError);
00169
00171 bool operator == (const AASequence&) const;
00172
00174 bool operator == (const String&) const throw(Exception::ParseError);
00175
00177 bool operator != (const AASequence&) const;
00178
00180 bool operator != (const String&) const throw(Exception::ParseError);
00182
00186 inline Iterator begin() { return peptide_.begin(); }
00187
00188 inline ConstIterator begin() const { return peptide_.begin(); }
00189
00190 inline Iterator end() { return peptide_.end(); }
00191
00192 inline ConstIterator end() const { return peptide_.end(); }
00194
00196 friend std::ostream& operator << (std::ostream& os, const AASequence& peptide);
00197
00199 friend std::istream& operator >> (std::istream& is, const AASequence& peptide);
00200
00201 protected:
00202
00203 ResidueDB* getResidueDB_() const;
00204
00205 static ResidueDB* custom_res_db_;
00206
00207 std::vector<const Residue*> peptide_;
00208
00209 void parseString_(std::vector<const Residue*>& sequence, const String& peptide) const throw(Exception::ParseError);
00210
00211 };
00212
00213 std::ostream& operator << (std::ostream& os, const AASequence& peptide);
00214
00215 std::istream& operator >> (std::istream& os, const AASequence& peptide);
00216
00217 }
00218
00219 #endif