src/ell/protein/S_LP_PullM.cc
Go to the documentation of this file.00001 #include "ell/State.hh"
00002 #include "ell/protein/S_LP_PullM.hh"
00003 #include <biu/LatticeProtein_Ipnt.hh>
00004 #include <biu/PullMoveSet.hh>
00005 #include <biu/LatticeDescriptorCUB.hh>
00006 #include <biu/assertbiu.hh>
00007
00008 namespace ell
00009 {
00010
00011 const std::string S_LP_PullM::ID = std::string("ell::S_LP_PullM");
00012
00013
00014
00015 S_LP_PullM::S_LP_PullM( biu::LatticeProtein_I* _latProt,
00016 biu::LatticeMoveSet* _moveSet)
00017 : S_LP(_latProt, _moveSet)
00018 {}
00019
00020 S_LP_PullM::S_LP_PullM( const S_LP_PullM& s)
00021 : S_LP( s.latProt->clone(), s.moveSet->clone() )
00022 {}
00023
00024 S_LP_PullM::~S_LP_PullM()
00025 {}
00026
00027 const std::string &
00028 S_LP_PullM::getID( void ) const {
00029 return S_LP_PullM::ID;
00030 }
00031
00032
00033 S_LP_PullM*
00034 S_LP_PullM::clone(State* toFill) const
00035 {
00036 assertbiu(latProt != NULL , "no lattice protein (NULL)");
00037 assertbiu(moveSet != NULL , "no move set (NULL)");
00038 if (toFill == NULL) {
00039 return new S_LP_PullM(*this);
00040 }
00041
00042 assertbiu(dynamic_cast<S_LP_PullM*>(toFill) != NULL
00043 , "toFill is no instance of S_LP_PullM");
00044 S_LP_PullM* s = static_cast<S_LP_PullM*>(toFill);
00045
00046 s->latProt->operator=(*(this->latProt));
00047
00048 delete s->moveSet;
00049 s->moveSet = this->moveSet->clone();
00050
00051 return s;
00052 }
00053
00054 State*
00055 S_LP_PullM::fromString(const std::string& stringRep) const {
00056 return new S_LP_PullM(this->latProt->fromString(stringRep),
00057 this->moveSet->clone());
00058 }
00059
00060
00061
00063
00064
00065
00066
00067 CSequence
00068 S_LP_PullM::compress(void) const {
00069 return latProt->getLatticeModel()->getDescriptor()->
00070 getAlphabet()->compress(latProt->getMoveSeqAbs());
00071 }
00072
00073
00074
00075
00076
00077
00078 CSequence&
00079 S_LP_PullM::compress(CSequence& toFill) const {
00080 toFill = latProt->getLatticeModel()->getDescriptor()->
00081 getAlphabet()->compress(latProt->getMoveSeqAbs());
00082 return toFill;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 State*
00094 S_LP_PullM::uncompress(const CSequence& cseq, State* toFill) const {
00095
00096 const std::string newSeq =
00097 latProt->getLatticeModel()->getString(
00098 latProt->getLatticeModel()->getDescriptor()->
00099 getAlphabet()->decompress(cseq, latProt->getLength()-1));
00100
00101 if (toFill==NULL) {
00102
00103 biu::LatticeProtein_I* newProt = latProt->clone();
00104 newProt->setMoveStrAbs(newSeq);
00105 toFill = new S_LP_PullM(newProt, moveSet->clone());
00106 }
00107 else
00108 {
00109 S_LP_PullM* s = dynamic_cast<S_LP_PullM*>(toFill);
00110 assertbiu(s != NULL, "casting to S_LP_PullM failed");
00111 s->latProt->setMoveStrAbs(newSeq);
00112 toFill = s;
00113 }
00114
00115 return toFill;
00116 }
00117
00118
00119
00120
00121
00122
00123 State*
00124 S_LP_PullM::uncompress(const CSequence& cseq) {
00125 return uncompress(cseq, this);
00126 }
00127
00128 }