src/ell/rna/S_RNAfe_SingleM_TB.hh
Go to the documentation of this file.00001 #ifndef RNAFREEENERGYSINGLEMOVESTATE_TB_HH_ 00002 #define RNAFREEENERGYSINGLEMOVESTATE_TB_HH_ 00003 00004 00005 #include "ell/State.hh" 00006 #include "ell/rna/RNAFreeEnergy_TB.hh" 00007 00008 namespace ell 00009 { 00019 class S_RNAfe_SingleM_TB : public State 00020 { 00021 protected: 00022 typedef RNAFreeEnergy_TB::SingleMove SingleMove; 00023 00024 class NeighborList : public State::NeighborList 00025 { 00026 protected: 00028 const S_RNAfe_SingleM_TB* const origin; 00029 00030 public: 00033 class ItState : public State::NeighborList::ItState 00034 { 00035 public: 00037 SingleMove lastMove; 00038 00039 ItState() : lastMove() {} 00040 ItState(const ItState &itstate) 00041 : lastMove(itstate.lastMove) {} 00042 virtual ~ItState() {} 00043 00044 virtual ItState* clone() const { 00045 return new ItState(*this); 00046 } 00047 }; 00048 00049 NeighborList(const S_RNAfe_SingleM_TB* _origin); 00050 00051 virtual ~NeighborList(); 00052 00057 virtual State* first(State::NeighborList::ItState** itstate) const; 00058 00063 virtual State* next( State::NeighborList::ItState* itstate, 00064 State* elem) const; 00065 }; 00066 00067 class RandomNeighborList : public State::NeighborList 00068 { 00069 public: 00070 class ItState; 00071 00072 protected: 00074 const S_RNAfe_SingleM_TB* const origin; 00075 00079 void switchMode(ItState* itstate) const; 00080 00081 public: 00082 class ItState : public State::NeighborList::ItState 00083 { 00084 public: 00089 static const size_t SWITCH_MODE_THRESHOLD; 00090 00093 size_t switchModeValue; 00094 00097 std::set<SingleMove> chosenMoves; 00098 00101 std::vector<SingleMove> unchosenValidMoves; 00102 00103 ItState() : switchModeValue(SWITCH_MODE_THRESHOLD), 00104 chosenMoves(), 00105 unchosenValidMoves() 00106 {} 00107 00108 ItState(const ItState &itstate) 00109 : switchModeValue(itstate.switchModeValue), 00110 chosenMoves(itstate.chosenMoves), 00111 unchosenValidMoves(itstate.unchosenValidMoves) 00112 {} 00113 00114 virtual ~ItState() 00115 {} 00116 00117 virtual ItState* clone() const { 00118 return new ItState(*this); 00119 } 00120 }; 00121 00122 RandomNeighborList(const S_RNAfe_SingleM_TB* _origin); 00123 00124 virtual ~RandomNeighborList(); 00125 00130 virtual State* first(State::NeighborList::ItState** itstate) const; 00131 00136 virtual State* next( State::NeighborList::ItState* itstate, 00137 State* elem) const; 00138 }; 00139 00140 RNAFreeEnergy_TB rnaFreeEnergy; 00141 00142 // biu::Alphabet::AlphElem open; 00143 // biu::Alphabet::AlphElem none; 00144 // biu::Alphabet::AlphElem close; 00145 00150 SingleMove firstValidSingleMove() const; 00151 00159 SingleMove nextValidSingleMove(const SingleMove lastSingleMove) const; 00160 00161 // /*! Searches for the next valid single move and starts 00162 // * the search for the first move position at pos 1 00163 // * and for the second move position at pos2. 00164 // * If a move was found, it will be returned, otherwise 00165 // * SingleMove(0,RNAStructure::INVALID_INDEX) will be returned. 00166 // */ 00167 // SingleMove searchForNextValidSingleMove(size_t pos1, 00168 // size_t pos2) const; 00169 00170 public: 00171 00173 static const std::string ID; 00174 00175 S_RNAfe_SingleM_TB( const std::string& rnaSeqStr, 00176 const std::string& rnaStructBracketNotStr); 00177 00178 S_RNAfe_SingleM_TB( const RNAFreeEnergy_TB& rna ); 00179 00182 S_RNAfe_SingleM_TB( const S_RNAfe_SingleM_TB& toCopy); 00183 00184 virtual ~S_RNAfe_SingleM_TB(); 00185 00191 virtual const std::string& getID( void ) const; 00192 00193 00194 // abstract functions (State) 00195 virtual bool operator== (const State& state2) const; 00196 virtual bool operator!= (const State& state2) const; 00197 00207 virtual bool operator< (const State& rna2) const; 00208 00209 00213 virtual double getEnergy() const; 00214 00219 virtual unsigned int getMinimalDistance(const State& state2) const; 00220 00228 virtual S_RNAfe_SingleM_TB* clone(State* toFill = NULL) const; 00229 00236 virtual State* fromString(const std::string& stringRep) const; 00246 virtual State* fromString( const std::string& stringRep 00247 , const double energy) const; 00248 00253 virtual std::string toString() const; 00254 00260 virtual std::string& toString( std::string & toFill ) const; 00261 00264 virtual std::string getSequence() const; 00265 00269 virtual std::string getStructure() const; 00270 00271 virtual NeighborListPtr getNeighborList() const; 00272 00273 virtual NeighborListPtr getRandomNeighborList() const; 00274 00275 virtual State* getRandomNeighbor(State* inPlaceNeigh = NULL) const; 00276 00278 00282 virtual CSequence compress(void) const ; 00283 00289 virtual CSequence& compress(CSequence& toFill) const; 00290 00299 virtual State* uncompress(const CSequence& cseq, State* toFill) const; 00300 00306 virtual State* uncompress(const CSequence& cseq); 00307 00308 00309 }; 00310 00311 } // namespace ell 00312 00313 #endif /*RNAFREEENERGYSINGLEMOVESTATE_TB_HH_*/