bpp-phyl3 3.0.0
BioNJ.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_DISTANCE_BIONJ_H
6#define BPP_PHYL_DISTANCE_BIONJ_H
7
8
9#include "NeighborJoining.h"
10
11namespace bpp
12{
21class BioNJ :
22 public NeighborJoining
23{
24private:
26 double lambda_;
27
28public:
36 BioNJ(bool rooted = false, bool positiveLengths = false, bool verbose = true) :
37 NeighborJoining(rooted, positiveLengths, verbose),
38 variance_(0),
39 lambda_(0) {}
40
49 BioNJ(const DistanceMatrix& matrix, bool rooted = false, bool positiveLengths = false, bool verbose = true) :
50 NeighborJoining(rooted, positiveLengths, verbose),
51 // Use the default constructor, because the other one call computeTree.
52 variance_(matrix),
53 lambda_(0)
54 {
55 setDistanceMatrix(matrix);
56 outputPositiveLengths(positiveLengths);
58 }
59
60 BioNJ* clone() const { return new BioNJ(*this); }
61
62 virtual ~BioNJ() {}
63
64public:
65 std::string getName() const { return "BioNJ"; }
66
68 {
70 variance_ = matrix;
71 }
72 void computeTree();
73 double computeDistancesFromPair(const std::vector<size_t>& pair, const std::vector<double>& branchLengths, size_t pos);
74};
75} // end of namespace bpp.
76#endif // BPP_PHYL_DISTANCE_BIONJ_H
The BioNJ distance method.
Definition: BioNJ.h:23
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:18
virtual ~BioNJ()
Definition: BioNJ.h:62
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:36
std::string getName() const
Definition: BioNJ.h:65
BioNJ * clone() const
Definition: BioNJ.h:60
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:49
void setDistanceMatrix(const DistanceMatrix &matrix)
Set the distance matrix to use.
Definition: BioNJ.h:67
DistanceMatrix variance_
Definition: BioNJ.h:25
double lambda_
Definition: BioNJ.h:26
void computeTree()
Compute the tree corresponding to the distance matrix.
Definition: BioNJ.cpp:25
The neighbor joining distance method.
virtual void setDistanceMatrix(const DistanceMatrix &matrix)
Set the distance matrix to use.
virtual void outputPositiveLengths(bool yn)
Defines the basic types of data flow nodes.