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&);
78 int divideFile(string, int&, vector<string>&);
79 vector<unsigned long long> setFilePosEachLine(string, int&);
80 vector<unsigned long long> setFilePosFasta(string, int&);
81 string sortFile(string, string);
82 int appendFiles(string, string);
83 int renameFile(string, string); //oldname, newname
84 string getFullPathName(string);
85 string findProgramPath(string programName);
86 string hasPath(string);
87 string getExtension(string);
88 string getPathName(string);
89 string getSimpleName(string);
90 string getRootName(string);
92 int openOutputFile(string, ofstream&);
93 int openOutputFileAppend(string, ofstream&);
94 int openInputFile(string, ifstream&);
95 int openInputFile(string, ifstream&, string); //no error given
96 string getline(ifstream&);
97 string getline(istringstream&);
98 void gobble(istream&);
99 void gobble(istringstream&);
100 vector<string> splitWhiteSpace(string& rest, char[], int);
101 vector<string> splitWhiteSpace(string);
102 set<string> readAccnos(string);
103 int readAccnos(string, vector<string>&);
104 map<string, int> readNames(string);
105 map<string, int> readNames(string, unsigned long int&);
106 int readTax(string, map<string, string>&);
107 int readNames(string, map<string, string>&, map<string, int>&);
108 int readNames(string, map<string, string>&);
109 int readNames(string, map<string, string>&, bool);
110 int readNames(string, map<string, string>&, int);
111 int readNames(string, map<string, vector<string> >&);
112 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
113 int mothurRemove(string);
114 bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
115 bool mothurConvert(string, intDist&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
116 bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
117 bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
121 bool checkReleaseVersion(ifstream&, string);
122 bool anyLabelsToProcess(string, set<string>&, string);
123 bool inUsersGroups(vector<string>, vector<string>);
124 bool inUsersGroups(vector<int>, vector< vector<int> >);
125 bool inUsersGroups(string, vector<string>);
126 bool inUsersGroups(int, vector<int>);
127 void getNumSeqs(ifstream&, int&);
128 int getNumSeqs(ifstream&);
129 int getNumNames(string);
130 int getNumChar(string, char);
132 bool isContainingOnlyDigits(string);
133 bool isNumeric1(string);
136 //string manipulation
137 void splitAtEquals(string&, string&);
138 void splitAtComma(string&, string&);
139 void splitAtComma(string&, vector<string>&);
140 void splitAtDash(string&, set<int>&);
141 void splitAtDash(string&, set<string>&);
142 void splitAtDash(string&, vector<string>&);
143 void splitAtChar(string&, vector<string>&, char);
144 void splitAtChar(string&, string&, char);
145 vector<string> splitWhiteSpaceWithQuotes(string);
146 int removeConfidences(string&);
147 string removeQuotes(string);
148 string makeList(vector<string>&);
149 bool isSubset(vector<string>, vector<string>); //bigSet, subset
150 int checkName(string&);
153 int factorial(int num);
154 vector<vector<double> > binomial(int);
155 float ceilDist(float, int);
156 float roundDist(float, int);
157 unsigned int fromBase36(string);
158 int getRandomIndex(int); //highest
159 double getStandardDeviation(vector<int>&);
160 vector<double> getStandardDeviation(vector< vector<double> >&);
161 vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
162 vector<double> getAverages(vector< vector<double> >&);
163 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&);
164 vector< vector<seqDist> > getStandardDeviation(vector< vector< vector<seqDist> > >&, vector< vector<seqDist> >&);
165 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&, string);
166 vector< vector<seqDist> > getAverages(vector< vector< vector<seqDist> > >&);
169 bool executing, runParse, jumble, gui, mothurCalling, debug;
171 //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles/getCurrentTypes.
172 string getPhylipFile() { return phylipfile; }
173 string getColumnFile() { return columnfile; }
174 string getListFile() { return listfile; }
175 string getRabundFile() { return rabundfile; }
176 string getSabundFile() { return sabundfile; }
177 string getNameFile() { return namefile; }
178 string getGroupFile() { return groupfile; }
179 string getOrderFile() { return orderfile; }
180 string getOrderGroupFile() { return ordergroupfile; }
181 string getTreeFile() { return treefile; }
182 string getSharedFile() { return sharedfile; }
183 string getRelAbundFile() { return relabundfile; }
184 string getDesignFile() { return designfile; }
185 string getFastaFile() { return fastafile; }
186 string getSFFFile() { return sfffile; }
187 string getQualFile() { return qualfile; }
188 string getOligosFile() { return oligosfile; }
189 string getAccnosFile() { return accnosfile; }
190 string getTaxonomyFile() { return taxonomyfile; }
191 string getFlowFile() { return flowfile; }
192 string getBiomFile() { return biomfile; }
193 string getCountTableFile() { return counttablefile; }
194 string getProcessors() { return processors; }
196 void setListFile(string f) { listfile = getFullPathName(f); }
197 void setTreeFile(string f) { treefile = getFullPathName(f); }
198 void setGroupFile(string f) { groupfile = getFullPathName(f); groupMode = "group"; }
199 void setPhylipFile(string f) { phylipfile = getFullPathName(f); }
200 void setColumnFile(string f) { columnfile = getFullPathName(f); }
201 void setNameFile(string f) { namefile = getFullPathName(f); }
202 void setRabundFile(string f) { rabundfile = getFullPathName(f); }
203 void setSabundFile(string f) { sabundfile = getFullPathName(f); }
204 void setSharedFile(string f) { sharedfile = getFullPathName(f); }
205 void setRelAbundFile(string f) { relabundfile = getFullPathName(f); }
206 void setOrderFile(string f) { orderfile = getFullPathName(f); }
207 void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); }
208 void setDesignFile(string f) { designfile = getFullPathName(f); }
209 void setFastaFile(string f) { fastafile = getFullPathName(f); }
210 void setSFFFile(string f) { sfffile = getFullPathName(f); }
211 void setQualFile(string f) { qualfile = getFullPathName(f); }
212 void setOligosFile(string f) { oligosfile = getFullPathName(f); }
213 void setAccnosFile(string f) { accnosfile = getFullPathName(f); }
214 void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); }
215 void setFlowFile(string f) { flowfile = getFullPathName(f); }
216 void setBiomFile(string f) { biomfile = getFullPathName(f); }
217 void setCountTableFile(string f) { counttablefile = getFullPathName(f); groupMode = "count"; }
218 void setProcessors(string p) { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n"); }
220 void printCurrentFiles();
221 bool hasCurrentFiles();
222 void clearCurrentFiles();
223 set<string> getCurrentTypes();
226 static MothurOut* _uniqueInstance;
227 MothurOut( const MothurOut& ); // Disable copy constructor
228 void operator=( const MothurOut& ); // Disable assignment operator
230 control_pressed = false; defaultPath="";
255 printedHeaders = false;
256 commandInputsConvertError = false;
257 mothurCalling = false;
259 sharedHeaderMode = "";
261 changedSeqNames = false;
266 string defaultPath, outputDir;
267 string releaseDate, version;
269 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
270 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile, counttablefile;
272 vector<string> Groups;
273 vector<string> namesOfGroups;
276 int mem_usage(double&, double&);
279 /***********************************************/