forked from diepthihoang/mpboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phylonode.cpp
71 lines (56 loc) · 1.66 KB
/
phylonode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// C++ Implementation: phylonode
//
// Description:
//
//
// Author: BUI Quang Minh, Steffen Klaere, Arndt von Haeseler <[email protected]>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "phylonode.h"
void PhyloNeighbor::clearForwardPartialLh(Node *dad) {
clearPartialLh();
for (NeighborVec::iterator it = node->neighbors.begin(); it != node->neighbors.end(); it ++)
if ((*it)->node != dad)
((PhyloNeighbor*)*it)->clearForwardPartialLh(node);
}
void PhyloNode::clearReversePartialLh(PhyloNode *dad) {
PhyloNeighbor *node_nei = (PhyloNeighbor*)findNeighbor(dad);
assert(node_nei);
node_nei->partial_lh_computed = 0;
for (NeighborVec::iterator it = neighbors.begin(); it != neighbors.end(); it ++)
if ((*it)->node != dad)
((PhyloNode*)(*it)->node)->clearReversePartialLh(this);
}
void PhyloNode::clearAllPartialLh(PhyloNode *dad) {
PhyloNeighbor *node_nei = (PhyloNeighbor*)findNeighbor(dad);
node_nei->partial_lh_computed = 0;
node_nei = (PhyloNeighbor*)dad->findNeighbor(this);
node_nei->partial_lh_computed = 0;
for (NeighborVec::iterator it = neighbors.begin(); it != neighbors.end(); it ++)
if ((*it)->node != dad)
((PhyloNode*)(*it)->node)->clearAllPartialLh(this);
}
PhyloNode::PhyloNode()
: Node()
{
init();
}
PhyloNode::PhyloNode(int aid) : Node(aid)
{
init();
}
PhyloNode::PhyloNode(int aid, int aname) : Node (aid, aname) {
init();
}
PhyloNode::PhyloNode(int aid, const char *aname) : Node(aid, aname) {
init();
}
void PhyloNode::init() {
//partial_lh = NULL;
}
void PhyloNode::addNeighbor(Node *node, double length, int id) {
neighbors.push_back(new PhyloNeighbor(node, length, id));
}