File: readtree.h

package info (click to toggle)
mothur 1.48.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 13,684 kB
  • sloc: cpp: 161,854; makefile: 122; sh: 31
file content (71 lines) | stat: -rwxr-xr-x 1,688 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef READTREE_H
#define READTREE_H
/*
 *  readtree.h
 *  Mothur
 *
 *  Created by Sarah Westcott on 1/22/09.
 *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
 *
 */

#include "mothur.h"
#include "tree.h"
#include "counttable.h"
#include "utils.hpp"

#define MAX_LINE		513
#define SKIPLINE(f,c)	{while((c=f.get())!=EOF && ((c) != '\n')){}}

class Tree;

/****************************************************************************/

class ReadTree {
	public:
		ReadTree(); 
		virtual ~ReadTree() = default;;
		
		virtual int read(CountTable*) = 0;
		int readSpecialChar(istream&, char, string);
		int readNodeChar(istream& f);
		float readBranchLength(istream& f);
	
		vector<Tree*> getTrees() { return Trees; }
		int AssembleTrees();
		
	protected:
		vector<Tree*> Trees;
		CountTable* ct;
		int numNodes, numLeaves;
		MothurOut* m;
        Utils util;
		
		
};

/****************************************************************************/

class ReadNewickTree : public ReadTree {
	
public:
    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() = default;;
	int read(CountTable*);
	
private:
	Tree* T;
	int readNewickInt(istream&, int&, Tree*, CountTable*);
	int readTreeString(CountTable*);
	string nexusTranslation(CountTable*);
	ifstream filehandle;
	string treeFile;
	string holder;
	int readOk;  // readOk = 0 means success, readOk = 1 means errors.
    vector<string> Treenames;
	
};

/****************************************************************************/

#endif