barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
geese-types.hpp
Go to the documentation of this file.
1 #ifndef GEESE_TYPES_HPP
2 #define GEESE_TYPES_HPP
3 
4 #define POS(a,b) (b)*N + (a)
5 
15 class NodeData {
16 public:
17 
21  std::vector< double > blengths = {};
22 
26  std::vector< bool > states = {};
27 
28  bool duplication = true;
29  bool has_leaf = false;
30 
31 
33  const std::vector< double > & blengths_,
34  const std::vector< bool > & states_,
35  bool duplication_ = true,
36  bool has_leaf_ = false
37  ) : blengths(blengths_), states(states_), duplication(duplication_),
38  has_leaf(has_leaf_) {};
39 
40  // ~NodeData() {};
41 
42 };
43 
45 private:
46  std::vector< size_t > data;
47  std::vector< double > * counters;
48 
49 public:
51  std::vector< size_t > data_,
52  std::vector< double > * counters_ = nullptr
53  ) : data(data_), counters(counters_) {};
54 
55  PhyloCounterData() : data(0u) {};
56 
57  size_t at(size_t d) {return data.at(d);};
58  size_t operator()(size_t d) {return data.at(d);};
59  size_t operator[](size_t d) {return data[d];};
60  void reserve(size_t x) {return data.reserve(x);};
61  void push_back(size_t x) {return data.push_back(x);};
62  void shrink_to_fit() {return data.shrink_to_fit();};
63  size_t size() {return data.size();};
64 
65  std::vector< size_t >::iterator begin() {return data.begin();};
66  std::vector< size_t >::iterator end() {return data.end();};
67 
68  bool empty() {return data.empty();};
69  std::vector< double > * get_counters() {return counters;};
70 
71 };
72 
74 public:
75  const std::vector< double > * counts;
76  size_t pos;
77  size_t lb;
78  size_t ub;
79  size_t duplication;
80 
82  const std::vector< double > * counts_,
83  size_t pos_,
84  size_t lb_,
85  size_t ub_,
86  size_t duplication_
87  ) :
88  counts(counts_), pos(pos_), lb(lb_), ub(ub_), duplication(duplication_) {};
89 
90  const double operator()() const
91  {
92  return (*counts)[pos];
93  }
94 
96 
97 };
98 
99 
100 typedef std::vector< std::pair< size_t, size_t > > PhyloRuleData;
101 
103 typedef barry::BArrayDense<size_t, NodeData> PhyloArray;
104 typedef barry::Counter<PhyloArray, PhyloCounterData > PhyloCounter;
105 typedef barry::Counters< PhyloArray, PhyloCounterData> PhyloCounters;
106 
107 typedef barry::Rule<PhyloArray,PhyloRuleData> PhyloRule;
108 typedef barry::Rules<PhyloArray,PhyloRuleData> PhyloRules;
109 
110 typedef barry::Rule<PhyloArray,PhyloRuleDynData> PhyloRuleDyn;
111 typedef barry::Rules<PhyloArray,PhyloRuleDynData> PhyloRulesDyn;
112 
113 typedef barry::Support<PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloSupport;
114 typedef barry::StatsCounter<PhyloArray, PhyloCounterData> PhyloStatsCounter;
115 typedef barry::Model<PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloModel;
116 typedef barry::PowerSet<PhyloArray, PhyloRuleData> PhyloPowerSet;
118 
119 // template<>
120 // inline void PhyloArray::insert_cell(
121 // size_t i,
122 // size_t j,
123 // const Cell< size_t > & v,
124 // bool check_bounds,
125 // bool
126 // ) {
127 
128 // if (check_bounds)
129 // out_of_range(i,j);
130 
131 // auto & elptr = el[POS(i,j)];
132 
133 // if (elptr == 0u)
134 // {
135 
136 // el_rowsums[i] += v.value;
137 // el_colsums[j] += v.value;
138 
139 // }
140 // else
141 // {
142 
143 // el_rowsums[i] += (v.value - elptr);
144 // el_colsums[j] += (v.value - elptr);
145 
146 // }
147 
148 // elptr = v.value;
149 
150 // return;
151 
152 // }
153 
154 #undef POS
155 
156 #endif
Data definition for the PhyloArray class.
Definition: geese-types.hpp:15
std::vector< double > blengths
Definition: geese-types.hpp:21
std::vector< bool > states
Definition: geese-types.hpp:26
bool has_leaf
Whether the node has a leaf as offspring.
Definition: geese-types.hpp:29
bool duplication
Whether the node is a duplication.
Definition: geese-types.hpp:28
NodeData(const std::vector< double > &blengths_, const std::vector< bool > &states_, bool duplication_=true, bool has_leaf_=false)
Definition: geese-types.hpp:32
size_t operator()(size_t d)
Definition: geese-types.hpp:58
std::vector< size_t >::iterator end()
Definition: geese-types.hpp:66
PhyloCounterData(std::vector< size_t > data_, std::vector< double > *counters_=nullptr)
Definition: geese-types.hpp:50
size_t at(size_t d)
Definition: geese-types.hpp:57
void push_back(size_t x)
Definition: geese-types.hpp:61
std::vector< size_t >::iterator begin()
Definition: geese-types.hpp:65
void reserve(size_t x)
Definition: geese-types.hpp:60
std::vector< double > * get_counters()
Definition: geese-types.hpp:69
size_t operator[](size_t d)
Definition: geese-types.hpp:59
const double operator()() const
Definition: geese-types.hpp:90
PhyloRuleDynData(const std::vector< double > *counts_, size_t pos_, size_t lb_, size_t ub_, size_t duplication_)
Definition: geese-types.hpp:81
const std::vector< double > * counts
Definition: geese-types.hpp:75
Data_Type &&counter_ data(std::move(counter_.data))
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type data_
barry::Counters< PhyloArray, PhyloCounterData > PhyloCounters
barry::Model< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloModel
std::vector< std::pair< size_t, size_t > > PhyloRuleData
barry::Rule< PhyloArray, PhyloRuleData > PhyloRule
barry::BArrayDense< size_t, NodeData > PhyloArray
barry::Counter< PhyloArray, PhyloCounterData > PhyloCounter
barry::StatsCounter< PhyloArray, PhyloCounterData > PhyloStatsCounter
barry::Rule< PhyloArray, PhyloRuleDynData > PhyloRuleDyn
barry::Rules< PhyloArray, PhyloRuleDynData > PhyloRulesDyn
barry::PowerSet< PhyloArray, PhyloRuleData > PhyloPowerSet
barry::Support< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloSupport
barry::Rules< PhyloArray, PhyloRuleData > PhyloRules
Data_Type * counters_