]> git.donarmstrong.com Git - mothur.git/blob - mothurout.h
changed normalize.shared and sub.sample commands to fix bug in normalize.shared and...
[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                 vector<string> Groups;
40                 vector<string> Treenames;
41                 map<string, string> names;
42                 vector<string> namesOfGroups;
43                 vector<string> binLabelsInFile;
44                 vector<string> currentBinLabels;
45                 string saveNextLabel, argv, sharedHeaderMode;
46                 bool printedHeaders;
47                 
48                 //functions from mothur.h
49                 //file operations
50                 vector<unsigned long int> divideFile(string, int&);
51                 int divideFile(string, int&, vector<string>&);
52                 vector<unsigned long int> setFilePosEachLine(string, int&);
53                 vector<unsigned long int> setFilePosFasta(string, int&);
54                 string sortFile(string, string);
55                 void appendFiles(string, string);
56                 int renameFile(string, string); //oldname, newname
57                 string getFullPathName(string);
58                 string hasPath(string);
59                 string getExtension(string);
60                 string getPathName(string);
61                 string getSimpleName(string);
62                 string getRootName(string);
63                 bool isBlank(string);
64                 int openOutputFile(string, ofstream&);
65                 int openOutputFileAppend(string, ofstream&);
66                 int openInputFile(string, ifstream&);
67                 int openInputFile(string, ifstream&, string); //no error given 
68                 string getline(ifstream&);
69                 string getline(istringstream&);
70                 void gobble(istream&);
71                 void gobble(istringstream&);
72                 map<string, int> readNames(string);
73                 int readNames(string, map<string, string>&);
74                 int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
75                 void mothurRemove(string);
76                 
77                 //searchs and checks
78                 bool checkReleaseVersion(ifstream&, string);
79                 bool anyLabelsToProcess(string, set<string>&, string);
80                 bool inUsersGroups(vector<string>, vector<string>);
81                 bool inUsersGroups(string, vector<string>);
82                 void getNumSeqs(ifstream&, int&);
83                 int getNumSeqs(ifstream&);
84                 int getNumNames(string);
85                 bool isTrue(string);
86                 bool isContainingOnlyDigits(string);
87         
88                 
89                 //string manipulation
90                 void splitAtEquals(string&, string&);
91                 void splitAtComma(string&, string&);    
92                 void splitAtComma(string&, vector<string>&);
93                 void splitAtDash(string&, set<int>&);
94                 void splitAtDash(string&, set<string>&);
95                 void splitAtDash(string&, vector<string>&);
96                 void splitAtChar(string&, vector<string>&, char);
97                 
98                 //math operation
99                 int factorial(int num);
100                 vector<vector<double> > binomial(int);
101                 float ceilDist(float, int);
102                 float roundDist(float, int);
103                 unsigned int fromBase36(string);
104                 int getRandomIndex(int); //highest
105
106                 int control_pressed;
107                 bool executing, runParse, jumble, gui;
108                 
109                 //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles.
110                 string getPhylipFile()          { return phylipfile;            }
111                 string getColumnFile()          { return columnfile;            }
112                 string getListFile()            { return listfile;                      }
113                 string getRabundFile()          { return rabundfile;            }
114                 string getSabundFile()          { return sabundfile;            }
115                 string getNameFile()            { return namefile;                      }       
116                 string getGroupFile()           { return groupfile;                     }       
117                 string getOrderFile()           { return orderfile;                     }
118                 string getOrderGroupFile()      { return ordergroupfile;        }
119                 string getTreeFile()            { return treefile;                      }
120                 string getSharedFile()          { return sharedfile;            }
121                 string getRelAbundFile()        { return relabundfile;          }
122                 string getDesignFile()          { return designfile;            }
123                 string getFastaFile()           { return fastafile;                     }
124                 string getSFFFile()                     { return sfffile;                       }
125                 string getQualFile()            { return qualfile;                      }
126                 string getOligosFile()          { return oligosfile;            }
127                 string getAccnosFile()          { return accnosfile;            }
128                 string getTaxonomyFile()        { return taxonomyfile;          }
129                 string getFlowFile()            { return flowfile;                      }
130                 string getProcessors()          { return processors;            }
131                 
132                 void setListFile(string f)                      { listfile = getFullPathName(f);                        }
133                 void setTreeFile(string f)                      { treefile = getFullPathName(f);                        }
134                 void setGroupFile(string f)                     { groupfile = getFullPathName(f);                       }               
135                 void setPhylipFile(string f)            { phylipfile = getFullPathName(f);                      }
136                 void setColumnFile(string f)            { columnfile = getFullPathName(f);                      }
137                 void setNameFile(string f)                      { namefile = getFullPathName(f);                        }       
138                 void setRabundFile(string f)            { rabundfile = getFullPathName(f);                      }
139                 void setSabundFile(string f)            { sabundfile = getFullPathName(f);                      }
140                 void setSharedFile(string f)            { sharedfile = getFullPathName(f);                      }
141                 void setRelAbundFile(string f)          { relabundfile = getFullPathName(f);            }
142                 void setOrderFile(string f)                     { orderfile = getFullPathName(f);                       }
143                 void setOrderGroupFile(string f)        { ordergroupfile = getFullPathName(f);          }
144                 void setDesignFile(string f)            { designfile = getFullPathName(f);                      }
145                 void setFastaFile(string f)                     { fastafile = getFullPathName(f);                       }
146                 void setSFFFile(string f)                       { sfffile = getFullPathName(f);                         }
147                 void setQualFile(string f)                      { qualfile = getFullPathName(f);                        }
148                 void setOligosFile(string f)            { oligosfile = getFullPathName(f);                      }
149                 void setAccnosFile(string f)            { accnosfile = getFullPathName(f);                      }
150                 void setTaxonomyFile(string f)          { taxonomyfile = getFullPathName(f);            }
151                 void setFlowFile(string f)                      { flowfile = getFullPathName(f);                        }
152                 void setProcessors(string p)            { processors = p;                                                       }
153                 
154                 void printCurrentFiles();
155                 bool hasCurrentFiles();
156                 void clearCurrentFiles();
157                 
158         private:
159                 static MothurOut* _uniqueInstance;
160                 MothurOut( const MothurOut& ); // Disable copy constructor
161                 void operator=( const MothurOut& ); // Disable assignment operator
162                 MothurOut() { 
163                         control_pressed = false; defaultPath=""; 
164                         phylipfile = "";
165                         columnfile = "";
166                         listfile = "";
167                         rabundfile = "";
168                         sabundfile = "";
169                         namefile = "";
170                         groupfile = "";
171                         designfile = "";
172                         orderfile = "";
173                         treefile = "";
174                         sharedfile = "";
175                         ordergroupfile = "";
176                         relabundfile = "";
177                         fastafile = "";
178                         qualfile = "";
179                         sfffile = "";
180                         oligosfile = "";
181                         accnosfile = "";
182                         taxonomyfile = "";
183                         processors = "1";
184                         flowfile = "";
185                         gui = false;
186                         printedHeaders = false;
187                         sharedHeaderMode = "";
188                 }
189                 ~MothurOut();
190
191                 string logFileName;
192                 string defaultPath, outputDir;
193                 string releaseDate, version;
194         
195                 string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile;
196                 string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
197
198         
199                 ofstream out;
200                 
201                 int mem_usage(double&, double&);
202
203 };
204 /***********************************************/
205
206 #endif
207