ToPS
|
00001 /* 00002 * ReverseComplementDNA.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 REVERSE_COMPLEMENT_HPP 00026 #define REVERSE_COMPLEMENT_HPP 00027 00028 #include "crossplatform.hpp" 00029 00030 #include "ProbabilisticModelDecorator.hpp" 00031 #include "DiscreteIIDModel.hpp" 00032 #include "Symbol.hpp" 00033 namespace tops { 00034 00035 class DLLEXPORT ReverseComplementDNA : public ProbabilisticModelDecorator { 00036 private: 00037 AlphabetPtr revAlphabet; 00038 int _seqLength; 00039 void revcomp(Sequence & revCompSeq, const Sequence & s, int begin, int end) const; 00040 public: 00041 ReverseComplementDNA(ProbabilisticModelPtr m) : ProbabilisticModelDecorator(m) 00042 { 00043 revAlphabet = AlphabetPtr(new Alphabet()); 00044 AlphabetPtr a = m->alphabet(); 00045 std::string A("A"); 00046 std::string C("C"); 00047 std::string G("G"); 00048 std::string T("T"); 00049 for(int i = 0; i < (int)a->size(); i++){ 00050 SymbolPtr s = a->getSymbol(i); 00051 if(s->name() == A) { 00052 revAlphabet->createSymbol(T); 00053 } else if (s->name() == G) { 00054 revAlphabet->createSymbol(C); 00055 } else if (s->name() == C) { 00056 revAlphabet->createSymbol(G); 00057 } else if (s->name() == T) { 00058 revAlphabet->createSymbol(A); 00059 } 00060 } 00061 }; 00062 virtual ~ReverseComplementDNA(){}; 00063 virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end) const; 00064 virtual Sequence & choose(Sequence & h, int size) const ; 00065 virtual Sequence & choose(Sequence &h, int initial_phase, int size) const; 00066 virtual double prefix_sum_array_compute(int begin , int end) ; 00067 virtual double prefix_sum_array_compute(int begin , int end, int phase); 00068 virtual bool initialize_prefix_sum_array(const Sequence & s, int phase); 00069 virtual bool initialize_prefix_sum_array(const Sequence & s) ; 00070 virtual std::string str() const; 00071 std::string model_name () const; 00072 virtual ProbabilisticModelParameters parameters() const ; 00073 virtual void initialize(const ProbabilisticModelParameters & p) ; 00074 00075 }; 00076 typedef boost::shared_ptr<ReverseComplementDNA> ReverseComplementDNAPtr; 00077 } 00078 00079 #endif