LocARNA-1.9.2
src/LocARNA/match_probs.hh
00001 #ifndef LOCARNA_MATCH_PROBS
00002 #define LOCARNA_MATCH_PROBS
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007 
00008 #include <string>
00009 
00010 #include "matrix.hh"
00011 
00012 namespace LocARNA {
00013 
00014     class StralScore;
00015     class RnaData;
00016     template <class T>
00017     class Alphabet;
00018     class Sequence;
00019 
00044     class MatchProbs {
00045     public:
00046         typedef size_t size_type; 
00047 
00049         MatchProbs();
00050 
00052         explicit MatchProbs(const std::string &filename);
00053 
00060         void
00061         pairHMM_probs(const Sequence &seqA,
00062                       const Sequence &seqB,
00063                       const std::string &file);
00064 
00073         void
00074         pf_probs(const RnaData &rnaA,
00075                  const RnaData &rnaB,
00076                  const Matrix<double> &sim_mat,
00077                  const Alphabet<char> &alphabet,
00078                  double gap_opening,
00079                  double gap_extension,
00080                  double pf_struct_weight,
00081                  double temp,
00082                  bool flag_local);
00083 
00088         std::istream &
00089         read(std::istream &in);
00090 
00092         void
00093         read(const std::string &filename);
00094 
00099         std::istream &
00100         read_sparse(std::istream &in, size_type lenA, size_type lenB);
00101 
00106         void
00107         read_sparse(const std::string &filename,
00108                     size_type lenA,
00109                     size_type lenB);
00110 
00115         std::ostream &
00116         write(std::ostream &out) const;
00117 
00119         void
00120         write(const std::string &filename) const;
00121 
00126         std::ostream &
00127         write_sparse(std::ostream &out, double threshold) const;
00128 
00133         void
00134         write_sparse(const std::string &filename, double threshold) const;
00135 
00137         size_type
00138         get_lenA() const {
00139             return probs.sizes().first;
00140         }
00141 
00143         size_type
00144         get_lenB() const {
00145             return probs.sizes().second;
00146         }
00147 
00149         double
00150         prob(size_t i, size_t j) const {
00151             assert(1 <= i && i < probs.sizes().first);
00152             assert(1 <= j && j < probs.sizes().second);
00153 
00154             return probs(i, j);
00155         }
00156 
00157     private:
00159         void
00160         pf_gotoh(size_type lenA,
00161                  size_type lenB,
00162                  Matrix<double> &zM,
00163                  Matrix<double> &zA,
00164                  Matrix<double> &zB,
00165 
00166                  const StralScore &score,
00167 
00168                  double temp,
00169 
00170                  bool local);
00171 
00172         Matrix<double> probs; 
00173 
00184         class ProbConsParameter {
00185         public:
00186             // ------------------------------------------------------------
00187             // transition probabilities
00188             // there are three states M, X, Y (plus implicitely start and end
00189             // state)
00190             double initM;       
00191             double initX;       
00192             double initY;       
00193             double startX;      
00194             double startY;      
00195             double extendM;     
00196             double extendX;     
00197             double extendY;     
00198             double startMFromX; 
00199             double startMFromY; 
00200 
00201             std::string basenames; 
00202 
00203             Matrix<double> emmission; 
00204             std::vector<double>
00205                 background; 
00206 
00214             explicit ProbConsParameter(const std::string &filename);
00215         };
00216     };
00217 }
00218 
00219 #endif // LOCARNA_MATCH_PROBS
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends