2
// File: DRTreeParsimonyScore.h
3
// Created by: Julien Dutheil
4
// Created on: Thu Jul 28 18:31 2005
8
Copyright or © or Copr. CNRS, (November 16, 2004)
10
This software is a computer program whose purpose is to provide classes
11
for phylogenetic data analysis.
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".
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
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.
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.
40
#ifndef _DRTREEPARSIMONYSCORE_H_
41
#define _DRTREEPARSIMONYSCORE_H_
43
#include "AbstractTreeParsimonyScore.h"
44
#include "DRTreeParsimonyData.h"
45
#include "../NNISearchable.h"
46
#include "../TreeTools.h"
52
* @brief Double recursive implementation of interface TreeParsimonyScore.
54
* Uses a DRTreeParsimonyData object for data storage.
56
class DRTreeParsimonyScore :
57
public AbstractTreeParsimonyScore,
58
public virtual NNISearchable
61
DRTreeParsimonyData *parsimonyData_;
62
unsigned int nbDistinctSites_;
67
const SiteContainer& data,
71
DRTreeParsimonyScore(const DRTreeParsimonyScore& tp);
73
DRTreeParsimonyScore& operator=(const DRTreeParsimonyScore& tp);
75
virtual ~DRTreeParsimonyScore();
77
#ifndef NO_VIRTUAL_COV
82
clone() const { return new DRTreeParsimonyScore(* this); }
86
* @brief Compute all scores.
88
* Call the computeScoresPreorder and computeScoresPostorder methods, and then initialize rootBitsets_ and rootScores_.
90
virtual void computeScores();
92
* @brief Compute scores (preorder algorithm).
94
virtual void computeScoresPreorder(const Node *);
96
* @brief Compute scores (postorder algorithm).
98
virtual void computeScoresPostorder(const Node *);
102
unsigned int getScore() const;
103
unsigned int getScoreForSite(unsigned int site) const;
106
* @brief Compute bitsets and scores for each site for a node, in postorder.
108
* @param pData The node data to use.
109
* @param rBitsets The bitset array where to store the resulting bitsets.
110
* @param rScores The score array where to write the resulting scores.
112
static void computeScoresPostorderForNode(
113
const DRTreeParsimonyNodeData& pData,
114
std::vector<Bitset>& rBitsets,
115
std::vector<unsigned int>& rScores);
118
* @brief Compute bitsets and scores for each site for a node, in preorder.
120
* @param pData The node data to use.
121
* @param source The node where we are coming from.
122
* @param rBitsets The bitset array where to store the resulting bitsets.
123
* @param rScores The score array where to write the resulting scores.
125
static void computeScoresPreorderForNode(
126
const DRTreeParsimonyNodeData& pData,
128
std::vector<Bitset>& rBitsets,
129
std::vector<unsigned int>& rScores);
132
* @brief Compute bitsets and scores for each site for a node, in all directions.
134
* @param pData The node data to use.
135
* @param rBitsets The bitset array where to store the resulting bitsets.
136
* @param rScores The score array where to write the resulting scores.
138
static void computeScoresForNode(
139
const DRTreeParsimonyNodeData& pData, std::vector<Bitset>& rBitsets,
140
std::vector<unsigned int>& rScores);
143
* @brief Compute bitsets and scores from an array of arrays.
145
* This method is the more general score computation.
146
* Depending on what is passed as input, it may computes scroes fo a subtree
149
* @param iBitsets The vector of bitset arrays to use.
150
* @param iScores The vector of score arrays to use.
151
* @param oBitsets The bitset array where to store the resulting bitsets.
152
* @param oScores The score array where to write the resulting scores.
154
static void computeScoresFromArrays(
155
const std::vector<const std::vector<Bitset>*>& iBitsets,
156
const std::vector<const std::vector<unsigned int>*>& iScores,
157
std::vector<Bitset>& oBitsets,
158
std::vector<unsigned int>& oScores);
161
* @name Thee NNISearchable interface.
165
double getTopologyValue() const throw (Exception) { return getScore(); }
167
double testNNI(int nodeId) const throw (NodeException);
169
void doNNI(int nodeId) throw (NodeException);
171
//Tree& getTopology() { return getTree(); } do we realy need this one?
173
const Tree& getTopology() const { return getTree(); }
175
void topologyChangeTested(const TopologyChangeEvent & event)
177
parsimonyData_->reInit();
181
void topologyChangeSuccessful(const TopologyChangeEvent & event) {}
186
} //end of namespace bpp.
188
#endif //_DRTREEPARSIMONYSCORE_H_