]> git.donarmstrong.com Git - mothur.git/blob - readtree.h
moved utilities out of mothur.h and into mothurOut class.
[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                 virtual ~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                 MothurOut* m;
37                 
38                 
39 };
40
41 /****************************************************************************/
42
43 class ReadNewickTree : public ReadTree {
44         
45 public:
46         ReadNewickTree(string file) : treeFile(file) { m->openInputFile(file, filehandle); readOk = 0; } 
47         ~ReadNewickTree() {};
48         int read();
49         
50 private:
51         Tree* T;
52         int readNewickInt(istream&, int&, Tree*);
53         int readTreeString();
54         void nexusTranslation();
55         ifstream filehandle;
56         string treeFile;
57         string holder;
58         int readOk;  // readOk = 0 means success, readOk = 1 means errors.
59         
60 };
61
62 /****************************************************************************/
63
64 #endif