Next version of JABA
[jabaws.git] / binaries / src / clustalw / src / tree / UPGMA / Node.h
1 #ifndef _NODE_H
2 #define _NODE_H
3 #include <limits>
4 #include <vector>
5 #include <string>
6 #include "upgmadata.h"
7 namespace clustalw
8 {
9
10 using namespace std;
11
12 class Node 
13 {
14     public:
15     
16         Node(int seqNum, double *aptrToDistMatRow, int numDists);
17         double getDist(int index){return ptrToDistMatRow[index];}
18         void setDist(int index, double dist){ptrToDistMatRow[index] = dist;}
19         double* getPtrToDistMatRow(){return ptrToDistMatRow;}
20         void setDistMatRowToNull(){ptrToDistMatRow = 0;}
21         int getNumDists(){return numDists;}
22         double getMinDist(){return minDist;}
23         int getIndexToMinDist(){return indexToMinDist;}
24         void setMinDist(int index, double d){indexToMinDist = index; minDist = d;}
25         int getOrder(){return order;}
26         void setOrder(int o){order = o;}
27         int getSeqNum(){return seqNum;}
28         void setSeqNum(int sNum){seqNum = sNum;}
29         void printNodeInfo();
30         void printDistMatRow();
31         void printMinDist();
32         string elementsToString();        
33         Node* getLeft(){return left;}
34         Node* getRight(){return right;}
35         void setLeft(Node* l){left = l;}
36         void setRight(Node* r){right = r;}
37         double getHeight(){return height;}
38         void setHeight(double h){height = h;}
39         vector<int>* getPtrToElements(){return &allElements;}
40         int getFirstElement(){return allElements[0];}
41         void clearElements(){allElements.clear();}
42         int getFirstElem(){return allElements[0];}
43         bool isLeafNode()
44         {    
45             if(left == 0 && right == 0)
46             {
47                 return true;
48             }
49             else
50             {
51                 return false;
52             }
53         }
54         
55         void merge(Node **rightNode, double _height);
56         void findMinDist();
57         void printElements();      
58         void makeEmpty();
59         void makeEmpty(Node* t);
60         /* Attributes */ 
61         Node *next; // For linked list of nodes
62         Node *left, *right;
63         int size;
64         int seqNum;
65         double height;
66         vector<int> allElements; // THis is for the groups!!!   
67         double *ptrToDistMatRow; 
68         double minDist; // minimal distance
69         int indexToMinDist; // index of minimal distance
70         int numDists;
71         int order;
72 };
73
74 }
75
76 #endif