1 #ifndef GEESE_FLOCK_MEET_HPP
2 #define GEESE_FLOCK_MEET_HPP 1
7 std::vector< std::vector<size_t> > & annotations,
8 std::vector< size_t > & geneid,
9 std::vector< int > & parent,
10 std::vector< bool > & duplication
27 if (annotations[0u].size() !=
nfuns())
28 throw std::length_error(
"The number of functions in the new set of annotations does not match that of the first Geese.");
33 dat.emplace_back(
Geese(annotations, geneid, parent, duplication));
38 return dat.size() - 1u;
61 a.delete_support =
false;
67 a.delete_rengine =
false;
75 printf_barry(
"Initializing nodes in Flock (this could take a while)...\n");
76 barry::Progress prog_bar(this->
ntrees(), bar_width);
103 if (
dat.size() == 0u)
104 throw std::logic_error(
"The flock has no data yet.");
106 return this->
model.get_counters();
113 return this->
model.get_support_fun();
120 return this->
model.get_stats_support();
127 return this->
model.get_stats_target();
139 const std::vector< double > & par,
141 bool use_reduced_sequence,
148 double ans = as_log ? 0.0: 1.0;
150 std::vector< double > par0(par.begin(), par.end() -
nfunctions);
151 model.update_pset_probs(par0, ncores);
157 #if defined(_OPENMP) || defined(__OPENMP)
158 #pragma omp parallel for reduction(+:ans) num_threads(ncores)
160 for (
auto& d : this->
dat)
161 ans += d.likelihood(par, as_log, use_reduced_sequence, 1u,
true);
163 for (
auto& d : this->
dat)
164 ans += d.likelihood(par, as_log, use_reduced_sequence, 1u,
true);
173 #if defined(_OPENMP) || defined(__OPENMP)
174 #pragma omp parallel for reduction(*:ans) num_threads(ncores)
176 for (
auto& d : this->
dat)
177 ans *= d.likelihood(par, as_log, use_reduced_sequence, 1u,
true);
179 for (
auto& d : this->
dat)
180 ans *= d.likelihood(par, as_log, use_reduced_sequence, 1u,
true);
199 return this->
dat.size();
206 std::vector< size_t >
res;
210 for (
const auto& d :
dat)
211 res.push_back(d.nnodes());
220 std::vector< size_t >
res;
224 for (
const auto& d :
dat)
225 res.push_back(d.nleafs());
242 return this->
model.support_size();
249 return this->
model.colnames();
255 std::vector< size_t > * dist
263 for (
const auto & d : dat)
269 size_t tmp = d.parse_polytomies(verb, dist);
297 for (
const auto & tree : this->
dat)
299 nzeros += tree.n_zeros;
300 nones += tree.n_ones;
301 ndpl += tree.n_dupl_events;
302 nspe += tree.n_spec_events;
306 printf_barry(
"FLOCK (GROUP OF GEESE)\nINFO ABOUT THE PHYLOGENIES\n");
312 printf_barry(
"# of ann. [zeros; ones] : [%li; %li]\n", nzeros, nones);
314 printf_barry(
"# of events [dupl; spec] : [%li; %li]\n", ndpl, nspe);
320 return this->
model.print();
327 if (check_bounds &&
i >=
ntrees())
328 throw std::logic_error(
"Geese not found in the flock (out of range).");
Geese * operator()(size_t i, bool check_bounds=true)
Access the i-th geese element.
std::vector< std::string > colnames() const
PhyloCounters * get_counters()
std::vector< double > * get_stats_support()
void set_seed(const size_t &s)
Set the seed of the model.
std::vector< std::vector< double > > * get_stats_target()
size_t nfuns() const noexcept
size_t parse_polytomies(bool verb=true, std::vector< size_t > *dist=nullptr) const noexcept
Check polytomies and return the largest.
void init(size_t bar_width=BARRY_PROGRESS_BAR_WIDTH)
size_t add_data(std::vector< std::vector< size_t > > &annotations, std::vector< size_t > &geneid, std::vector< int > &parent, std::vector< bool > &duplication)
Add a tree to the flock.
std::vector< size_t > nleafs() const noexcept
size_t support_size() const noexcept
double likelihood_joint(const std::vector< double > &par, bool as_log=false, bool use_reduced_sequence=true, size_t ncores=1u)
Returns the joint likelihood of the model.
PhyloSupport * get_support_fun()
std::vector< size_t > nnodes() const noexcept
size_t ntrees() const noexcept
Data_Type &&counter_ noexcept
std::vector< double > keygen_full(const PhyloArray &array, const PhyloCounterData *d)
barry::Counters< PhyloArray, PhyloCounterData > PhyloCounters
barry::Model< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloModel
barry::Support< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloSupport