LocARNA-1.8.11
fitonoff.hh
1 #ifndef LOCARNA_FIT_ON_OFF_HH
2 #define LOCARNA_FIT_ON_OFF_HH
3 
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7 
8 #include <string>
9 #include <vector>
10 
11 #include <cmath>
12 
13 namespace LocARNA {
14 
15  typedef std::vector<double> numseq_t;
16  typedef std::vector<double>::size_type size_type;
17 
18  typedef long double pf_t;
19 
24  class FitOnOff {
25  double delta_01;
26  double delta_10;
27  numseq_t x;
28 
29  double beta;
30 
31  pf_t exp_delta_01;
32  pf_t exp_delta_10;
33 
34  std::vector<std::vector<pf_t> > v;
35 
36  std::vector<std::vector<bool> > t;
37 
38  std::vector<bool> trace;
39 
40 
41  public:
42 
50  FitOnOff(numseq_t &x_, double delta_01_, double delta_10_, double beta_)
51  : delta_01(delta_01_),
52  delta_10(delta_10_),
53  x(x_),
54  beta(beta_)
55  {
56  v.resize(2);
57  v[0].resize(x.size()+1);
58  v[1].resize(x.size()+1);
59 
60  t.resize(2);
61  t[0].resize(x.size()+1);
62  t[1].resize(x.size()+1);
63  trace.resize(x.size()+1);
64 
65  exp_delta_01 = exp(-beta*delta_01);
66  exp_delta_10 = exp(-beta*delta_10);
67 
68  }
69 
77  double
78  viterbi(double c0, double c1, bool traceback);
79 
87  double
88  best_once_on(double c0, double c1);
89 
90 
95  pf_t
96  forward(double c0, double c1);
97 
98 
103  std::pair<double,double>
104  optimize(double c0, double c1);
105 
107  void
108  write_viterbi_path_compact(std::ostream &out,double c0, double c1);
109 
111  void
112  write_viterbi_path(std::ostream &out,double c0, double c1) const;
113 
114  // DEBUGGING
115 
122  void
123  print_table(const std::string &name, const std::vector<bool> &v) const;
124 
131  void
132  print_table(const std::string &name, const std::vector<pf_t> &v) const;
133 
138  void
139  print_tables() const;
140 
141 
142  };
143 
144 } // END namespace LocARNA
145 
146 #endif //LOCARNA_FIT_ON_OFF_HH
std::pair< double, double > optimize(double c0, double c1)
Definition: fitonoff.cc:101
void print_tables() const
Definition: fitonoff.cc:270
double viterbi(double c0, double c1, bool traceback)
Definition: fitonoff.cc:15
void write_viterbi_path(std::ostream &out, double c0, double c1) const
writes the viterbi path
Definition: fitonoff.cc:213
void write_viterbi_path_compact(std::ostream &out, double c0, double c1)
writes the ranges in the viterbi path
Definition: fitonoff.cc:222
double best_once_on(double c0, double c1)
Definition: fitonoff.cc:41
size_t size_type
general size type
Definition: aux.hh:94
pf_t forward(double c0, double c1)
Definition: fitonoff.cc:88
void print_table(const std::string &name, const std::vector< bool > &v) const
Definition: fitonoff.cc:255
Definition: aligner.cc:17
Implements fitting of a two-step function to a number sequence.
Definition: fitonoff.hh:24
FitOnOff(numseq_t &x_, double delta_01_, double delta_10_, double beta_)
Definition: fitonoff.hh:50