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