bpp-phyl  2.2.0
PairedSiteLikelihoods.h
Go to the documentation of this file.
1 //
2 // File: PairedSiteLikelihoods.h
3 // Created by: Nicolas Rochette
4 // Created on: January 6, 2011
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for phylogenetic data analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38  */
39 
40 #ifndef _PAIREDSITELLIKELIHOODS_H_
41 #define _PAIREDSITELLIKELIHOODS_H_
42 
43 // From the STL:
44 #include <vector>
45 #include <string>
46 
47 // From Bio++
48 #include "TreeLikelihood.h"
49 #include <Bpp/Exceptions.h>
50 
51 namespace bpp
52 {
61 {
62 private:
63  std::vector<std::vector<double> > logLikelihoods_;
64  std::vector<std::string> modelNames_;
65 
66 public:
68 
79  const std::vector<std::vector<double> >& siteLogLikelihoods,
80  const std::vector<std::string>& modelNames = std::vector<std::string>()
81  ) throw (Exception);
82 
84 
93  void appendModel(
94  const std::vector<double>& siteLogLikelihoods,
95  const std::string& modelName = "") throw (Exception);
96 
104  void appendModel(const bpp::TreeLikelihood& treelikelihood) throw (Exception);
105 
113  void appendModels(const PairedSiteLikelihoods& psl) throw (Exception);
114 
118  const std::vector<std::vector<double> >& getLikelihoods() const
119  {
120  return logLikelihoods_;
121  }
122 
126  const std::vector<std::string>& getModelNames() const
127  {
128  return modelNames_;
129  }
130 
132  size_t getNumberOfModels() const
133  {
134  return logLikelihoods_.size();
135  }
136 
141  std::size_t getNumberOfSites() const throw (Exception)
142  {
143  try
144  {
145  return logLikelihoods_.at(0).size();
146  }
147  catch (std::out_of_range&)
148  {
149  throw Exception("PairedSiteLikelihoods::nsites: The container is empty, there isn't a number of sites.");
150  }
151  }
152 
159  void setName(std::size_t pos, std::string& name)
160  {
161  modelNames_.at(pos) = name;
162  }
163 
178  std::pair< std::vector<std::string>, std::vector<double> > computeExpectedLikelihoodWeights(int replicates = 10000) const;
179 
190  static std::vector<int> bootstrap(std::size_t length, double scaling = 1);
191 
192 };
193 } // namespace bpp.
194 
195 #endif //_PAIREDSITELLIKELIHOODS_H_
const std::vector< std::string > & getModelNames() const
A container for paired-site likelihoods (likelihoods over the same sites for different models...
static std::vector< int > bootstrap(std::size_t length, double scaling=1)
Draw a nonparametric pseudoreplicate.
void appendModels(const PairedSiteLikelihoods &psl)
Append models by concatenation.
The TreeLikelihood interface.
STL namespace.
void appendModel(const std::vector< double > &siteLogLikelihoods, const std::string &modelName="")
Append a model.
std::pair< std::vector< std::string >, std::vector< double > > computeExpectedLikelihoodWeights(int replicates=10000) const
Compute the Expected Likelihood Weights of the models.
std::vector< std::vector< double > > logLikelihoods_
std::size_t getNumberOfSites() const
const std::vector< std::vector< double > > & getLikelihoods() const
size_t getNumberOfModels() const
Get the number of models in the container.
void setName(std::size_t pos, std::string &name)
Set the name of a model.
std::vector< std::string > modelNames_