00001
00002
00003
00005 #ifndef DNASTR_H
00006 #define DNASTR_H
00007
00008 #include <string>
00009 #include <dsu.h>
00010 #include <strstream>
00011 #include <stdexcept>
00012 #include <assert.h>
00013
00019 class DnaStr {
00020 public:
00026 DnaStr(const string& str, dsu::Strand_t strnd) : _str(str), _strnd(strnd) { }
00027
00031 const string& getStr() const { return _str; }
00032
00038 double gcPcnt(int = 1, int = -1) const;
00039
00043 dsu::Strand_t getStrnd() const { return _strnd; }
00044
00048 const char operator[](int idx) const
00049 #if _RUNTIME_DEBUG < 3
00050 {
00051 assert(idx >= 1 && (idx-1) < (signed)_str.length());
00052 return _strnd==dsu::eNeg ? dsu::comp(_str[ idx-1]) : _str[idx-1];
00053 }
00054 #else
00055 ;
00056 #endif
00057
00061 inline unsigned length() const { return _str.length(); }
00062
00068 inline bool isStart(const char [3]) const;
00069
00074 inline bool isStart(int)const;
00075
00081 inline bool isStop(const char [3]) const;
00082
00086 inline bool isStop(int bp) const;
00087
00091 friend std::ostream& operator<<(std::ostream& os, const DnaStr& str) {
00092 for(unsigned i = 0; i < str._str.length(); ++i)
00093 os<<str[i];
00094 return os;
00095 }
00096
00097 #if _RUNTIME_DEBUG >= 1
00098 void printCodon(int start) const {
00099 if(_strnd == dsu::ePos)
00100 std::cout<<operator[](start)<<operator[](start+1)<<operator[](start+2)<<std::endl;
00101 else
00102 std::cout<<operator[](start+2)<<operator[](start+1)<<operator[](start)<<std::endl;
00103 }
00104 #endif
00105 private:
00106 inline static bool isU(char);
00107 inline static bool isA(char);
00108 inline static bool isG(char);
00109 inline static bool isC(char);
00110 inline static bool isR(char);
00111
00112 private:
00113 const string& _str;
00114 dsu::Strand_t _strnd;
00115
00116 };
00117
00118 #include "inline/DnaStr.hpp"
00119
00120 #endif // DNASTR_H