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