bpp-phyl  2.2.0
AbstractTreeParsimonyScore.h
Go to the documentation of this file.
1 //
2 // File: AbstractTreeParsimonyScore.h
3 // Created by: Julien Dutheil
4 // Created on: Thu Jul 28 17:25 2005
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 _ABSTRACTTREEPARSIMONYSCORE_H_
41 #define _ABSTRACTTREEPARSIMONYSCORE_H_
42 
43 #include "TreeParsimonyScore.h"
44 #include "../Model/StateMap.h"
45 
46 // From SeqLib:
47 #include <Bpp/Seq/Container/SiteContainer.h>
48 
49 namespace bpp
50 {
55  public virtual TreeParsimonyScore
56 {
57 private:
59  const SiteContainer* data_;
60  const Alphabet* alphabet_;
62  size_t nbStates_;
63 
64 public:
66  const Tree& tree,
67  const SiteContainer& data,
68  bool verbose,
69  bool includeGaps)
70  throw (Exception);
71 
73  const Tree& tree,
74  const SiteContainer& data,
75  const StateMap* statesMap,
76  bool verbose)
77  throw (Exception);
78 
80  tree_(0),
81  data_(0),
82  alphabet_(tp.alphabet_),
83  statesMap_(0),
85  {
86  tree_ = tp.tree_->clone();
87  data_ = dynamic_cast<SiteContainer*>(tp.data_->clone());
88  statesMap_ = tp.statesMap_->clone();
89  }
90 
92  {
93  tree_ = dynamic_cast<TreeTemplate<Node>*>(tp.tree_->clone());
94  data_ = dynamic_cast<SiteContainer*>(tp.data_->clone());
95  alphabet_ = tp.alphabet_;
96  statesMap_ = tp.statesMap_->clone();
97  nbStates_ = tp.nbStates_;
98  return *this;
99  }
100 
102  {
103  delete tree_;
104  if (data_) delete data_;
105  }
106 
107 private:
108  void init_(const SiteContainer& data, bool verbose) throw (Exception);
109 
110 public:
111  virtual const Tree& getTree() const { return *tree_; }
112  virtual std::vector<unsigned int> getScoreForEachSite() const;
113  virtual const StateMap& getStateMap() const { return *statesMap_; }
114 
115 protected:
116  const TreeTemplate<Node>* getTreeP_() const { return tree_; }
118 };
119 } // end of namespace bpp.
120 
121 #endif // _ABSTRACTTREEPARSIMONYSCORE_H_
122 
Compute a parsimony score.
AbstractTreeParsimonyScore(const Tree &tree, const SiteContainer &data, bool verbose, bool includeGaps)
virtual StateMap * clone() const =0
The phylogenetic tree class.
Interface for phylogenetic tree objects.
Definition: Tree.h:148
AbstractTreeParsimonyScore & operator=(const AbstractTreeParsimonyScore &tp)
void init_(const SiteContainer &data, bool verbose)
virtual std::vector< unsigned int > getScoreForEachSite() const
Get the score for each site for the current tree, i.e. the total minimum number of changes in the tre...
const TreeTemplate< Node > * getTreeP_() const
Partial implementation of the TreeParsimonyScore interface.
virtual const StateMap & getStateMap() const
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:58
AbstractTreeParsimonyScore(const AbstractTreeParsimonyScore &tp)
virtual const Tree & getTree() const
Get the tree for wich scores are computed.