barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
geese-node-bones.hpp
Go to the documentation of this file.
1 #ifndef GEESE_NODE_BONES
2 #define GEESE_NODE_BONES 1
3 
11 class Node {
12 public:
13 
14  size_t id;
15  size_t ord;
16 
18  std::vector< size_t > annotations;
20 
21  std::vector< PhyloArray > arrays = {};
22 
23  Node * parent = nullptr;
24  std::vector< Node* > offspring = {};
25  std::vector< size_t > narray = {};
26  bool visited = false;
27 
28  std::vector< double > subtree_prob;
29  std::vector< double > probability;
30 
36 
37  Node() : ord(std::numeric_limits< size_t >::max()) {};
38  Node(size_t id_, size_t ord_, bool duplication_);
39  Node(size_t id_, size_t ord_, std::vector< size_t > annotations_, bool duplication_);
40 
41  // Move constructor
42  Node(Node && x) noexcept;
43 
44  // Copy constructor
45  Node(const Node & x);
47 
48  ~Node() {};
49 
50  int get_parent() const;
51 
52  size_t noffspring() const noexcept;
53  bool is_leaf() const noexcept;
54 
55 };
56 
57 inline Node::Node(size_t id_, size_t ord_, bool duplication_)
58  : id(id_), ord(ord_), duplication(duplication_) {
59 
60  return;
61 }
62 
63 inline Node::Node(
64  size_t id_,
65  size_t ord_,
66  std::vector< size_t > annotations_,
67  bool duplication_
68  ) : id(id_), ord(ord_), annotations(annotations_), duplication(duplication_) {}
69 
70 inline Node::Node(Node && x) noexcept :
71  id(x.id), ord(x.ord), array(std::move(x.array)),
72  annotations(std::move(x.annotations)),
73  duplication(x.duplication), arrays(std::move(x.arrays)),
74  parent(std::move(x.parent)),
75  offspring(std::move(x.offspring)),
76  narray(std::move(x.narray)),
77  visited(x.visited),
78  subtree_prob(std::move(x.subtree_prob)),
79  probability(std::move(x.probability)) {
80 
81  return;
82 
83 }
84 
85 inline Node::Node(const Node & x) :
86  id(x.id), ord(x.ord), array(x.array),
87  annotations(x.annotations),
88  duplication(x.duplication), arrays(x.arrays),
89  parent(x.parent),
90  offspring(x.offspring),
91  narray(x.narray),
92  visited(x.visited),
93  subtree_prob(x.subtree_prob),
94  probability(x.probability) {
95 
96  return;
97 
98 }
99 
100 inline int Node::get_parent() const {
101  if (parent == nullptr)
102  return -1;
103  else
104  return static_cast<int>(parent->id);
105 }
106 inline size_t Node::noffspring() const noexcept {
107 
108  return this->offspring.size();
109 
110 }
111 
112 inline bool Node::is_leaf() const noexcept {
113  return offspring.size() == 0u;
114 }
115 
116 #endif
A single node for the model.
std::vector< size_t > annotations
Observed annotations (only defined for Geese)
PhyloArray array
Array of the node.
bool duplication
std::vector< PhyloArray > arrays
Arrays given all possible states.
size_t id
Id of the node (as specified in the input)
std::vector< Node * > offspring
Offspring nodes.
int get_parent() const
std::vector< size_t > narray
ID of the array in the model.
std::vector< double > probability
The probability of observing each state.
size_t noffspring() const noexcept
bool visited
Node * parent
Parent node.
size_t ord
Order in which the node was created.
bool is_leaf() const noexcept
std::vector< double > subtree_prob
Induced subtree probabilities.
Data_Type &&counter_ noexcept
barry::BArrayDense< size_t, NodeData > PhyloArray