src/biu/RNAStructure_TB.hh
Go to the documentation of this file.00001 #ifndef RNASTRUCTURE_TB_HH_
00002 #define RNASTRUCTURE_TB_HH_
00003
00004
00005 #include "biu/BioMolecule.hh"
00006 #include "biu/AllowedBasePairs.hh"
00007
00008 namespace biu
00009 {
00010
00030 class RNAStructure_TB : public BioMolecule
00031 {
00032 protected:
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class TreeItem {
00045 public:
00046
00047 size_t next;
00048
00049 size_t pair;
00050
00051
00052 bool
00053 operator == (const TreeItem& op2) const {
00054 return ((this->next==op2.next)&&(this->pair==op2.pair));
00055 }
00056 };
00057
00058
00059
00060
00061 public:
00062
00063
00064 Sequence getSequence() const ;
00065
00066
00068 Structure getStructure() const ;
00069
00073 virtual double getEnergy() const ;
00074
00075
00078 size_t getLength() const ;
00079
00080
00085 bool isValid() const;
00086
00087
00092 std::string getStringRepresentation() const;
00093
00094
00095
00096
00097
00098
00099
00100 protected:
00101
00102
00104 static const size_t MIN_LOOP_LENGTH;
00105
00106
00110 static const Alphabet STRUCT_ALPH;
00111
00112
00114 const bool seqShared;
00115
00116
00120 const AllowedBasePairs* bPair;
00121
00122
00123
00124
00125
00126
00127 mutable size_t strucStatus;
00128
00129
00131 Sequence* rnaSeq;
00132
00133
00135
00136
00137 std::string bracketStructStr;
00138
00139
00141 std::vector<TreeItem>* validTreeStruc;
00142
00143
00144 public:
00145
00146
00148 static const Alphabet::AlphElem STRUCT_BND_OPEN;
00150 static const Alphabet::AlphElem STRUCT_BND_CLOSE;
00152 static const Alphabet::AlphElem STRUCT_UNBOUND;
00153
00155
00156 static const size_t INVALID_INDEX;
00157
00158
00159
00160 static const size_t BASEPAIRS_VALIDITY ;
00161 static const size_t BASEPAIRS_VALIDITY_CALCULATED ;
00162 static const size_t LOOPSIZE_VALIDITY ;
00163 static const size_t LOOPSIZE_VALIDITY_CALCULATED ;
00164 static const size_t STRUCTURE_VALIDITY ;
00165 static const size_t STRUCTURE_VALIDITY_CALCULATED ;
00166
00167
00168
00169 static const size_t INSERT_MOVE;
00170 static const size_t SHIFT_MOVE;
00171 static const size_t REVERSE_SHIFT_MOVE;
00172 static const size_t INVALID_DELETE_MOVE;
00173 static const size_t DELETE_MOVE;
00174
00175
00176
00177
00178 static const size_t getMinLoopLength() ;
00179
00180 static const Alphabet* getStructureAlphabet() ;
00181
00182
00183
00193 RNAStructure_TB( const std::string& rnaSeqStr,
00194 const std::string& rnaStructBracketDotStr,
00195 const AllowedBasePairs* const bPair);
00196
00197
00208 RNAStructure_TB( Sequence* rnaSeq,
00209 const Structure* const rnaStructBracketDot,
00210 const AllowedBasePairs* const bPair,
00211 const bool seqIsShared);
00212
00213
00214 RNAStructure_TB(const RNAStructure_TB& rnaStruct);
00215
00216
00217 virtual ~RNAStructure_TB();
00218
00219
00220 RNAStructure_TB& operator= (const RNAStructure_TB& rnaStruct2);
00221 bool operator== (const RNAStructure_TB& rnaStruct2) const;
00222 bool operator!= (const RNAStructure_TB& rnaStruct2) const;
00223
00224
00225
00229 virtual void setStructure(const Structure& str);
00230
00231
00232
00233 std::string getSequenceString() const ;
00234
00235
00236 std::string getStructureString() const ;
00237
00238
00239 const std::string& getStructureStringRef() const ;
00240
00241
00242
00243
00244
00245
00249 bool hasValidStructure() const ;
00250
00251
00255 bool hasValidBasePairs() const ;
00256
00257
00261 bool hasValidLoopSize() const ;
00262
00263
00264
00265
00266
00267 bool isValidInsertMove(const size_t i, const size_t j) const;
00268 bool isValidDeleteMove(const size_t i, const size_t j) const;
00269
00275 int isValidSingleMove( const size_t i, const size_t j) const;
00276
00277 bool isValidLeftShiftMove(const size_t i, const size_t j, const size_t k) const;
00278 bool isValidRightShiftMove(const size_t i, const size_t j, const size_t k) const;
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 void insertBond(const size_t i, const size_t j);
00290 void deleteBond(const size_t i, const size_t j);
00291
00292
00293 void leftShift(const size_t i, const size_t j, const size_t k);
00294 void rightShift(const size_t i, const size_t j, const size_t k);
00295
00296 void shiftUnordered(const size_t i, const size_t j);
00297
00298 void shiftToBond(const size_t i, const size_t k);
00299
00300 void shiftToBond(const size_t i, const size_t j, const size_t k);
00301
00302
00303
00304 size_t moveType(size_t i, size_t j) const ;
00305
00306 void executeOrderedMove(size_t i, size_t j);
00307
00308 bool executeOrderedMoveTry(size_t i, size_t j);
00309
00310
00323 bool getNextSingleMove( size_t& i, size_t& j ) const ;
00324
00325
00326
00332 size_t getCorrespondingBase(size_t basePos) const;
00333
00334
00338 bool isAllowedBasePair(size_t pos1, size_t pos2) const;
00339
00340
00341
00342
00343
00344
00345 protected:
00346
00347
00349 bool initTree(const Structure& str);
00350
00351
00352
00353 bool areOnSameLevel(const size_t i, const size_t j) const ;
00354
00355
00356
00357
00358 void setStringBrackets(const size_t i, const size_t j);
00359
00360
00361
00362
00363
00364
00365 private:
00366
00367 std::string decodedStatus() const;
00368
00369
00370
00371
00372 public:
00373 bool isValidUnorderedShift(const size_t i, const size_t j) const;
00374
00375
00376 bool isValidShift(const size_t i, const size_t j) const;
00377
00378
00379 void decodeMoveIndex(size_t const index, size_t& i, size_t& j) const;
00380
00381 bool executeOrderedMoveTry(size_t const index);
00382
00383 size_t getMoveIndexCount() const;
00384
00385
00386 };
00387
00388
00389 }
00390
00391 #include "biu/RNAStructure_TB.icc"
00392
00393 #endif