bpp-phyl  2.1.0
 All Classes Namespaces Files Functions Variables Friends Pages
DRTreeParsimonyScore.h
Go to the documentation of this file.
1 //
2 // File: DRTreeParsimonyScore.h
3 // Created by: Julien Dutheil
4 // Created on: Thu Jul 28 18:31 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 _DRTREEPARSIMONYSCORE_H_
41 #define _DRTREEPARSIMONYSCORE_H_
42 
44 #include "DRTreeParsimonyData.h"
45 #include "../NNISearchable.h"
46 #include "../TreeTools.h"
47 
48 namespace bpp
49 {
57  public virtual NNISearchable
58 {
59 private:
62 
63 public:
65  const Tree& tree,
66  const SiteContainer& data,
67  bool verbose = true,
68  bool includeGaps = false)
69  throw (Exception);
70 
72  const Tree& tree,
73  const SiteContainer& data,
74  const StateMap* statesMap,
75  bool verbose = true)
76  throw (Exception);
77 
79 
80  DRTreeParsimonyScore& operator=(const DRTreeParsimonyScore& tp);
81 
82  virtual ~DRTreeParsimonyScore();
83 
84 #ifndef NO_VIRTUAL_COV
85  DRTreeParsimonyScore*
86 #else
87  Clonable*
88 #endif
89  clone() const { return new DRTreeParsimonyScore(*this); }
90 
91 private:
92  void init_(const SiteContainer& data, bool verbose);
93 
94 protected:
100  virtual void computeScores();
104  virtual void computeScoresPreorder(const Node*);
108  virtual void computeScoresPostorder(const Node*);
109 
110 public:
111  unsigned int getScore() const;
112  unsigned int getScoreForSite(size_t site) const;
113 
121  static void computeScoresPostorderForNode(
122  const DRTreeParsimonyNodeData& pData,
123  std::vector<Bitset>& rBitsets,
124  std::vector<unsigned int>& rScores);
125 
134  static void computeScoresPreorderForNode(
135  const DRTreeParsimonyNodeData& pData,
136  const Node* source,
137  std::vector<Bitset>& rBitsets,
138  std::vector<unsigned int>& rScores);
139 
147  static void computeScoresForNode(
148  const DRTreeParsimonyNodeData& pData, std::vector<Bitset>& rBitsets,
149  std::vector<unsigned int>& rScores);
150 
163  static void computeScoresFromArrays(
164  const std::vector<const std::vector<Bitset>*>& iBitsets,
165  const std::vector<const std::vector<unsigned int>*>& iScores,
166  std::vector<Bitset>& oBitsets,
167  std::vector<unsigned int>& oScores);
168 
174  double getTopologyValue() const throw (Exception) { return getScore(); }
175 
176  double testNNI(int nodeId) const throw (NodeException);
177 
178  void doNNI(int nodeId) throw (NodeException);
179 
180  // Tree& getTopology() { return getTree(); } do we realy need this one?
181  const Tree& getTopology() const { return getTree(); }
182 
184  {
186  computeScores();
187  }
188 
191 };
192 } // end of namespace bpp.
193 
194 #endif // _DRTREEPARSIMONYSCORE_H_
195