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 #include "utils.hpp" 16 17 #define MAX_LINE 513 18 #define SKIPLINE(f,c) {while((c=f.get())!=EOF && ((c) != '\n')){}} 19 20 class Tree; 21 22 /****************************************************************************/ 23 24 class ReadTree { 25 public: 26 ReadTree(); ~ReadTree()27 virtual ~ReadTree() {}; 28 29 virtual int read(CountTable*) = 0; 30 int readSpecialChar(istream&, char, string); 31 int readNodeChar(istream& f); 32 float readBranchLength(istream& f); 33 getTrees()34 vector<Tree*> getTrees() { return Trees; } 35 int AssembleTrees(); 36 37 protected: 38 vector<Tree*> Trees; 39 CountTable* ct; 40 int numNodes, numLeaves; 41 MothurOut* m; 42 Utils util; 43 44 45 }; 46 47 /****************************************************************************/ 48 49 class ReadNewickTree : public ReadTree { 50 51 public: ReadNewickTree(string file,vector<string> T)52 ReadNewickTree(string file, vector<string> T) : treeFile(file), Treenames(T) { Utils util; util.openInputFile(file, filehandle); readOk = 0; if (Treenames.size() == 0) { Treenames = util.parseTreeFile(treeFile); } } ~ReadNewickTree()53 ~ReadNewickTree() {}; 54 int read(CountTable*); 55 56 private: 57 Tree* T; 58 int readNewickInt(istream&, int&, Tree*, CountTable*); 59 int readTreeString(CountTable*); 60 string nexusTranslation(CountTable*); 61 ifstream filehandle; 62 string treeFile; 63 string holder; 64 int readOk; // readOk = 0 means success, readOk = 1 means errors. 65 vector<string> Treenames; 66 67 }; 68 69 /****************************************************************************/ 70 71 #endif 72