8 * Created by westcott on 2/25/10.
9 * Copyright 2010 Schloss Lab. All rights reserved.
15 /***********************************************/
22 logger& operator <<( const T& o ) {
23 cout << o; return *this;
26 logger& operator<<(ostream& (*m)(ostream&) ) {
27 cout << m; return *this;
31 /***********************************************/
36 static MothurOut* getInstance();
37 void setFileName(string);
39 void mothurOut(string); //writes to cout and the logfile
40 void mothurOutEndLine(); //writes to cout and the logfile
41 void mothurOut(string, ofstream&); //writes to the ofstream, cout and the logfile
42 void mothurOutEndLine(ofstream&); //writes to the ofstream, cout and the logfile
43 void mothurOutJustToScreen(string); //writes to cout
44 void mothurOutJustToLog(string);
45 void errorOut(exception&, string, string);
47 string getDefaultPath() { return defaultPath; }
48 void setDefaultPath(string);
49 string getOutputDir() { return outputDir; }
50 void setOutputDir(string);
52 string getReleaseDate() { return releaseDate; }
53 void setReleaseDate(string r) { releaseDate = r; }
54 string getVersion() { return version; }
55 void setVersion(string r) { version = r; }
57 void addGroup(string g) { Groups.push_back(g); }
58 void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
59 void clearGroups() { Groups.clear(); }
60 int getNumGroups() { return Groups.size(); }
61 vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
62 void addAllGroup(string g) { namesOfGroups.push_back(g); }
63 void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
64 void clearAllGroups() { namesOfGroups.clear(); }
65 int getNumAllGroups() { return namesOfGroups.size(); }
67 vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
68 vector<string> Treenames;
69 //map<string, string> names;
70 vector<string> binLabelsInFile;
71 vector<string> currentBinLabels;
72 string saveNextLabel, argv, sharedHeaderMode, groupMode;
73 bool printedHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
75 //functions from mothur.h
77 bool dirCheck(string&); //completes path, appends appropriate / or \, makes sure dir is writable.
78 vector<unsigned long long> divideFile(string, int&); //divides splitting unevenness by sequence
79 vector<unsigned long long> divideFilePerLine(string, int&); //divides splitting unevenness at line breaks
80 int divideFile(string, int&, vector<string>&);
81 vector<unsigned long long> setFilePosEachLine(string, int&);
82 vector<unsigned long long> setFilePosFasta(string, int&);
83 string sortFile(string, string);
84 int appendFiles(string, string);
85 int appendFilesWithoutHeaders(string, string);
86 int renameFile(string, string); //oldname, newname
87 string getFullPathName(string);
88 string findProgramPath(string programName);
89 string hasPath(string);
90 string getExtension(string);
91 string getPathName(string);
92 string getSimpleName(string);
93 string getRootName(string);
95 int openOutputFile(string, ofstream&);
96 int openOutputFileBinary(string, ofstream&);
97 int openOutputFileAppend(string, ofstream&);
98 int openOutputFileBinaryAppend(string, ofstream&);
99 int openInputFile(string, ifstream&);
100 int openInputFile(string, ifstream&, string); //no error given
101 string getline(ifstream&);
102 string getline(istringstream&);
103 void gobble(istream&);
104 void gobble(istringstream&);
105 vector<string> splitWhiteSpace(string& rest, char[], int);
106 vector<string> splitWhiteSpace(string);
107 set<string> readAccnos(string);
108 int readAccnos(string, vector<string>&);
109 map<string, int> readNames(string);
110 map<string, int> readNames(string, unsigned long int&);
111 int readTax(string, map<string, string>&);
112 vector<consTax> readConsTax(string);
113 int readConsTax(string, map<string, consTax2>&);
114 int readNames(string, map<string, string>&, map<string, int>&);
115 int readNames(string, map<string, string>&);
116 int readNames(string, map<string, string>&, bool);
117 int readNames(string, map<string, string>&, int);
118 int readNames(string, map<string, vector<string> >&);
119 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
120 int mothurRemove(string);
121 bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
122 bool mothurConvert(string, intDist&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
123 bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
124 bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
128 bool checkReleaseVersion(ifstream&, string);
129 bool anyLabelsToProcess(string, set<string>&, string);
130 bool inUsersGroups(vector<string>, vector<string>);
131 bool inUsersGroups(vector<int>, vector< vector<int> >);
132 bool inUsersGroups(string, vector<string>);
133 bool inUsersGroups(int, vector<int>);
134 void getNumSeqs(ifstream&, int&);
135 int getNumSeqs(ifstream&);
136 int getNumNames(string);
137 int getNumChar(string, char);
139 bool isContainingOnlyDigits(string);
140 bool isNumeric1(string);
141 string findEdianness();
144 //string manipulation
145 void splitAtEquals(string&, string&);
146 void splitAtComma(string&, string&);
147 void splitAtComma(string&, vector<string>&);
148 void splitAtDash(string&, set<int>&);
149 void splitAtDash(string&, set<string>&);
150 void splitAtDash(string&, vector<string>&);
151 void splitAtChar(string&, vector<string>&, char);
152 void splitAtChar(string&, string&, char);
153 vector<string> splitWhiteSpaceWithQuotes(string);
154 int removeConfidences(string&);
155 string removeQuotes(string);
156 string makeList(vector<string>&);
157 bool isSubset(vector<string>, vector<string>); //bigSet, subset
158 int checkName(string&);
159 map<string, vector<string> > parseClasses(string);
162 double max(vector<double>&); //returns largest value in vector
163 double min(vector<double>&); //returns smallest value in vector
164 int factorial(int num);
165 vector<vector<double> > binomial(int);
166 float ceilDist(float, int);
167 float roundDist(float, int);
168 unsigned int fromBase36(string);
169 double median(vector<double>);
170 int getRandomIndex(int); //highest
171 double getStandardDeviation(vector<int>&);
172 vector<double> getStandardDeviation(vector< vector<double> >&);
173 vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
174 vector<double> getAverages(vector< vector<double> >&);
175 double getAverage(vector<double>);
176 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&);
177 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&, vector< vector<seqDist> >&);
178 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&, string);
179 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&);
182 bool executing, runParse, jumble, gui, mothurCalling, debug;
184 //current files - if you add a new type you must edit optionParser->getParameters, get.current and set.current commands and mothurOut->printCurrentFiles/clearCurrentFiles/getCurrentTypes. add a get and set function.
185 string getPhylipFile() { return phylipfile; }
186 string getColumnFile() { return columnfile; }
187 string getListFile() { return listfile; }
188 string getRabundFile() { return rabundfile; }
189 string getSabundFile() { return sabundfile; }
190 string getNameFile() { return namefile; }
191 string getGroupFile() { return groupfile; }
192 string getOrderFile() { return orderfile; }
193 string getOrderGroupFile() { return ordergroupfile; }
194 string getTreeFile() { return treefile; }
195 string getSharedFile() { return sharedfile; }
196 string getRelAbundFile() { return relabundfile; }
197 string getDesignFile() { return designfile; }
198 string getFastaFile() { return fastafile; }
199 string getSFFFile() { return sfffile; }
200 string getQualFile() { return qualfile; }
201 string getOligosFile() { return oligosfile; }
202 string getAccnosFile() { return accnosfile; }
203 string getTaxonomyFile() { return taxonomyfile; }
204 string getFlowFile() { return flowfile; }
205 string getBiomFile() { return biomfile; }
206 string getCountTableFile() { return counttablefile; }
207 string getSummaryFile() { return summaryfile; }
208 string getProcessors() { return processors; }
210 void setListFile(string f) { listfile = getFullPathName(f); }
211 void setTreeFile(string f) { treefile = getFullPathName(f); }
212 void setGroupFile(string f) { groupfile = getFullPathName(f); groupMode = "group"; }
213 void setPhylipFile(string f) { phylipfile = getFullPathName(f); }
214 void setColumnFile(string f) { columnfile = getFullPathName(f); }
215 void setNameFile(string f) { namefile = getFullPathName(f); }
216 void setRabundFile(string f) { rabundfile = getFullPathName(f); }
217 void setSabundFile(string f) { sabundfile = getFullPathName(f); }
218 void setSharedFile(string f) { sharedfile = getFullPathName(f); }
219 void setRelAbundFile(string f) { relabundfile = getFullPathName(f); }
220 void setOrderFile(string f) { orderfile = getFullPathName(f); }
221 void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); }
222 void setDesignFile(string f) { designfile = getFullPathName(f); }
223 void setFastaFile(string f) { fastafile = getFullPathName(f); }
224 void setSFFFile(string f) { sfffile = getFullPathName(f); }
225 void setQualFile(string f) { qualfile = getFullPathName(f); }
226 void setOligosFile(string f) { oligosfile = getFullPathName(f); }
227 void setAccnosFile(string f) { accnosfile = getFullPathName(f); }
228 void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); }
229 void setFlowFile(string f) { flowfile = getFullPathName(f); }
230 void setBiomFile(string f) { biomfile = getFullPathName(f); }
231 void setSummaryFile(string f) { summaryfile = getFullPathName(f); }
232 void setCountTableFile(string f) { counttablefile = getFullPathName(f); groupMode = "count"; }
233 void setProcessors(string p) { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n"); }
235 void printCurrentFiles();
236 bool hasCurrentFiles();
237 void clearCurrentFiles();
238 set<string> getCurrentTypes();
241 static MothurOut* _uniqueInstance;
242 MothurOut( const MothurOut& ); // Disable copy constructor
243 void operator=( const MothurOut& ); // Disable assignment operator
245 control_pressed = false; defaultPath="";
271 printedHeaders = false;
272 commandInputsConvertError = false;
273 mothurCalling = false;
275 sharedHeaderMode = "";
277 changedSeqNames = false;
283 string defaultPath, outputDir;
284 string releaseDate, version;
286 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
287 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile, counttablefile, summaryfile;
289 vector<string> Groups;
290 vector<string> namesOfGroups;
293 int mem_usage(double&, double&);
296 /***********************************************/