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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
/*
* treenode.cpp
* Mothur
*
* Created by Sarah Westcott on 1/23/09.
* Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "treenode.h"
/****************************************************************/
Node::Node() {
m = MothurOut::getInstance();
//initialize node
name = "";
branchLength = -1;
parent = -1;
lchild = -1;
rchild = -1;
length2leaf = 0.0;
label = -1;
}
/****************************************************************/
void Node::setName(string Name) { name = Name; }
/****************************************************************/
void Node::setGroup(vector<string> groups) { group =groups; }
/****************************************************************/
void Node::setBranchLength(float l) { branchLength = l; }
/****************************************************************/
void Node::setLabel(float l) { label = l; }
/****************************************************************/
void Node::setLengthToLeaves(float l) { length2leaf = l; }
/****************************************************************/
void Node::setParent(int p) { parent = p; }
/****************************************************************/
void Node::setIndex(int i) { vectorIndex = i; }
/****************************************************************/
void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; } //leftchild, rightchild
/****************************************************************/
string Node::getName() { return name; }
/****************************************************************/
vector<string> Node::getGroup() { return group; }
/****************************************************************/
float Node::getBranchLength() { return branchLength; }
/****************************************************************/
float Node::getLabel() { return label; }
/****************************************************************/
float Node::getLengthToLeaves() { return length2leaf; }
/****************************************************************/
int Node::getParent() { return parent; }
/****************************************************************/
int Node::getLChild() { return lchild; }
/****************************************************************/
int Node::getRChild() { return rchild; }
/****************************************************************/
int Node::getIndex() { return vectorIndex; }
/****************************************************************/
//to be used by printTree in the Tree class to print the leaf info
void Node::printNode() {
try{
m->mothurOut(name + " " + toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
/*for (int i = 0; i < group.size(); i++) { m->mothurOut( group[i] + " "); }
//there is a branch length
if (branchLength != -1) {
m->mothurOut(" " + toString(branchLength));
}
m->mothurOut(" |");
map<string, int>::iterator it;
for(it=pGroups.begin();it!=pGroups.end();it++){
m->mothurOut(" " + it->first + ":" + toString(it->second));
}
m->mothurOut(" |");
for(it=pcount.begin();it!=pcount.end();it++){
m->mothurOut(" " + it->first + ":" + toString(it->second));
}*/
m->mothurOutEndLine();
}
catch(exception& e) {
m->errorOut(e, "Node", "printNode");
exit(1);
}
}
/****************************************************************/
|