X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=treenode.cpp;fp=treenode.cpp;h=0131f59c340ef30eeeeb56ed2a96fc2dc258b808;hb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;hp=0000000000000000000000000000000000000000;hpb=1b73ff67c83892a025e597dabd9df6fe7b58206a;p=mothur.git diff --git a/treenode.cpp b/treenode.cpp new file mode 100644 index 0000000..0131f59 --- /dev/null +++ b/treenode.cpp @@ -0,0 +1,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 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 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::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); + } +} +/****************************************************************/