bpp-phyl3  3.0.0
PairedSiteLikelihoods.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_LEGACY_LIKELIHOOD_PAIREDSITELIKELIHOODS_H
6 #define BPP_PHYL_LEGACY_LIKELIHOOD_PAIREDSITELIKELIHOODS_H
7 
8 
9 // From the STL:
10 #include <vector>
11 #include <string>
12 
13 // From Bio++
14 #include "TreeLikelihood.h"
15 #include <Bpp/Exceptions.h>
16 
17 namespace bpp
18 {
27 {
28 private:
29  std::vector<std::vector<double>> logLikelihoods_;
30  std::vector<std::string> modelNames_;
31 
32 public:
34 
45  const std::vector<std::vector<double>>& siteLogLikelihoods,
46  const std::vector<std::string>& modelNames = std::vector<std::string>()
47  );
48 
50 
59  void appendModel(
60  const std::vector<double>& siteLogLikelihoods,
61  const std::string& modelName = "");
62 
70  void appendModel(const bpp::TreeLikelihoodInterface& treelikelihood);
71 
79  void appendModels(const PairedSiteLikelihoods& psl);
80 
84  const std::vector<std::vector<double>>& getLikelihoods() const
85  {
86  return logLikelihoods_;
87  }
88 
92  const std::vector<std::string>& getModelNames() const
93  {
94  return modelNames_;
95  }
96 
98  size_t getNumberOfModels() const
99  {
100  return logLikelihoods_.size();
101  }
102 
107  std::size_t getNumberOfSites() const
108  {
109  try
110  {
111  return logLikelihoods_.at(0).size();
112  }
113  catch (std::out_of_range&)
114  {
115  throw Exception("PairedSiteLikelihoods::nsites: The container is empty, there isn't a number of sites.");
116  }
117  }
118 
125  void setName(std::size_t pos, std::string& name)
126  {
127  modelNames_.at(pos) = name;
128  }
129 
144  std::pair< std::vector<std::string>, std::vector<double>> computeExpectedLikelihoodWeights(int replicates = 10000) const;
145 
156  static std::vector<int> bootstrap(std::size_t length, double scaling = 1);
157 };
158 } // namespace bpp.
159 #endif // BPP_PHYL_LEGACY_LIKELIHOOD_PAIREDSITELIKELIHOODS_H
A container for paired-site likelihoods (likelihoods over the same sites for different models,...
size_t getNumberOfModels() const
Get the number of models in the container.
std::vector< std::vector< double > > logLikelihoods_
const std::vector< std::string > & getModelNames() const
std::size_t getNumberOfSites() const
void appendModels(const PairedSiteLikelihoods &psl)
Append models by concatenation.
std::vector< std::string > modelNames_
const std::vector< std::vector< double > > & getLikelihoods() const
std::pair< std::vector< std::string >, std::vector< double > > computeExpectedLikelihoodWeights(int replicates=10000) const
Compute the Expected Likelihood Weights of the models.
void appendModel(const std::vector< double > &siteLogLikelihoods, const std::string &modelName="")
Append a model.
void setName(std::size_t pos, std::string &name)
Set the name of a model.
static std::vector< int > bootstrap(std::size_t length, double scaling=1)
Draw a nonparametric pseudoreplicate.
The TreeLikelihood interface.
Defines the basic types of data flow nodes.