Generated on Mon Jun 23 17:17:53 2008 for ell-2.3.0 by doxygen 1.5.1

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 S_LP_PullM::S_LP_PullM(     biu::LatticeProtein_I* _latProt,
00012                             biu::LatticeMoveSet* _moveSet)
00013     : S_LP(_latProt, _moveSet)
00014     {}
00015 
00016 S_LP_PullM::S_LP_PullM( const S_LP_PullM& s)
00017     : S_LP( s.latProt->clone(), s.moveSet->clone() )
00018     {}
00019 
00020 S_LP_PullM::~S_LP_PullM()
00021     {}
00022 
00023 State* 
00024 S_LP_PullM::clone() const
00025 {
00026     assertbiu(latProt != NULL , "no lattice protein (NULL)");
00027     assertbiu(moveSet != NULL , "no move set (NULL)");
00028     return new S_LP_PullM(*this);
00029 }
00030 
00031 State* 
00032 S_LP_PullM::fromString(const std::string& stringRep) const {
00033     return new S_LP_PullM(this->latProt->fromString(stringRep), 
00034                             this->moveSet->clone());
00035 }
00036 
00037 
00038 
00040     
00041         /* Access to a compressed sequence representation of the state.
00042          * @return the compressed sequence representation
00043          */
00044     CSequence  
00045     S_LP_PullM::compress(void) const {
00046         return latProt->getLatticeModel()->getDescriptor()->
00047                     getAlphabet()->compress(latProt->getMoveSeqAbs());
00048     }
00049     
00050         /* Access to a compressed sequence representation of the state.
00051          * @param toFill a data structure to write the compressed 
00052          *               representation too
00053          * @return the compressed sequence representation
00054          */
00055     CSequence&  
00056     S_LP_PullM::compress(CSequence& toFill) const {
00057         toFill = latProt->getLatticeModel()->getDescriptor()->
00058                     getAlphabet()->compress(latProt->getMoveSeqAbs());
00059         return toFill;
00060     }
00061     
00062         /* Uncompresses a compressed sequence representation into a new
00063          * State object.
00064          * @param cseq the compressed sequence representation of a state
00065          * @param toFill a state object to uncompress too or NULL if a new 
00066          *               object has to be created
00067          * @return new State object that is encoded in cseq or NULL in error
00068          *         case.
00069          */
00070     State*  
00071     S_LP_PullM::uncompress(const CSequence& cseq, State* toFill) const {
00072         
00073         const std::string newSeq =
00074             latProt->getLatticeModel()->getString(
00075                     latProt->getLatticeModel()->getDescriptor()->
00076                     getAlphabet()->decompress(cseq, latProt->getLength()-1));
00077         
00078         if (toFill==NULL) {
00079             // create new object
00080             biu::LatticeProtein_I* newProt = latProt->clone();
00081             newProt->setMoveStrAbs(newSeq);
00082             toFill = new S_LP_PullM(newProt, moveSet->clone());
00083         }
00084         else
00085         {
00086             S_LP_PullM* s = dynamic_cast<S_LP_PullM*>(toFill);
00087             assertbiu(s != NULL, "casting to S_LP_PullM failed");
00088             s->latProt->setMoveStrAbs(newSeq);
00089             toFill = s;
00090         }
00091         
00092         return toFill;
00093     }
00094     
00095         /* Uncompresses a compressed sequence representation into a this
00096          * State object.
00097          * @param cseq the compressed sequence representation of a state
00098          * @return this or NULL in error case
00099          */
00100     State*  
00101     S_LP_PullM::uncompress(const CSequence& cseq) {
00102         return uncompress(cseq, this);
00103     }
00104 
00105 } // namespace ell