]> git.donarmstrong.com Git - mothur.git/blob - treenode.cpp
When Pat tried to compile mothur in Ubuntu linux, there were a number of minor proble...
[mothur.git] / treenode.cpp
1 /*
2  *  treenode.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/23/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "treenode.h"
11
12
13 /****************************************************************/      
14 Node::Node() {
15         //initialize node
16         name = "";
17         branchLength = -1;
18         parent = -1;
19         lchild = -1;
20         rchild = -1;
21         
22 }
23 /****************************************************************/
24 void Node::setName(string Name) {  name = Name; }
25 /****************************************************************/
26 //non leaf nodes will belong to multiple groups, leaf nodes will only belong to one.
27 void Node::setGroup(string groups)  { group.push_back(groups); }
28 /****************************************************************/
29 void Node::setBranchLength(float l) { branchLength = l; }
30 /****************************************************************/
31 void Node::setParent(int p)  { parent = p; }
32 /****************************************************************/
33 void Node::setIndex(int i)  { vectorIndex = i; }
34 /****************************************************************/
35 void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; }    //leftchild, rightchild
36 /****************************************************************/
37 string Node::getName() { return name; }
38 /****************************************************************/
39 vector<string> Node::getGroup() { return group; }
40 /****************************************************************/
41 float Node::getBranchLength() { return branchLength; }
42 /****************************************************************/
43 int Node::getParent() { return parent; }
44 /****************************************************************/
45 int Node::getLChild() { return lchild; }
46 /****************************************************************/
47 int Node::getRChild() { return rchild; }
48 /****************************************************************/
49 int Node::getIndex() { return vectorIndex; }
50 /****************************************************************/
51 //to be used by printTree in the Tree class to print the leaf info                      
52 void Node::printNode(ostream& out) {
53         try{
54                 out << name;
55                 
56                 //there is a branch length
57                 if (branchLength != -1) { 
58                         out << ":" << setprecision(4) << branchLength; 
59                 }
60                 
61         }
62         catch(exception& e) {
63                 cout << "Standard Error: " << e.what() << " has occurred in the Node class Function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
64                 exit(1);
65         }
66         catch(...) {
67                 cout << "An unknown error has occurred in the Node class function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
68                 exit(1);
69         }               
70 }
71 /****************************************************************/