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