]> git.donarmstrong.com Git - mothur.git/blob - mothurout.h
changed rarefaction.single output
[mothur.git] / mothurout.h
1 #ifndef MOTHUROUT_H
2 #define MOTHUROUT_H
3
4 /*
5  *  mothurOut.h
6  *  Mothur
7  *
8  *  Created by westcott on 2/25/10.
9  *  Copyright 2010 Schloss Lab. All rights reserved.
10  *
11  */
12
13 #include "mothur.h"
14
15 /***********************************************/
16
17 class MothurOut {
18         
19         public:
20                 static MothurOut* getInstance();
21                 void setFileName(string);
22                 
23                 void mothurOut(string); //writes to cout and the logfile
24                 void mothurOutEndLine(); //writes to cout and the logfile
25                 void mothurOut(string, ofstream&); //writes to the ofstream, cout and the logfile
26                 void mothurOutEndLine(ofstream&); //writes to the ofstream, cout and the logfile
27                 void mothurOutJustToLog(string);
28                 void errorOut(exception&, string, string);
29                 void closeLog();
30                 string getDefaultPath() { return defaultPath; }
31                 void setDefaultPath(string);
32                 string getOutputDir() { return outputDir; }
33                 void setOutputDir(string);
34                 
35                 string getReleaseDate() { return releaseDate; }
36                 void setReleaseDate(string r) { releaseDate = r; }
37                 string getVersion() { return version; }
38                 void setVersion(string r) { version = r; }
39         
40                 void addGroup(string g) { Groups.push_back(g); }
41                 void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
42                 void clearGroups() { Groups.clear(); }
43             int getNumGroups() { return Groups.size(); }
44                 vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
45                 void addAllGroup(string g) { namesOfGroups.push_back(g); }
46                 void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
47                 void clearAllGroups() { namesOfGroups.clear(); }
48                 int getNumAllGroups() { return namesOfGroups.size(); }
49         
50                 vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
51                 vector<string> Treenames;
52                 map<string, string> names;
53                 vector<string> binLabelsInFile;
54                 vector<string> currentBinLabels;
55                 string saveNextLabel, argv, sharedHeaderMode;
56                 bool printedHeaders;
57                 
58                 //functions from mothur.h
59                 //file operations
60                 vector<unsigned long long> divideFile(string, int&);
61                 int divideFile(string, int&, vector<string>&);
62                 vector<unsigned long long> setFilePosEachLine(string, int&);
63                 vector<unsigned long long> setFilePosFasta(string, int&);
64                 string sortFile(string, string);
65                 int appendFiles(string, string);
66                 int renameFile(string, string); //oldname, newname
67                 string getFullPathName(string);
68                 string hasPath(string);
69                 string getExtension(string);
70                 string getPathName(string);
71                 string getSimpleName(string);
72                 string getRootName(string);
73                 bool isBlank(string);
74                 int openOutputFile(string, ofstream&);
75                 int openOutputFileAppend(string, ofstream&);
76                 int openInputFile(string, ifstream&);
77                 int openInputFile(string, ifstream&, string); //no error given 
78                 string getline(ifstream&);
79                 string getline(istringstream&);
80                 void gobble(istream&);
81                 void gobble(istringstream&);
82                 map<string, int> readNames(string);
83                 int readNames(string, map<string, string>&);
84                 int readNames(string, map<string, vector<string> >&);
85                 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
86                 int mothurRemove(string);
87         
88                 
89                 //searchs and checks
90                 bool checkReleaseVersion(ifstream&, string);
91                 bool anyLabelsToProcess(string, set<string>&, string);
92                 bool inUsersGroups(vector<string>, vector<string>);
93                 bool inUsersGroups(string, vector<string>);
94                 void getNumSeqs(ifstream&, int&);
95                 int getNumSeqs(ifstream&);
96                 int getNumNames(string);
97                 int getNumChar(string, char);
98                 bool isTrue(string);
99                 bool isContainingOnlyDigits(string);
100         
101                 
102                 //string manipulation
103                 void splitAtEquals(string&, string&);
104                 void splitAtComma(string&, string&);    
105                 void splitAtComma(string&, vector<string>&);
106                 void splitAtDash(string&, set<int>&);
107                 void splitAtDash(string&, set<string>&);
108                 void splitAtDash(string&, vector<string>&);
109                 void splitAtChar(string&, vector<string>&, char);
110                 int removeConfidences(string&);
111                 
112                 //math operation
113                 int factorial(int num);
114                 vector<vector<double> > binomial(int);
115                 float ceilDist(float, int);
116                 float roundDist(float, int);
117                 unsigned int fromBase36(string);
118                 int getRandomIndex(int); //highest
119
120                 int control_pressed;
121                 bool executing, runParse, jumble, gui;
122                 
123                 //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles.
124                 string getPhylipFile()          { return phylipfile;            }
125                 string getColumnFile()          { return columnfile;            }
126                 string getListFile()            { return listfile;                      }
127                 string getRabundFile()          { return rabundfile;            }
128                 string getSabundFile()          { return sabundfile;            }
129                 string getNameFile()            { return namefile;                      }       
130                 string getGroupFile()           { return groupfile;                     }       
131                 string getOrderFile()           { return orderfile;                     }
132                 string getOrderGroupFile()      { return ordergroupfile;        }
133                 string getTreeFile()            { return treefile;                      }
134                 string getSharedFile()          { return sharedfile;            }
135                 string getRelAbundFile()        { return relabundfile;          }
136                 string getDesignFile()          { return designfile;            }
137                 string getFastaFile()           { return fastafile;                     }
138                 string getSFFFile()                     { return sfffile;                       }
139                 string getQualFile()            { return qualfile;                      }
140                 string getOligosFile()          { return oligosfile;            }
141                 string getAccnosFile()          { return accnosfile;            }
142                 string getTaxonomyFile()        { return taxonomyfile;          }
143                 string getFlowFile()            { return flowfile;                      }
144                 string getProcessors()          { return processors;            }
145                 
146                 void setListFile(string f)                      { listfile = getFullPathName(f);                        }
147                 void setTreeFile(string f)                      { treefile = getFullPathName(f);                        }
148                 void setGroupFile(string f)                     { groupfile = getFullPathName(f);                       }               
149                 void setPhylipFile(string f)            { phylipfile = getFullPathName(f);                      }
150                 void setColumnFile(string f)            { columnfile = getFullPathName(f);                      }
151                 void setNameFile(string f)                      { namefile = getFullPathName(f);                        }       
152                 void setRabundFile(string f)            { rabundfile = getFullPathName(f);                      }
153                 void setSabundFile(string f)            { sabundfile = getFullPathName(f);                      }
154                 void setSharedFile(string f)            { sharedfile = getFullPathName(f);                      }
155                 void setRelAbundFile(string f)          { relabundfile = getFullPathName(f);            }
156                 void setOrderFile(string f)                     { orderfile = getFullPathName(f);                       }
157                 void setOrderGroupFile(string f)        { ordergroupfile = getFullPathName(f);          }
158                 void setDesignFile(string f)            { designfile = getFullPathName(f);                      }
159                 void setFastaFile(string f)                     { fastafile = getFullPathName(f);                       }
160                 void setSFFFile(string f)                       { sfffile = getFullPathName(f);                         }
161                 void setQualFile(string f)                      { qualfile = getFullPathName(f);                        }
162                 void setOligosFile(string f)            { oligosfile = getFullPathName(f);                      }
163                 void setAccnosFile(string f)            { accnosfile = getFullPathName(f);                      }
164                 void setTaxonomyFile(string f)          { taxonomyfile = getFullPathName(f);            }
165                 void setFlowFile(string f)                      { flowfile = getFullPathName(f);                        }
166                 void setProcessors(string p)            { processors = p;                                                       }
167                 
168                 void printCurrentFiles();
169                 bool hasCurrentFiles();
170                 void clearCurrentFiles();
171                 
172         private:
173                 static MothurOut* _uniqueInstance;
174                 MothurOut( const MothurOut& ); // Disable copy constructor
175                 void operator=( const MothurOut& ); // Disable assignment operator
176                 MothurOut() { 
177                         control_pressed = false; defaultPath=""; 
178                         phylipfile = "";
179                         columnfile = "";
180                         listfile = "";
181                         rabundfile = "";
182                         sabundfile = "";
183                         namefile = "";
184                         groupfile = "";
185                         designfile = "";
186                         orderfile = "";
187                         treefile = "";
188                         sharedfile = "";
189                         ordergroupfile = "";
190                         relabundfile = "";
191                         fastafile = "";
192                         qualfile = "";
193                         sfffile = "";
194                         oligosfile = "";
195                         accnosfile = "";
196                         taxonomyfile = "";
197                         processors = "1";
198                         flowfile = "";
199                         gui = false;
200                         printedHeaders = false;
201                         sharedHeaderMode = "";
202                 }
203                 ~MothurOut();
204
205                 string logFileName;
206                 string defaultPath, outputDir;
207                 string releaseDate, version;
208         
209                 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile;
210                 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
211
212                 vector<string> Groups;
213                 vector<string> namesOfGroups;
214                 ofstream out;
215                 
216                 int mem_usage(double&, double&);
217
218 };
219 /***********************************************/
220
221 #endif
222