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> sharedBinLabelsInFile;
71 vector<string> currentSharedBinLabels;
72 vector<string> listBinLabelsInFile;
73 //vector<string> currentListBinLabels;
74 string saveNextLabel, argv, sharedHeaderMode, groupMode;
75 bool printedSharedHeaders, printedListHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
77 //functions from mothur.h
79 bool dirCheck(string&); //completes path, appends appropriate / or \, makes sure dir is writable.
80 vector<unsigned long long> divideFile(string, int&); //divides splitting unevenness by sequence
81 vector<unsigned long long> divideFilePerLine(string, int&); //divides splitting unevenness at line breaks
82 int divideFile(string, int&, vector<string>&);
83 vector<unsigned long long> setFilePosEachLine(string, int&);
84 vector<unsigned long long> setFilePosFasta(string, int&);
85 string sortFile(string, string);
86 int appendFiles(string, string);
87 int appendFilesWithoutHeaders(string, string);
88 int renameFile(string, string); //oldname, newname
89 string getFullPathName(string);
90 string findProgramPath(string programName);
91 string hasPath(string);
92 string getExtension(string);
93 string getPathName(string);
94 string getSimpleName(string);
95 string getRootName(string);
97 int openOutputFile(string, ofstream&);
98 int openOutputFileBinary(string, ofstream&);
99 int openOutputFileAppend(string, ofstream&);
100 int openOutputFileBinaryAppend(string, ofstream&);
101 int openInputFile(string, ifstream&);
102 int openInputFile(string, ifstream&, string); //no error given
103 string getline(ifstream&);
104 string getline(istringstream&);
105 void gobble(istream&);
106 void gobble(istringstream&);
107 vector<string> splitWhiteSpace(string& rest, char[], int);
108 vector<string> splitWhiteSpace(string);
109 set<string> readAccnos(string);
110 int readAccnos(string, vector<string>&);
111 map<string, int> readNames(string);
112 map<string, int> readNames(string, unsigned long int&);
113 int readTax(string, map<string, string>&);
114 vector<consTax> readConsTax(string);
115 int readConsTax(string, map<string, consTax2>&);
116 int readNames(string, map<string, string>&, map<string, int>&);
117 int readNames(string, map<string, string>&);
118 int readNames(string, map<string, string>&, bool);
119 int readNames(string, map<string, string>&, int);
120 int readNames(string, map<string, vector<string> >&);
121 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
122 int mothurRemove(string);
123 bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
124 bool mothurConvert(string, intDist&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
125 bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
126 bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
130 bool checkReleaseVersion(ifstream&, string);
131 bool anyLabelsToProcess(string, set<string>&, string);
132 bool inUsersGroups(vector<string>, vector<string>);
133 bool inUsersGroups(vector<int>, vector< vector<int> >);
134 bool inUsersGroups(string, vector<string>);
135 bool inUsersGroups(int, vector<int>);
136 void getNumSeqs(ifstream&, int&);
137 int getNumSeqs(ifstream&);
138 int getNumNames(string);
139 int getNumChar(string, char);
141 bool isContainingOnlyDigits(string);
142 bool isNumeric1(string);
143 bool isLabelEquivalent(string, string);
144 string getSimpleLabel(string);
145 string findEdianness();
148 //string manipulation
149 void splitAtEquals(string&, string&);
150 void splitAtComma(string&, string&);
151 void splitAtComma(string&, vector<string>&);
152 void splitAtDash(string&, set<int>&);
153 void splitAtDash(string&, set<string>&);
154 void splitAtDash(string&, vector<string>&);
155 void splitAtChar(string&, vector<string>&, char);
156 void splitAtChar(string&, string&, char);
157 vector<string> splitWhiteSpaceWithQuotes(string);
158 int removeConfidences(string&);
159 string removeQuotes(string);
160 string makeList(vector<string>&);
161 bool isSubset(vector<string>, vector<string>); //bigSet, subset
162 int checkName(string&);
163 map<string, vector<string> > parseClasses(string);
166 double max(vector<double>&); //returns largest value in vector
167 double min(vector<double>&); //returns smallest value in vector
168 int factorial(int num);
169 vector<vector<double> > binomial(int);
170 float ceilDist(float, int);
171 float roundDist(float, int);
172 unsigned int fromBase36(string);
173 double median(vector<double>);
174 int getRandomIndex(int); //highest
175 double getStandardDeviation(vector<int>&);
176 vector<double> getStandardDeviation(vector< vector<double> >&);
177 vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
178 vector<double> getAverages(vector< vector<double> >&);
179 double getAverage(vector<double>);
180 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&);
181 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&, vector< vector<seqDist> >&);
182 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&, string);
183 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&);
186 bool executing, runParse, jumble, gui, mothurCalling, debug;
188 //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.
189 string getPhylipFile() { return phylipfile; }
190 string getColumnFile() { return columnfile; }
191 string getListFile() { return listfile; }
192 string getRabundFile() { return rabundfile; }
193 string getSabundFile() { return sabundfile; }
194 string getNameFile() { return namefile; }
195 string getGroupFile() { return groupfile; }
196 string getOrderFile() { return orderfile; }
197 string getOrderGroupFile() { return ordergroupfile; }
198 string getTreeFile() { return treefile; }
199 string getSharedFile() { return sharedfile; }
200 string getRelAbundFile() { return relabundfile; }
201 string getDesignFile() { return designfile; }
202 string getFastaFile() { return fastafile; }
203 string getSFFFile() { return sfffile; }
204 string getQualFile() { return qualfile; }
205 string getOligosFile() { return oligosfile; }
206 string getAccnosFile() { return accnosfile; }
207 string getTaxonomyFile() { return taxonomyfile; }
208 string getFlowFile() { return flowfile; }
209 string getBiomFile() { return biomfile; }
210 string getCountTableFile() { return counttablefile; }
211 string getSummaryFile() { return summaryfile; }
212 string getProcessors() { return processors; }
214 void setListFile(string f) { listfile = getFullPathName(f); }
215 void setTreeFile(string f) { treefile = getFullPathName(f); }
216 void setGroupFile(string f) { groupfile = getFullPathName(f); groupMode = "group"; }
217 void setPhylipFile(string f) { phylipfile = getFullPathName(f); }
218 void setColumnFile(string f) { columnfile = getFullPathName(f); }
219 void setNameFile(string f) { namefile = getFullPathName(f); }
220 void setRabundFile(string f) { rabundfile = getFullPathName(f); }
221 void setSabundFile(string f) { sabundfile = getFullPathName(f); }
222 void setSharedFile(string f) { sharedfile = getFullPathName(f); }
223 void setRelAbundFile(string f) { relabundfile = getFullPathName(f); }
224 void setOrderFile(string f) { orderfile = getFullPathName(f); }
225 void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); }
226 void setDesignFile(string f) { designfile = getFullPathName(f); }
227 void setFastaFile(string f) { fastafile = getFullPathName(f); }
228 void setSFFFile(string f) { sfffile = getFullPathName(f); }
229 void setQualFile(string f) { qualfile = getFullPathName(f); }
230 void setOligosFile(string f) { oligosfile = getFullPathName(f); }
231 void setAccnosFile(string f) { accnosfile = getFullPathName(f); }
232 void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); }
233 void setFlowFile(string f) { flowfile = getFullPathName(f); }
234 void setBiomFile(string f) { biomfile = getFullPathName(f); }
235 void setSummaryFile(string f) { summaryfile = getFullPathName(f); }
236 void setCountTableFile(string f) { counttablefile = getFullPathName(f); groupMode = "count"; }
237 void setProcessors(string p) { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n"); }
239 void printCurrentFiles();
240 bool hasCurrentFiles();
241 void clearCurrentFiles();
242 set<string> getCurrentTypes();
245 static MothurOut* _uniqueInstance;
246 MothurOut( const MothurOut& ); // Disable copy constructor
247 void operator=( const MothurOut& ); // Disable assignment operator
249 control_pressed = false; defaultPath="";
275 printedSharedHeaders = false;
276 printedListHeaders = false;
277 commandInputsConvertError = false;
278 mothurCalling = false;
280 sharedHeaderMode = "";
282 changedSeqNames = false;
288 string defaultPath, outputDir;
289 string releaseDate, version;
291 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
292 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile, counttablefile, summaryfile;
294 vector<string> Groups;
295 vector<string> namesOfGroups;
298 int mem_usage(double&, double&);
301 /***********************************************/