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;
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 openOutputFileAppend(string, ofstream&);
97 int openInputFile(string, ifstream&);
98 int openInputFile(string, ifstream&, string); //no error given
99 string getline(ifstream&);
100 string getline(istringstream&);
101 void gobble(istream&);
102 void gobble(istringstream&);
103 vector<string> splitWhiteSpace(string& rest, char[], int);
104 vector<string> splitWhiteSpace(string);
105 set<string> readAccnos(string);
106 int readAccnos(string, vector<string>&);
107 map<string, int> readNames(string);
108 map<string, int> readNames(string, unsigned long int&);
109 int readTax(string, map<string, string>&);
110 int readNames(string, map<string, string>&, map<string, int>&);
111 int readNames(string, map<string, string>&);
112 int readNames(string, map<string, string>&, bool);
113 int readNames(string, map<string, string>&, int);
114 int readNames(string, map<string, vector<string> >&);
115 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
116 int mothurRemove(string);
117 bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
118 bool mothurConvert(string, intDist&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
119 bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
120 bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
124 bool checkReleaseVersion(ifstream&, string);
125 bool anyLabelsToProcess(string, set<string>&, string);
126 bool inUsersGroups(vector<string>, vector<string>);
127 bool inUsersGroups(vector<int>, vector< vector<int> >);
128 bool inUsersGroups(string, vector<string>);
129 bool inUsersGroups(int, vector<int>);
130 void getNumSeqs(ifstream&, int&);
131 int getNumSeqs(ifstream&);
132 int getNumNames(string);
133 int getNumChar(string, char);
135 bool isContainingOnlyDigits(string);
136 bool isNumeric1(string);
139 //string manipulation
140 void splitAtEquals(string&, string&);
141 void splitAtComma(string&, string&);
142 void splitAtComma(string&, vector<string>&);
143 void splitAtDash(string&, set<int>&);
144 void splitAtDash(string&, set<string>&);
145 void splitAtDash(string&, vector<string>&);
146 void splitAtChar(string&, vector<string>&, char);
147 void splitAtChar(string&, string&, char);
148 vector<string> splitWhiteSpaceWithQuotes(string);
149 int removeConfidences(string&);
150 string removeQuotes(string);
151 string makeList(vector<string>&);
152 bool isSubset(vector<string>, vector<string>); //bigSet, subset
153 int checkName(string&);
156 int factorial(int num);
157 vector<vector<double> > binomial(int);
158 float ceilDist(float, int);
159 float roundDist(float, int);
160 unsigned int fromBase36(string);
161 int getRandomIndex(int); //highest
162 double getStandardDeviation(vector<int>&);
163 vector<double> getStandardDeviation(vector< vector<double> >&);
164 vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
165 vector<double> getAverages(vector< vector<double> >&);
166 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&);
167 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&, vector< vector<seqDist> >&);
168 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&, string);
169 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&);
172 bool executing, runParse, jumble, gui, mothurCalling, debug;
174 //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.
175 string getPhylipFile() { return phylipfile; }
176 string getColumnFile() { return columnfile; }
177 string getListFile() { return listfile; }
178 string getRabundFile() { return rabundfile; }
179 string getSabundFile() { return sabundfile; }
180 string getNameFile() { return namefile; }
181 string getGroupFile() { return groupfile; }
182 string getOrderFile() { return orderfile; }
183 string getOrderGroupFile() { return ordergroupfile; }
184 string getTreeFile() { return treefile; }
185 string getSharedFile() { return sharedfile; }
186 string getRelAbundFile() { return relabundfile; }
187 string getDesignFile() { return designfile; }
188 string getFastaFile() { return fastafile; }
189 string getSFFFile() { return sfffile; }
190 string getQualFile() { return qualfile; }
191 string getOligosFile() { return oligosfile; }
192 string getAccnosFile() { return accnosfile; }
193 string getTaxonomyFile() { return taxonomyfile; }
194 string getFlowFile() { return flowfile; }
195 string getBiomFile() { return biomfile; }
196 string getCountTableFile() { return counttablefile; }
197 string getSummaryFile() { return summaryfile; }
198 string getProcessors() { return processors; }
200 void setListFile(string f) { listfile = getFullPathName(f); }
201 void setTreeFile(string f) { treefile = getFullPathName(f); }
202 void setGroupFile(string f) { groupfile = getFullPathName(f); groupMode = "group"; }
203 void setPhylipFile(string f) { phylipfile = getFullPathName(f); }
204 void setColumnFile(string f) { columnfile = getFullPathName(f); }
205 void setNameFile(string f) { namefile = getFullPathName(f); }
206 void setRabundFile(string f) { rabundfile = getFullPathName(f); }
207 void setSabundFile(string f) { sabundfile = getFullPathName(f); }
208 void setSharedFile(string f) { sharedfile = getFullPathName(f); }
209 void setRelAbundFile(string f) { relabundfile = getFullPathName(f); }
210 void setOrderFile(string f) { orderfile = getFullPathName(f); }
211 void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); }
212 void setDesignFile(string f) { designfile = getFullPathName(f); }
213 void setFastaFile(string f) { fastafile = getFullPathName(f); }
214 void setSFFFile(string f) { sfffile = getFullPathName(f); }
215 void setQualFile(string f) { qualfile = getFullPathName(f); }
216 void setOligosFile(string f) { oligosfile = getFullPathName(f); }
217 void setAccnosFile(string f) { accnosfile = getFullPathName(f); }
218 void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); }
219 void setFlowFile(string f) { flowfile = getFullPathName(f); }
220 void setBiomFile(string f) { biomfile = getFullPathName(f); }
221 void setSummaryFile(string f) { summaryfile = getFullPathName(f); }
222 void setCountTableFile(string f) { counttablefile = getFullPathName(f); groupMode = "count"; }
223 void setProcessors(string p) { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n"); }
225 void printCurrentFiles();
226 bool hasCurrentFiles();
227 void clearCurrentFiles();
228 set<string> getCurrentTypes();
231 static MothurOut* _uniqueInstance;
232 MothurOut( const MothurOut& ); // Disable copy constructor
233 void operator=( const MothurOut& ); // Disable assignment operator
235 control_pressed = false; defaultPath="";
261 printedHeaders = false;
262 commandInputsConvertError = false;
263 mothurCalling = false;
265 sharedHeaderMode = "";
267 changedSeqNames = false;
272 string defaultPath, outputDir;
273 string releaseDate, version;
275 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
276 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile, counttablefile, summaryfile;
278 vector<string> Groups;
279 vector<string> namesOfGroups;
282 int mem_usage(double&, double&);
285 /***********************************************/