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