]> git.donarmstrong.com Git - mothur.git/blob - mothurout.h
finished added bygroup processing of chimeras in chimera.slayer and chimera.uchime...
[mothur.git] / mothurout.h
1 #ifndef MOTHUROUT_H
2 #define MOTHUROUT_H
3
4 /*
5  *  mothurOut.h
6  *  Mothur
7  *
8  *  Created by westcott on 2/25/10.
9  *  Copyright 2010 Schloss Lab. All rights reserved.
10  *
11  */
12
13 #include "mothur.h"
14
15 /***********************************************/
16
17 class MothurOut {
18         
19         public:
20                 static MothurOut* getInstance();
21                 void setFileName(string);
22                 
23                 void mothurOut(string); //writes to cout and the logfile
24                 void mothurOutEndLine(); //writes to cout and the logfile
25                 void mothurOut(string, ofstream&); //writes to the ofstream, cout and the logfile
26                 void mothurOutEndLine(ofstream&); //writes to the ofstream, cout and the logfile
27                 void mothurOutJustToLog(string);
28                 void errorOut(exception&, string, string);
29                 void closeLog();
30                 string getDefaultPath() { return defaultPath; }
31                 void setDefaultPath(string);
32                 string getOutputDir() { return outputDir; }
33                 void setOutputDir(string);
34                 
35                 string getReleaseDate() { return releaseDate; }
36                 void setReleaseDate(string r) { releaseDate = r; }
37                 string getVersion() { return version; }
38                 void setVersion(string r) { version = r; }
39         
40                 void addGroup(string g) { Groups.push_back(g); }
41                 void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
42                 void clearGroups() { Groups.clear(); }
43             int getNumGroups() { return Groups.size(); }
44                 vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
45                 void addAllGroup(string g) { namesOfGroups.push_back(g); }
46                 void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
47                 void clearAllGroups() { namesOfGroups.clear(); }
48                 int getNumAllGroups() { return namesOfGroups.size(); }
49         
50                 vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
51                 vector<string> Treenames;
52                 map<string, string> names;
53                 vector<string> binLabelsInFile;
54                 vector<string> currentBinLabels;
55                 string saveNextLabel, argv, sharedHeaderMode;
56                 bool printedHeaders;
57                 
58                 //functions from mothur.h
59                 //file operations
60                 vector<unsigned long long> divideFile(string, int&);
61                 int divideFile(string, int&, vector<string>&);
62                 vector<unsigned long long> setFilePosEachLine(string, int&);
63                 vector<unsigned long long> setFilePosFasta(string, int&);
64                 string sortFile(string, string);
65                 int appendFiles(string, string);
66                 int renameFile(string, string); //oldname, newname
67                 string getFullPathName(string);
68                 string hasPath(string);
69                 string getExtension(string);
70                 string getPathName(string);
71                 string getSimpleName(string);
72                 string getRootName(string);
73                 bool isBlank(string);
74                 int openOutputFile(string, ofstream&);
75                 int openOutputFileAppend(string, ofstream&);
76                 int openInputFile(string, ifstream&);
77                 int openInputFile(string, ifstream&, string); //no error given 
78                 string getline(ifstream&);
79                 string getline(istringstream&);
80                 void gobble(istream&);
81                 void gobble(istringstream&);
82                 map<string, int> readNames(string);
83                 int readNames(string, map<string, string>&);
84                 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
85                 void mothurRemove(string);
86                 
87                 //searchs and checks
88                 bool checkReleaseVersion(ifstream&, string);
89                 bool anyLabelsToProcess(string, set<string>&, string);
90                 bool inUsersGroups(vector<string>, vector<string>);
91                 bool inUsersGroups(string, vector<string>);
92                 void getNumSeqs(ifstream&, int&);
93                 int getNumSeqs(ifstream&);
94                 int getNumNames(string);
95                 bool isTrue(string);
96                 bool isContainingOnlyDigits(string);
97         
98                 
99                 //string manipulation
100                 void splitAtEquals(string&, string&);
101                 void splitAtComma(string&, string&);    
102                 void splitAtComma(string&, vector<string>&);
103                 void splitAtDash(string&, set<int>&);
104                 void splitAtDash(string&, set<string>&);
105                 void splitAtDash(string&, vector<string>&);
106                 void splitAtChar(string&, vector<string>&, char);
107                 
108                 //math operation
109                 int factorial(int num);
110                 vector<vector<double> > binomial(int);
111                 float ceilDist(float, int);
112                 float roundDist(float, int);
113                 unsigned int fromBase36(string);
114                 int getRandomIndex(int); //highest
115
116                 int control_pressed;
117                 bool executing, runParse, jumble, gui;
118                 
119                 //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles.
120                 string getPhylipFile()          { return phylipfile;            }
121                 string getColumnFile()          { return columnfile;            }
122                 string getListFile()            { return listfile;                      }
123                 string getRabundFile()          { return rabundfile;            }
124                 string getSabundFile()          { return sabundfile;            }
125                 string getNameFile()            { return namefile;                      }       
126                 string getGroupFile()           { return groupfile;                     }       
127                 string getOrderFile()           { return orderfile;                     }
128                 string getOrderGroupFile()      { return ordergroupfile;        }
129                 string getTreeFile()            { return treefile;                      }
130                 string getSharedFile()          { return sharedfile;            }
131                 string getRelAbundFile()        { return relabundfile;          }
132                 string getDesignFile()          { return designfile;            }
133                 string getFastaFile()           { return fastafile;                     }
134                 string getSFFFile()                     { return sfffile;                       }
135                 string getQualFile()            { return qualfile;                      }
136                 string getOligosFile()          { return oligosfile;            }
137                 string getAccnosFile()          { return accnosfile;            }
138                 string getTaxonomyFile()        { return taxonomyfile;          }
139                 string getFlowFile()            { return flowfile;                      }
140                 string getProcessors()          { return processors;            }
141                 
142                 void setListFile(string f)                      { listfile = getFullPathName(f);                        }
143                 void setTreeFile(string f)                      { treefile = getFullPathName(f);                        }
144                 void setGroupFile(string f)                     { groupfile = getFullPathName(f);                       }               
145                 void setPhylipFile(string f)            { phylipfile = getFullPathName(f);                      }
146                 void setColumnFile(string f)            { columnfile = getFullPathName(f);                      }
147                 void setNameFile(string f)                      { namefile = getFullPathName(f);                        }       
148                 void setRabundFile(string f)            { rabundfile = getFullPathName(f);                      }
149                 void setSabundFile(string f)            { sabundfile = getFullPathName(f);                      }
150                 void setSharedFile(string f)            { sharedfile = getFullPathName(f);                      }
151                 void setRelAbundFile(string f)          { relabundfile = getFullPathName(f);            }
152                 void setOrderFile(string f)                     { orderfile = getFullPathName(f);                       }
153                 void setOrderGroupFile(string f)        { ordergroupfile = getFullPathName(f);          }
154                 void setDesignFile(string f)            { designfile = getFullPathName(f);                      }
155                 void setFastaFile(string f)                     { fastafile = getFullPathName(f);                       }
156                 void setSFFFile(string f)                       { sfffile = getFullPathName(f);                         }
157                 void setQualFile(string f)                      { qualfile = getFullPathName(f);                        }
158                 void setOligosFile(string f)            { oligosfile = getFullPathName(f);                      }
159                 void setAccnosFile(string f)            { accnosfile = getFullPathName(f);                      }
160                 void setTaxonomyFile(string f)          { taxonomyfile = getFullPathName(f);            }
161                 void setFlowFile(string f)                      { flowfile = getFullPathName(f);                        }
162                 void setProcessors(string p)            { processors = p;                                                       }
163                 
164                 void printCurrentFiles();
165                 bool hasCurrentFiles();
166                 void clearCurrentFiles();
167                 
168         private:
169                 static MothurOut* _uniqueInstance;
170                 MothurOut( const MothurOut& ); // Disable copy constructor
171                 void operator=( const MothurOut& ); // Disable assignment operator
172                 MothurOut() { 
173                         control_pressed = false; defaultPath=""; 
174                         phylipfile = "";
175                         columnfile = "";
176                         listfile = "";
177                         rabundfile = "";
178                         sabundfile = "";
179                         namefile = "";
180                         groupfile = "";
181                         designfile = "";
182                         orderfile = "";
183                         treefile = "";
184                         sharedfile = "";
185                         ordergroupfile = "";
186                         relabundfile = "";
187                         fastafile = "";
188                         qualfile = "";
189                         sfffile = "";
190                         oligosfile = "";
191                         accnosfile = "";
192                         taxonomyfile = "";
193                         processors = "1";
194                         flowfile = "";
195                         gui = false;
196                         printedHeaders = false;
197                         sharedHeaderMode = "";
198                 }
199                 ~MothurOut();
200
201                 string logFileName;
202                 string defaultPath, outputDir;
203                 string releaseDate, version;
204         
205                 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile;
206                 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
207
208                 vector<string> Groups;
209                 vector<string> namesOfGroups;
210                 ofstream out;
211                 
212                 int mem_usage(double&, double&);
213
214 };
215 /***********************************************/
216
217 #endif
218