bpp-phyl  2.2.0
PhylogeneticsApplicationTools.h
Go to the documentation of this file.
1 //
2 // File: PhylogeneticsApplicationTools.h
3 // Created by: Julien Dutheil
4 // Created on: Fri Oct 21 16:49 2005
5 // from old file ApplicationTools.h created on Sun Dec 14 09:36:26 2003
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for phylogenetic data analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef _PHYLOGENETICSAPPLICATIONTOOLS_H_
42 #define _PHYLOGENETICSAPPLICATIONTOOLS_H_
43 
44 #include "../Tree.h"
45 #include "../Model/SubstitutionModel.h"
46 #include "../Model/SubstitutionModelSet.h"
47 #include "../Model/MixedSubstitutionModelSet.h"
48 #include "../Model/MarkovModulatedSubstitutionModel.h"
49 #include "../Likelihood/HomogeneousTreeLikelihood.h"
50 #include "../Likelihood/ClockTreeLikelihood.h"
51 #include "../Mapping/SubstitutionCount.h"
52 #include <Bpp/Text/TextTools.h>
53 #include <Bpp/Text/StringTokenizer.h>
54 #include <Bpp/Io/OutputStream.h>
55 #include <Bpp/Numeric/Prob/DiscreteDistribution.h>
56 #include <Bpp/Numeric/Prob/MultipleDiscreteDistribution.h>
57 #include <Bpp/Numeric/Function/Optimizer.h>
58 
59 // From SeqLib:
60 #include <Bpp/Seq/Container/SiteContainer.h>
61 #include <Bpp/Seq/Container/VectorSiteContainer.h>
62 
63 // From the STL:
64 #include <string>
65 #include <map>
66 
67 namespace bpp
68 {
69 
70 
86  {
87 
88  public:
91 
92 
107  static Tree* getTree(
108  std::map<std::string, std::string>& params,
109  const std::string& prefix = "input.",
110  const std::string& suffix = "",
111  bool suffixIsOptional = true,
112  bool verbose = true,
113  int warn = 1) throw (Exception);
114 
129  static std::vector<Tree*> getTrees(
130  std::map<std::string, std::string>& params,
131  const std::string& prefix = "input.",
132  const std::string& suffix = "",
133  bool suffixIsOptional = true,
134  bool verbose = true,
135  int warn = 1) throw (Exception);
136 
159  const Alphabet* alphabet,
160  const GeneticCode* gCode,
161  const SiteContainer* data,
162  std::map<std::string, std::string>& params,
163  const std::string& suffix = "",
164  bool suffixIsOptional = true,
165  bool verbose = true,
166  int warn = 1) throw (Exception);
167 
168 
191  SubstitutionModel& model,
192  std::map<std::string, std::string>& unparsedParameterValues,
193  size_t modelNumber,
194  const SiteContainer* data,
195  std::map<std::string, double>& existingParams,
196  std::map<std::string, std::string>& sharedParams,
197  bool verbose) throw (Exception);
198 
219  const Alphabet* alphabet,
220  const GeneticCode* gCode,
221  const SiteContainer* data,
222  std::map<std::string, std::string>& params,
223  const std::vector<double>& rateFreqs,
224  const std::string& suffix = "",
225  bool suffixIsOptional = true,
226  bool verbose = true,
227  int warn = 1) throw (Exception);
228 
248  const Alphabet* alphabet,
249  const GeneticCode* gCode,
250  const std::string& freqDescription,
251  const SiteContainer* data,
252  const std::vector<double>& rateFreqs,
253  bool verbose = true,
254  int warn = 1)
255  throw (Exception);
256 
264  const Alphabet* alphabet,
265  const GeneticCode* gcode,
266  const SiteContainer* data,
267  std::map<std::string, std::string>& params,
268  const std::string& suffix = "",
269  bool suffixIsOptional = true,
270  bool verbose = true,
271  int warn = 1);
272 
327  static void setSubstitutionModelSet(
328  SubstitutionModelSet& modelSet,
329  const Alphabet* alphabet,
330  const GeneticCode* gcode,
331  const SiteContainer* data,
332  std::map<std::string, std::string>& params,
333  const std::string& suffix = "",
334  bool suffixIsOptional = true,
335  bool verbose = true,
336  int warn = 1);
337 
402  MixedSubstitutionModelSet& mixedModelSet,
403  const Alphabet* alphabet,
404  const SiteContainer* data,
405  std::map<std::string, std::string>& params,
406  const std::string& suffix = "",
407  bool suffixIsOptional = true,
408  bool verbose = true,
409  int warn = 1);
410 
426  static MultipleDiscreteDistribution* getMultipleDistributionDefaultInstance(
427  const std::string& distDescription,
428  std::map<std::string, std::string>& unparsedParameterValues,
429  bool verbose = true);
430 
445  static DiscreteDistribution* getRateDistribution(
446  std::map<std::string, std::string>& params,
447  const std::string& suffix = "",
448  bool suffixIsOptional = true,
449  bool verbose = true)
450  throw (Exception);
451 
473  TreeLikelihood* tl,
474  const ParameterList& parameters,
475  std::map<std::string, std::string>& params,
476  const std::string& suffix = "",
477  bool suffixIsOptional = true,
478  bool verbose = true,
479  int warn = 1)
480  throw (Exception);
481 
495  static void optimizeParameters(
497  const ParameterList& parameters,
498  std::map<std::string, std::string>& params,
499  const std::string& suffix = "",
500  bool suffixIsOptional = true,
501  bool verbose = true,
502  int warn = 1)
503  throw (Exception);
504 
513  static void checkEstimatedParameters(const ParameterList& pl);
514 
527  const Alphabet* alphabet,
528  const SubstitutionModel* model,
529  map<string, string>& params,
530  string suffix = "",
531  bool verbose = true,
532  int warn = 1);
533 
550  static void writeTree(
551  const TreeTemplate<Node>& tree,
552  std::map<std::string, std::string>& params,
553  const std::string& prefix = "output.",
554  const std::string& suffix = "",
555  bool suffixIsOptional = true,
556  bool verbose = true,
557  bool checkOnly = false,
558  int warn = 1) throw (Exception);
559 
576  static void writeTrees(
577  const std::vector<Tree*>& trees,
578  std::map<std::string, std::string>& params,
579  const std::string& prefix = "output.",
580  const std::string& suffix = "",
581  bool suffixIsOptional = true,
582  bool verbose = true,
583  bool checkOnly = false,
584  int warn = 1) throw (Exception);
585 
586 
587 
595  static void printParameters(const SubstitutionModel* model, OutputStream& out,int warn = 1);
596 
597 
598 
606  static void printParameters(const SubstitutionModelSet* modelSet, OutputStream& out, int warn = 1);
607 
608 
609 
616  static void printParameters(const DiscreteDistribution* rDist, OutputStream& out);
617 
618  };
619 
620 } //end of namespace bpp.
621 
622 #endif //_PHYLOGENETICSAPPLICATIONTOOLS_H_
623 
static Tree * getTree(std::map< std::string, std::string > &params, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Build a Tree object according to options.
Substitution models manager for non-homogeneous / non-reversible models of evolution.
Interface for all substitution models.
static void writeTree(const TreeTemplate< Node > &tree, std::map< std::string, std::string > &params, const std::string &prefix="output.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, bool checkOnly=false, int warn=1)
Write a tree according to options.
static SubstitutionModelSet * getSubstitutionModelSet(const Alphabet *alphabet, const GeneticCode *gcode, const SiteContainer *data, std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Gets a SubstitutionModelSet object according to options.
static FrequenciesSet * getFrequenciesSet(const Alphabet *alphabet, const GeneticCode *gCode, const std::string &freqDescription, const SiteContainer *data, const std::vector< double > &rateFreqs, bool verbose=true, int warn=1)
Get A FrequenciesSet object according to options.
The TreeLikelihood interface.
static SubstitutionModel * getSubstitutionModel(const Alphabet *alphabet, const GeneticCode *gCode, const SiteContainer *data, std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Build a SubstitutionModel object according to options.
The phylogenetic tree class.
Interface for phylogenetic tree objects.
Definition: Tree.h:148
Parametrize a set of state frequencies.
static MultipleDiscreteDistribution * getMultipleDistributionDefaultInstance(const std::string &distDescription, std::map< std::string, std::string > &unparsedParameterValues, bool verbose=true)
Build a multi-dimension distribution as a MultipleDiscreteDistribution object with default parameter ...
static std::vector< Tree * > getTrees(std::map< std::string, std::string > &params, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Build a list ofTree objects according to options.
This class provides some common tools for applications.
static void completeMixedSubstitutionModelSet(MixedSubstitutionModelSet &mixedModelSet, const Alphabet *alphabet, const SiteContainer *data, std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Complete a MixedSubstitutionModelSet object according to options, given this model has already been f...
Substitution models manager for Mixed Substitution Models. This class inherits from SubstitutionModel...
static void printParameters(const SubstitutionModel *model, OutputStream &out, int warn=1)
Output a SubstitutionModel description to a file.
Interface for likelihood computation with a global clock and rate across sites variation.
static TreeLikelihood * optimizeParameters(TreeLikelihood *tl, const ParameterList &parameters, std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Optimize parameters according to options.
The SubstitutionsCount interface.
static void writeTrees(const std::vector< Tree *> &trees, std::map< std::string, std::string > &params, const std::string &prefix="output.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, bool checkOnly=false, int warn=1)
Write a tree according to options.
static void setSubstitutionModelSet(SubstitutionModelSet &modelSet, const Alphabet *alphabet, const GeneticCode *gcode, const SiteContainer *data, std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Sets a SubstitutionModelSet object according to options.
static FrequenciesSet * getRootFrequenciesSet(const Alphabet *alphabet, const GeneticCode *gCode, const SiteContainer *data, std::map< std::string, std::string > &params, const std::vector< double > &rateFreqs, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
Get A FrequenciesSet object for root frequencies (NH models) according to options.
static void setSubstitutionModelParametersInitialValuesWithAliases(SubstitutionModel &model, std::map< std::string, std::string > &unparsedParameterValues, size_t modelNumber, const SiteContainer *data, std::map< std::string, double > &existingParams, std::map< std::string, std::string > &sharedParams, bool verbose)
Set parameter initial values of a given model in a set according to options.
static void checkEstimatedParameters(const ParameterList &pl)
Check if parameter values are close to their definition boundary.
static DiscreteDistribution * getRateDistribution(std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true)
Build a DiscreteDistribution object according to options.
static SubstitutionCount * getSubstitutionCount(const Alphabet *alphabet, const SubstitutionModel *model, map< string, string > &params, string suffix="", bool verbose=true, int warn=1)
Get a SubstitutionCount instance.