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 mothurOutJustToLog(string);
44 void errorOut(exception&, string, string);
46 string getDefaultPath() { return defaultPath; }
47 void setDefaultPath(string);
48 string getOutputDir() { return outputDir; }
49 void setOutputDir(string);
51 string getReleaseDate() { return releaseDate; }
52 void setReleaseDate(string r) { releaseDate = r; }
53 string getVersion() { return version; }
54 void setVersion(string r) { version = r; }
56 void addGroup(string g) { Groups.push_back(g); }
57 void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
58 void clearGroups() { Groups.clear(); }
59 int getNumGroups() { return Groups.size(); }
60 vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
61 void addAllGroup(string g) { namesOfGroups.push_back(g); }
62 void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
63 void clearAllGroups() { namesOfGroups.clear(); }
64 int getNumAllGroups() { return namesOfGroups.size(); }
66 vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
67 vector<string> Treenames;
68 //map<string, string> names;
69 vector<string> binLabelsInFile;
70 vector<string> currentBinLabels;
71 string saveNextLabel, argv, sharedHeaderMode, groupMode;
72 bool printedHeaders, commandInputsConvertError, changedSeqNames;
74 //functions from mothur.h
76 bool dirCheck(string&); //completes path, appends appropriate / or \, makes sure dir is writable.
77 vector<unsigned long long> divideFile(string, int&); //divides splitting unevenness by sequence
78 vector<unsigned long long> divideFilePerLine(string, int&); //divides splitting unevenness at line breaks
79 int divideFile(string, int&, vector<string>&);
80 vector<unsigned long long> setFilePosEachLine(string, int&);
81 vector<unsigned long long> setFilePosFasta(string, int&);
82 string sortFile(string, string);
83 int appendFiles(string, string);
84 int renameFile(string, string); //oldname, newname
85 string getFullPathName(string);
86 string findProgramPath(string programName);
87 string hasPath(string);
88 string getExtension(string);
89 string getPathName(string);
90 string getSimpleName(string);
91 string getRootName(string);
93 int openOutputFile(string, ofstream&);
94 int openOutputFileAppend(string, ofstream&);
95 int openInputFile(string, ifstream&);
96 int openInputFile(string, ifstream&, string); //no error given
97 string getline(ifstream&);
98 string getline(istringstream&);
99 void gobble(istream&);
100 void gobble(istringstream&);
101 vector<string> splitWhiteSpace(string& rest, char[], int);
102 vector<string> splitWhiteSpace(string);
103 set<string> readAccnos(string);
104 int readAccnos(string, vector<string>&);
105 map<string, int> readNames(string);
106 map<string, int> readNames(string, unsigned long int&);
107 int readTax(string, map<string, string>&);
108 int readNames(string, map<string, string>&, map<string, int>&);
109 int readNames(string, map<string, string>&);
110 int readNames(string, map<string, string>&, bool);
111 int readNames(string, map<string, string>&, int);
112 int readNames(string, map<string, vector<string> >&);
113 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
114 int mothurRemove(string);
115 bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
116 bool mothurConvert(string, intDist&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
117 bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
118 bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
122 bool checkReleaseVersion(ifstream&, string);
123 bool anyLabelsToProcess(string, set<string>&, string);
124 bool inUsersGroups(vector<string>, vector<string>);
125 bool inUsersGroups(vector<int>, vector< vector<int> >);
126 bool inUsersGroups(string, vector<string>);
127 bool inUsersGroups(int, vector<int>);
128 void getNumSeqs(ifstream&, int&);
129 int getNumSeqs(ifstream&);
130 int getNumNames(string);
131 int getNumChar(string, char);
133 bool isContainingOnlyDigits(string);
134 bool isNumeric1(string);
137 //string manipulation
138 void splitAtEquals(string&, string&);
139 void splitAtComma(string&, string&);
140 void splitAtComma(string&, vector<string>&);
141 void splitAtDash(string&, set<int>&);
142 void splitAtDash(string&, set<string>&);
143 void splitAtDash(string&, vector<string>&);
144 void splitAtChar(string&, vector<string>&, char);
145 void splitAtChar(string&, string&, char);
146 vector<string> splitWhiteSpaceWithQuotes(string);
147 int removeConfidences(string&);
148 string removeQuotes(string);
149 string makeList(vector<string>&);
150 bool isSubset(vector<string>, vector<string>); //bigSet, subset
151 int checkName(string&);
154 int factorial(int num);
155 vector<vector<double> > binomial(int);
156 float ceilDist(float, int);
157 float roundDist(float, int);
158 unsigned int fromBase36(string);
159 int getRandomIndex(int); //highest
160 double getStandardDeviation(vector<int>&);
161 vector<double> getStandardDeviation(vector< vector<double> >&);
162 vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
163 vector<double> getAverages(vector< vector<double> >&);
164 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&);
165 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&, vector< vector<seqDist> >&);
166 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&, string);
167 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&);
170 bool executing, runParse, jumble, gui, mothurCalling, debug;
172 //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles/getCurrentTypes.
173 string getPhylipFile() { return phylipfile; }
174 string getColumnFile() { return columnfile; }
175 string getListFile() { return listfile; }
176 string getRabundFile() { return rabundfile; }
177 string getSabundFile() { return sabundfile; }
178 string getNameFile() { return namefile; }
179 string getGroupFile() { return groupfile; }
180 string getOrderFile() { return orderfile; }
181 string getOrderGroupFile() { return ordergroupfile; }
182 string getTreeFile() { return treefile; }
183 string getSharedFile() { return sharedfile; }
184 string getRelAbundFile() { return relabundfile; }
185 string getDesignFile() { return designfile; }
186 string getFastaFile() { return fastafile; }
187 string getSFFFile() { return sfffile; }
188 string getQualFile() { return qualfile; }
189 string getOligosFile() { return oligosfile; }
190 string getAccnosFile() { return accnosfile; }
191 string getTaxonomyFile() { return taxonomyfile; }
192 string getFlowFile() { return flowfile; }
193 string getBiomFile() { return biomfile; }
194 string getCountTableFile() { return counttablefile; }
195 string getProcessors() { return processors; }
197 void setListFile(string f) { listfile = getFullPathName(f); }
198 void setTreeFile(string f) { treefile = getFullPathName(f); }
199 void setGroupFile(string f) { groupfile = getFullPathName(f); groupMode = "group"; }
200 void setPhylipFile(string f) { phylipfile = getFullPathName(f); }
201 void setColumnFile(string f) { columnfile = getFullPathName(f); }
202 void setNameFile(string f) { namefile = getFullPathName(f); }
203 void setRabundFile(string f) { rabundfile = getFullPathName(f); }
204 void setSabundFile(string f) { sabundfile = getFullPathName(f); }
205 void setSharedFile(string f) { sharedfile = getFullPathName(f); }
206 void setRelAbundFile(string f) { relabundfile = getFullPathName(f); }
207 void setOrderFile(string f) { orderfile = getFullPathName(f); }
208 void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); }
209 void setDesignFile(string f) { designfile = getFullPathName(f); }
210 void setFastaFile(string f) { fastafile = getFullPathName(f); }
211 void setSFFFile(string f) { sfffile = getFullPathName(f); }
212 void setQualFile(string f) { qualfile = getFullPathName(f); }
213 void setOligosFile(string f) { oligosfile = getFullPathName(f); }
214 void setAccnosFile(string f) { accnosfile = getFullPathName(f); }
215 void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); }
216 void setFlowFile(string f) { flowfile = getFullPathName(f); }
217 void setBiomFile(string f) { biomfile = getFullPathName(f); }
218 void setCountTableFile(string f) { counttablefile = getFullPathName(f); groupMode = "count"; }
219 void setProcessors(string p) { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n"); }
221 void printCurrentFiles();
222 bool hasCurrentFiles();
223 void clearCurrentFiles();
224 set<string> getCurrentTypes();
227 static MothurOut* _uniqueInstance;
228 MothurOut( const MothurOut& ); // Disable copy constructor
229 void operator=( const MothurOut& ); // Disable assignment operator
231 control_pressed = false; defaultPath="";
256 printedHeaders = false;
257 commandInputsConvertError = false;
258 mothurCalling = false;
260 sharedHeaderMode = "";
262 changedSeqNames = false;
267 string defaultPath, outputDir;
268 string releaseDate, version;
270 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
271 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile, counttablefile;
273 vector<string> Groups;
274 vector<string> namesOfGroups;
277 int mem_usage(double&, double&);
280 /***********************************************/