bpp-phyl  2.2.0
BioNJ.h
Go to the documentation of this file.
1 //
2 // File: BioNJ.cpp
3 // Created by: Vincent Ranwez
4 // Created on: Tue Apr 11 14:23 2006
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
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 _BIONJ_H_
41 #define _BIONJ_H_
42 
43 #include "NeighborJoining.h"
44 
45 namespace bpp
46 {
55 class BioNJ :
56  public NeighborJoining
57 {
58 private:
59  DistanceMatrix variance_;
60  double lambda_;
61 
62 public:
70  BioNJ(bool rooted = false, bool positiveLengths = false, bool verbose = true) :
71  NeighborJoining(rooted, positiveLengths, verbose),
72  variance_(0),
73  lambda_(0) {}
74 
83  BioNJ(const DistanceMatrix& matrix, bool rooted = false, bool positiveLengths = false, bool verbose = true) throw (Exception) :
84  NeighborJoining(rooted, positiveLengths, verbose),
85  // Use the default constructor, because the other one call computeTree.
86  variance_(matrix),
87  lambda_(0)
88  {
89  setDistanceMatrix(matrix);
90  outputPositiveLengths(positiveLengths);
91  computeTree();
92  }
93 
94  BioNJ* clone() const { return new BioNJ(*this); }
95 
96  virtual ~BioNJ() {}
97 
98 public:
99  std::string getName() const { return "BioNJ"; }
100 
101  void setDistanceMatrix(const DistanceMatrix& matrix) throw (Exception)
102  {
104  variance_ = matrix;
105  }
106  void computeTree() throw (Exception);
107  double computeDistancesFromPair(const std::vector<size_t>& pair, const std::vector<double>& branchLengths, size_t pos);
108 };
109 } // end of namespace bpp.
110 
111 #endif // _BIONJ_H_
112 
double lambda_
Definition: BioNJ.h:60
void computeTree()
Compute the tree corresponding to the distance matrix.
Definition: BioNJ.cpp:60
BioNJ(bool rooted=false, bool positiveLengths=false, bool verbose=true)
Create a new BioNJ object instance and compute a tree from a distance matrix.
Definition: BioNJ.h:70
STL namespace.
DistanceMatrix variance_
Definition: BioNJ.h:59
virtual void outputPositiveLengths(bool yn)
BioNJ * clone() const
Definition: BioNJ.h:94
The BioNJ distance method.
Definition: BioNJ.h:55
std::string getName() const
Definition: BioNJ.h:99
The neighbor joining distance method.
void setDistanceMatrix(const DistanceMatrix &matrix)
Set the distance matrix to use.
Definition: BioNJ.h:101
double computeDistancesFromPair(const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos)
Actualizes the distance matrix according to a given pair and the corresponding branch lengths...
Definition: BioNJ.cpp:53
BioNJ(const DistanceMatrix &matrix, bool rooted=false, bool positiveLengths=false, bool verbose=true)
Create a new BioNJ object instance and compute a tree from a distance matrix.
Definition: BioNJ.h:83
virtual void setDistanceMatrix(const DistanceMatrix &matrix)
Set the distance matrix to use.
virtual ~BioNJ()
Definition: BioNJ.h:96