LocARNA-1.8.11
match_probs.hh
1 #ifndef LOCARNA_MATCH_PROBS
2 #define LOCARNA_MATCH_PROBS
3 
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7 
8 #include <string>
9 
10 #include "matrix.hh"
11 
12 namespace LocARNA {
13 
14  class StralScore;
15  class RnaData;
16  template <class T> class Alphabet;
17  class Sequence;
18 
42  class MatchProbs {
43  public:
44  typedef size_t size_type;
45 
47  MatchProbs();
48 
50  explicit
51  MatchProbs(const std::string &filename);
52 
59  void
60  pairHMM_probs(const Sequence &seqA,
61  const Sequence &seqB,
62  const std::string & file);
63 
71  void
72  pf_probs(const RnaData &rnaA,
73  const RnaData &rnaB,
74  const Matrix<double> &sim_mat,
75  const Alphabet<char> &alphabet,
76  double gap_opening,
77  double gap_extension,
78  double pf_struct_weight,
79  double temp,
80  bool flag_local);
81 
86  std::istream &
87  read(std::istream &in);
88 
90  void
91  read(const std::string &filename);
92 
93 
98  std::istream &
99  read_sparse(std::istream &in, size_type lenA, size_type lenB);
100 
105  void
106  read_sparse(const std::string &filename, size_type lenA, size_type lenB);
107 
112  std::ostream &
113  write(std::ostream &out) const;
114 
116  void
117  write(const std::string &filename) const;
118 
123  std::ostream &
124  write_sparse(std::ostream &out, double threshold) const;
125 
130  void
131  write_sparse(const std::string &filename, double threshold) const;
132 
134  size_type get_lenA() const {return probs.sizes().first;}
135 
137  size_type get_lenB() const {return probs.sizes().second;}
138 
140  double prob(size_t i, size_t j) const {
141  assert(1<=i && i<probs.sizes().first);
142  assert(1<=j && j<probs.sizes().second);
143 
144  return probs(i,j);
145  }
146 
147  private:
149  void
150  pf_gotoh(size_type lenA,
151  size_type lenB,
152  Matrix<double> &zM,
153  Matrix<double> &zA,
154  Matrix<double> &zB,
155 
156  const StralScore &score,
157 
158  double temp,
159 
160  bool local
161  );
162 
163  Matrix<double> probs;
164 
174  class ProbConsParameter {
175  public:
176  // ------------------------------------------------------------
177  // transition probabilities
178  // there are three states M, X, Y (plus implicitely start and end state)
179  double initM;
180  double initX;
181  double initY;
182  double startX;
183  double startY;
184  double extendM;
185  double extendX;
186  double extendY;
187  double startMFromX;
188  double startMFromY;
189 
190  std::string basenames;
191 
192  Matrix<double> emmission;
193  std::vector<double> background;
194 
202  explicit
203  ProbConsParameter(const std::string &filename);
204  };
205 
206  };
207 
208 }
209 
210 #endif // LOCARNA_MATCH_PROBS
represent sparsified data of RNA ensemble
Definition: rna_data.hh:42
void pairHMM_probs(const Sequence &seqA, const Sequence &seqB, const std::string &file)
Definition: match_probs.cc:118
std::istream & read(std::istream &in)
Provides probabilities for each match.
Definition: match_probs.hh:42
Definition: aligner.cc:17
std::ostream & write_sparse(std::ostream &out, double threshold) const
Definition: match_probs.cc:502
size_t size_type
size
Definition: match_probs.hh:44
MatchProbs()
construct as empty object
Definition: match_probs.cc:106
Implements the stral-like scoring function.
Definition: stral_score.hh:22
std::ostream & write(std::ostream &out) const
void pf_probs(const RnaData &rnaA, const RnaData &rnaB, const Matrix< double > &sim_mat, const Alphabet< char > &alphabet, double gap_opening, double gap_extension, double pf_struct_weight, double temp, bool flag_local)
Definition: match_probs.cc:359
size_type get_lenB() const
get the length of the second sequence
Definition: match_probs.hh:137
size_pair_type sizes() const
Definition: matrix.hh:93
size_type get_lenA() const
get the length of the first sequence
Definition: match_probs.hh:134
std::istream & read_sparse(std::istream &in, size_type lenA, size_type lenB)
Definition: match_probs.cc:464
"Sequence View" of multiple alignment as array of column vectors
Definition: sequence.hh:29
double prob(size_t i, size_t j) const
return the match probability for the two bases
Definition: match_probs.hh:140