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