ToPS
MultipleSequentialModel.hpp
00001 /*
00002  *       MultipleSequentialModel.hpp
00003  *
00004  *       Copyright 2011 Andre Yoshiaki Kashiwabara <akashiwabara@usp.br>
00005  *                      Ígor Bonádio <ibonadio@ime.usp.br>
00006  *                      Vitor Onuchic <vitoronuchic@gmail.com>
00007  *                      Alan Mitchell Durham <aland@usp.br>
00008  *
00009  *       This program is free software; you can redistribute it and/or modify
00010  *       it under the terms of the GNU  General Public License as published by
00011  *       the Free Software Foundation; either version 3 of the License, or
00012  *       (at your option) any later version.
00013  *
00014  *       This program is distributed in the hope that it will be useful,
00015  *       but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *       GNU General Public License for more details.
00018  *
00019  *       You should have received a copy of the GNU General Public License
00020  *       along with this program; if not, write to the Free Software
00021  *       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022  *       MA 02110-1301, USA.
00023  */
00024 
00025 #ifndef MULTIPLE_SEQUENTIAL_MODEL
00026 #define MULTIPLE_SEQUENTIAL_MODEL
00027 
00028 #include "crossplatform.hpp"
00029 
00030 #include "Sequence.hpp"
00031 #include "Alphabet.hpp"
00032 
00033 #include "ProbabilisticModel.hpp"
00034 #include "FactorableModel.hpp"
00035 #include "MultipleSequentialModelCreator.hpp"
00036 #include "ProbabilisticModelParameter.hpp"
00037 #include "util.hpp"
00038 #include <cstdarg>
00039 #include <vector>
00040 
00041 namespace tops {
00042 
00043 
00045     class DLLEXPORT MultipleSequentialModel : public ProbabilisticModel
00046     {
00047     public:
00048 
00049         MultipleSequentialModel()  {
00050         };
00051         virtual double prefix_sum_array_compute(int begin, int end, int phase);
00052 
00053         virtual double prefix_sum_array_compute(int begin, int end) ;
00054 
00055         virtual bool initialize_prefix_sum_array(const Sequence & s);
00056 
00057         virtual bool initialize_prefix_sum_array(const Sequence & s, int phase);
00058 
00059         virtual ~MultipleSequentialModel() {}
00060         virtual void initialize (const ProbabilisticModelParameters & p ) ;
00061         virtual ProbabilisticModelParameters parameters() const;
00062         virtual std::string model_name() const {
00063             return "MultipleSequentialModel";
00064         }
00065 
00067         virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end) const;
00068 
00069         virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end, int phase) const ;
00070         virtual std::string str() const;
00071         virtual Sequence &  choose(Sequence & h, int size) const;
00072     private:
00073         std::vector<ProbabilisticModelPtr> _sub_models;
00074         std::vector<int> _max_size;
00075         int _idx_not_limited;
00076         std::map<std::string, ProbabilisticModelPtr> _models;
00077         ProbabilisticModelParameters _parameters;
00078         int _seqsize;
00079     };
00080 
00081     typedef boost::shared_ptr<MultipleSequentialModel> MultipleSequentialModelPtr;
00082 }
00083 
00084 
00085 
00086 #endif