]> git.donarmstrong.com Git - mothur.git/blob - readtree.h
adding treeclimber and unifrac pieces
[mothur.git] / readtree.h
1 #ifndef READTREE_H
2 #define READTREE_H
3 /*
4  *  readtree.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 1/22/09.
8  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11
12 using namespace std;
13
14 #include <string>
15 #include <iostream>
16 #include "globaldata.hpp"
17 #include "tree.h"
18
19 #define MAX_LINE                513
20 #define SKIPLINE(f,c)   {while((c=f.get())!=EOF && ((c) != '\n')){}}
21
22 class Tree;
23
24 /****************************************************************************/
25
26 class ReadTree {
27         public:
28                 ReadTree(); 
29                 ~ReadTree() {};
30                 
31                 virtual void read() {};
32                 int readSpecialChar(istream&, char, string);
33                 int readNodeChar(istream& f);
34                 float readBranchLength(istream& f);
35                 
36         protected:
37                 GlobalData* globaldata;
38                 int numNodes, numLeaves;
39                 
40 };
41
42 /****************************************************************************/
43
44 class ReadNewickTree : public ReadTree {
45         
46 public:
47         ReadNewickTree(string file) : treeFile(file) { openInputFile(file, filehandle);  } 
48         ~ReadNewickTree() {};
49         void read();
50         
51 private:
52         Tree* T;
53         int readNewickInt(istream&, int&, Tree*);
54         void readTreeString();
55         void nexusTranslation();
56         ifstream filehandle;
57         string treeFile;
58         string holder;
59 };
60
61 /****************************************************************************/
62
63 #endif