]> git.donarmstrong.com Git - mothur.git/blob - fileoutput.h
merged pat's trim seqs edits with sarah's major overhaul of global data; also added...
[mothur.git] / fileoutput.h
1 #ifndef FILEOUTPUT_H
2 #define FILEOUTPUT_H
3
4 #include "mothur.h"
5
6 /***********************************************************************/
7
8 class FileOutput {
9         
10 public:
11         FileOutput(){};
12         ~FileOutput(){};
13         
14         virtual void initFile(string) = 0;
15         virtual void initFile(string, vector<string>) = 0;
16         virtual void output(int, vector<double>) = 0;
17         virtual void output(vector<double>) = 0;
18         virtual void resetFile() = 0;
19         virtual string getFileName() = 0;
20
21 protected:
22         int renameOk;
23
24 };      
25         
26 /***********************************************************************/
27
28 class ThreeColumnFile : public FileOutput {
29         
30 public:
31         ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp") { };
32         ~ThreeColumnFile();
33         void initFile(string);
34         void output(int, vector<double>);
35         void resetFile();
36         string getFileName()    { return inName;        };
37         
38         void initFile(string, vector<string>){};
39         void output(vector<double>) {};
40
41 private:
42         string inName;
43         string outName;
44         ifstream inFile;
45         ofstream outFile;
46         int counter;
47 };
48
49
50 /***********************************************************************/
51 class OneColumnFile : public FileOutput {
52         
53         
54 public:
55         OneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
56         ~OneColumnFile();
57         void output(int, vector<double>);
58         void initFile(string);
59         void resetFile();
60         string getFileName()    { return inName;        };
61         
62         void initFile(string, vector<string>) {};
63         void output(vector<double>) {};
64
65
66 private:
67         string outName;
68         ifstream inFile;
69         string inName;
70         ofstream outFile;
71         int counter;
72 };
73
74 /***********************************************************************/
75 class SharedOneColumnFile : public FileOutput {
76         
77         
78 public:
79         SharedOneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
80         ~SharedOneColumnFile();
81         void output(int, vector<double>);
82         void initFile(string);
83         void resetFile();
84         string getFileName()    { return inName;        };
85         
86         void initFile(string, vector<string>) {};
87         void output(vector<double>) {};
88
89
90 private:
91         string outName;
92         ifstream inFile;
93         string inName;
94         ofstream outFile;
95         int counter;
96                 
97 };
98
99 /***********************************************************************/
100
101 class SharedThreeColumnFile : public FileOutput {
102         
103 public:
104         SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(getPathName(n) + ".temp") {      };
105         ~SharedThreeColumnFile();
106         void initFile(string);
107         void output(int, vector<double>);
108         void resetFile();
109         string getFileName()    { return inName;        };
110         
111         
112         void initFile(string, vector<string>) {};
113         void output(vector<double>) {};
114
115 private:
116         string inName, groupLabel;
117         string outName;
118         ifstream inFile;
119         ofstream outFile;
120         int counter, numGroup;
121 };
122
123 /***********************************************************************/
124 //used by parsimony, unifrac.weighted and unifrac.unweighted
125 class ColumnFile : public FileOutput {
126         
127 public:
128         ColumnFile(string n, string i) : FileOutput(), iters(i), inName(n), counter(0), outName(getPathName(n) + ".temp") {};
129         ~ColumnFile();
130         
131         //to make compatible with parent class
132         void output(int, vector<double>){};
133         void initFile(string){};
134         
135         void initFile(string, vector<string>);
136         void output(vector<double>);
137         void resetFile();
138         string getFileName()    { return inName;        };
139 private:
140         string inName;
141         string outName;
142         ifstream inFile;
143         ofstream outFile;
144         int counter;
145         string iters;
146 };
147
148 /***********************************************************************/
149
150 #endif