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