LocARNA-2.0.0
mcc_matrices.hh
1 #ifndef LOCARNA_MCC_MATRICES_HH
2 #define LOCARNA_MCC_MATRICES_HH
3 
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7 
8 #include <assert.h>
9 
10 #define PUBLIC // for Vienna
11 
12 extern "C" {
13 #include <ViennaRNA/params.h> // import pf_paramT definition
14 }
15 
16 namespace LocARNA {
17  class PFoldParams;
18  class MultipleAlignment;
19 
21  public:
27  virtual ~McC_matrices_base();
28 
31  size_t
32  iidx(size_t i, size_t j) const {
33  assert(1 <= i);
34  assert(i <= j);
35  assert(j <= vc_->length);
36 
37  return vc_->iindx[i] - j;
38  }
39 
42  size_t
43  jidx(size_t i, size_t j) const {
44  assert(1 <= i);
45  assert(i <= j);
46  assert(j <= vc_->length);
47 
48  return vc_->jindx[j] + i;
49  }
50 
60  bppm(size_t i, size_t j) const {
61  return vc_->exp_matrices->probs[iidx(i, j)];
62  }
63 
73  qb(size_t i, size_t j) const {
74  return vc_->exp_matrices->qb[iidx(i, j)];
75  }
76 
86  qm(size_t i, size_t j) const {
87  return vc_->exp_matrices->qm[iidx(i, j)];
88  }
89 
93  vrna_exp_param_t *
94  exp_params() const {
95  return vc_->exp_params;
96  }
97 
103  FLT_OR_DBL
104  scale(size_t i) const {
105  return vc_->exp_matrices->scale[i];
106  }
107 
113  FLT_OR_DBL
114  expMLbase(size_t i) const {
115  return vc_->exp_matrices->expMLbase[i];
116  }
117 
122  FLT_OR_DBL
123  kT() const {
124  return vc_->exp_params->kT;
125  }
126 
134  FLT_OR_DBL
135  q1k(size_t k) const {
136  return vc_->exp_matrices->q1k[k];
137  }
138 
146  FLT_OR_DBL
147  qln(size_t l) const {
148  return vc_->exp_matrices->qln[l];
149  }
150 
159  int
160  pair(size_t c, size_t d) const {
161  assert(vc_);
162  assert(vc_->exp_params);
163  return vc_->exp_params->model_details.pair[c][d];
164  }
165 
166  int
167  rtype(size_t x) const {
168  assert(vc_);
169  assert(vc_->exp_params);
170  return vc_->exp_params->model_details.rtype[x];
171  }
172 
173  vrna_fold_compound_t *vc() {return vc_;}
174 
175  protected:
176 
177  // /** @brief free vrna fold compound
178  // @param vc pointer to the fold compound
179  // */
180  // static
181  // const
182  // auto free_vfc = [](vrna_fold_compound_t *vc) {vrna_fold_compound_free(vc);};
183 
188  vrna_fold_compound_t* vc_;
189 
193  explicit
194  McC_matrices_base(vrna_fold_compound_t* vc = nullptr);
195 
196  }; // end class McC_matrices_base
197 
203  public:
210  McC_matrices_t(const MultipleAlignment &sequence, const PFoldParams &params);
211 
215  virtual ~McC_matrices_t();
216 
225  char
226  ptype(size_t i, size_t j) const {
227  return vc_->ptype[jidx(i, j)];
228  }
229 
238  char
239  rev_ptype(size_t i, size_t j) const {
240  return vc_->exp_params->model_details.rtype[(size_t)ptype(i, j)];
241  }
242 
250  short
251  S1(size_t i) const {
252  return vc_->sequence_encoding[i];
253  }
254 
255  char *
256  sequence() const {
257  return vc_->sequence;
258  }
259  };
260 
264  public:
271  McC_ali_matrices_t(const MultipleAlignment &ma, const PFoldParams &params);
272 
276  virtual ~McC_ali_matrices_t();
277 
286  short
287  pscore(size_t i, size_t j) const {
288  return vc_->pscore[jidx(i, j)];
289  }
290 
299  short
300  S(size_t s, size_t i) const {
301  assert(vc_);
302  return vc_->S[s][i];
303  }
304 
313  short
314  S3(size_t s, size_t i) const {
315  assert(vc_);
316  return vc_->S3[s][i];
317  }
318 
327  short
328  S5(size_t s, size_t i) const {
329  assert(vc_);
330  return vc_->S5[s][i];
331  }
332 
341  short
342  a2s(size_t s, size_t i) const {
343  return vc_->a2s[s][i];
344  }
345 
346  char *
347  Ss(size_t s) const {
348  return vc_->Ss[s];
349  }
350  };
351 
352 } // end namespace LocARNA
353 
354 #endif // LOCARNA_MCC_MATRICES_HH
Alifold-McCaskill matrices.
Definition: mcc_matrices.hh:263
short S(size_t s, size_t i) const
Read access to sequence encoding S.
Definition: mcc_matrices.hh:300
virtual ~McC_ali_matrices_t()
destruct
Definition: mcc_matrices.cc:77
short a2s(size_t s, size_t i) const
Read access to a2s.
Definition: mcc_matrices.hh:342
short S3(size_t s, size_t i) const
Read access to sequence encoding S3.
Definition: mcc_matrices.hh:314
short S5(size_t s, size_t i) const
Read access to sequence encoding S5.
Definition: mcc_matrices.hh:328
short pscore(size_t i, size_t j) const
Access matrix pscore.
Definition: mcc_matrices.hh:287
McC_ali_matrices_t(const MultipleAlignment &ma, const PFoldParams &params)
Construct from multiple alignment.
Definition: mcc_matrices.cc:54
Definition: mcc_matrices.hh:20
McC_matrices_base(vrna_fold_compound_t *vc=nullptr)
construct with fold compound
Definition: mcc_matrices.cc:27
vrna_fold_compound_t * vc_
vrna fold compound The fold compound holds the DP matrices, input and model details.
Definition: mcc_matrices.hh:188
vrna_exp_param_t * exp_params() const
exp params
Definition: mcc_matrices.hh:94
FLT_OR_DBL expMLbase(size_t i) const
expMLbase
Definition: mcc_matrices.hh:114
size_t jidx(size_t i, size_t j) const
index in triagonal matrix
Definition: mcc_matrices.hh:43
FLT_OR_DBL qb(size_t i, size_t j) const
Read access matrix qb.
Definition: mcc_matrices.hh:73
FLT_OR_DBL q1k(size_t k) const
Read access matrix q1k.
Definition: mcc_matrices.hh:135
virtual ~McC_matrices_base()
Destructor.
Definition: mcc_matrices.cc:28
int pair(size_t c, size_t d) const
Read access matrix pair.
Definition: mcc_matrices.hh:160
FLT_OR_DBL qm(size_t i, size_t j) const
Read access matrix qm.
Definition: mcc_matrices.hh:86
FLT_OR_DBL qln(size_t l) const
Read access matrix qln.
Definition: mcc_matrices.hh:147
FLT_OR_DBL scale(size_t i) const
scale
Definition: mcc_matrices.hh:104
FLT_OR_DBL kT() const
kT
Definition: mcc_matrices.hh:123
size_t iidx(size_t i, size_t j) const
index in triagonal matrix
Definition: mcc_matrices.hh:32
FLT_OR_DBL bppm(size_t i, size_t j) const
Read access matrix bppm.
Definition: mcc_matrices.hh:60
McCaskill matrices.
Definition: mcc_matrices.hh:202
virtual ~McC_matrices_t()
destruct, optionally free local copy
Definition: mcc_matrices.cc:51
char ptype(size_t i, size_t j) const
Access matrix ptype.
Definition: mcc_matrices.hh:226
char rev_ptype(size_t i, size_t j) const
Reverse ptype.
Definition: mcc_matrices.hh:239
McC_matrices_t(const MultipleAlignment &sequence, const PFoldParams &params)
Construct from sequence.
Definition: mcc_matrices.cc:34
short S1(size_t i) const
Read access to sequence encoding S1.
Definition: mcc_matrices.hh:251
Represents a multiple alignment.
Definition: multiple_alignment.hh:65
Parameters for partition folding.
Definition: pfold_params.hh:32
Definition: aligner.cc:15
double FLT_OR_DBL
select FLT_OR_DBL
Definition: aux.hh:291