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