]> git.donarmstrong.com Git - rsem.git/blob - Orientation.h
Added posterior standard deviation of counts as output if either '--calc-pme' or...
[rsem.git] / Orientation.h
1 #ifndef ORIENTATION_H_
2 #define ORIENTATION_H_
3
4 #include<cstdio>
5 #include<cstring>
6 #include<cassert>
7
8 #include "simul.h"
9
10 class Orientation {
11 public:
12         Orientation(double probF = 0.5) {
13                 prob[0] = probF;
14                 prob[1] = 1.0 - probF;
15         }
16
17         Orientation& operator= (const Orientation& rv) {
18                 if (this == &rv) return *this;
19                 memcpy(prob, rv.prob, sizeof(rv.prob));
20                 return *this;
21         }
22
23         //dir : 0 + 1 -
24         double getProb(int dir) { return prob[dir]; }
25
26         void read(FILE* fi) {
27                 assert(fscanf(fi, "%lf", &prob[0]) == 1);
28                 prob[1] = 1.0 - prob[0];
29         }
30
31         void write(FILE* fo) {
32                 fprintf(fo, "%.10g\n", prob[0]);
33         }
34
35
36         int simulate(simul* sampler) { return (sampler->random() < prob[0] ? 0 : 1); }
37
38 private:
39         double prob[2]; //0 + 1 -
40 };
41
42 #endif /* ORIENTATION_H_ */