]> git.donarmstrong.com Git - mothur.git/blob - readtree.h
changed random forest output filename
[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 "tree.h"
14 #include "counttable.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(CountTable*) = 0;
29                 int readSpecialChar(istream&, char, string);
30                 int readNodeChar(istream& f);
31                 float readBranchLength(istream& f);
32         
33                 vector<Tree*> getTrees() { return Trees; }
34                 int AssembleTrees();
35                 
36         protected:
37                 vector<Tree*> Trees;
38                 CountTable* ct;
39                 int numNodes, numLeaves;
40                 MothurOut* m;
41                 
42                 
43 };
44
45 /****************************************************************************/
46
47 class ReadNewickTree : public ReadTree {
48         
49 public:
50         ReadNewickTree(string file) : treeFile(file) { m->openInputFile(file, filehandle); readOk = 0; } 
51         ~ReadNewickTree() {};
52         int read(CountTable*);
53         
54 private:
55         Tree* T;
56         int readNewickInt(istream&, int&, Tree*, CountTable*);
57         int readTreeString(CountTable*);
58         string nexusTranslation(CountTable*);
59         ifstream filehandle;
60         string treeFile;
61         string holder;
62         int readOk;  // readOk = 0 means success, readOk = 1 means errors.
63         
64 };
65
66 /****************************************************************************/
67
68 #endif