]> git.donarmstrong.com Git - mothur.git/blob - readtree.h
started shared utilities, updates to venn and heatmap added tree.groups command
[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 "mothur.h"
15 #include "globaldata.hpp"
16 #include "tree.h"
17
18 #define MAX_LINE                513
19 #define SKIPLINE(f,c)   {while((c=f.get())!=EOF && ((c) != '\n')){}}
20
21 class Tree;
22
23 /****************************************************************************/
24
25 class ReadTree {
26         public:
27                 ReadTree(); 
28                 ~ReadTree() {};
29                 
30                 virtual int read() = 0;
31                 int readSpecialChar(istream&, char, string);
32                 int readNodeChar(istream& f);
33                 float readBranchLength(istream& f);
34                 
35         protected:
36                 GlobalData* globaldata;
37                 int numNodes, numLeaves;
38                 
39                 
40 };
41
42 /****************************************************************************/
43
44 class ReadNewickTree : public ReadTree {
45         
46 public:
47         ReadNewickTree(string file) : treeFile(file) { openInputFile(file, filehandle); readOk = 0; } 
48         ~ReadNewickTree() {};
49         int read();
50         
51 private:
52         Tree* T;
53         int readNewickInt(istream&, int&, Tree*);
54         int readTreeString();
55         void nexusTranslation();
56         ifstream filehandle;
57         string treeFile;
58         string holder;
59         int readOk;  // readOk = 0 means success, readOk = 1 means errors.
60         
61 };
62
63 /****************************************************************************/
64
65 #endif