A70B53AA0F4CD7AD0064797E /* getgroupcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70B53A40F4CD7AD0064797E /* getgroupcommand.cpp */; };
A70B53AB0F4CD7AD0064797E /* getlabelcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70B53A60F4CD7AD0064797E /* getlabelcommand.cpp */; };
A70DECD91063D8B40057C03C /* secondarystructurecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70DECD81063D8B40057C03C /* secondarystructurecommand.cpp */; };
+ A70F3FD01136E391004FDC52 /* mothurout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70F3FCF1136E391004FDC52 /* mothurout.cpp */; };
A71CB8A311354B9F00848EF7 /* parselistscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71CB8A211354B9F00848EF7 /* parselistscommand.cpp */; };
A727E84A10D14568001A8432 /* readblast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A727E84910D14568001A8432 /* readblast.cpp */; };
A7283FF81056CAE100D0CC69 /* chimeracheckrdp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7283FF71056CAE100D0CC69 /* chimeracheckrdp.cpp */; };
A70B53A70F4CD7AD0064797E /* getlabelcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getlabelcommand.h; sourceTree = SOURCE_ROOT; };
A70DECD71063D8B40057C03C /* secondarystructurecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = secondarystructurecommand.h; sourceTree = SOURCE_ROOT; };
A70DECD81063D8B40057C03C /* secondarystructurecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = secondarystructurecommand.cpp; sourceTree = SOURCE_ROOT; };
+ A70F3FCE1136E391004FDC52 /* mothurout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurout.h; sourceTree = SOURCE_ROOT; };
+ A70F3FCF1136E391004FDC52 /* mothurout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurout.cpp; sourceTree = SOURCE_ROOT; };
A71CB8A111354B9F00848EF7 /* parselistscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parselistscommand.h; sourceTree = SOURCE_ROOT; };
A71CB8A211354B9F00848EF7 /* parselistscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parselistscommand.cpp; sourceTree = SOURCE_ROOT; };
A727E84810D14568001A8432 /* readblast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readblast.h; sourceTree = SOURCE_ROOT; };
7E412FE90F8D3E2C00381DD0 /* libshuff.cpp */,
37E3ED800F4D9D0D00B5DF02 /* mothur.h */,
37D927EF0F21331F001D4494 /* mothur.cpp */,
+ A70F3FCE1136E391004FDC52 /* mothurout.h */,
+ A70F3FCF1136E391004FDC52 /* mothurout.cpp */,
373C691E0FC1C98600137ACD /* nast.hpp */,
373C691D0FC1C98600137ACD /* nast.cpp */,
373C692A0FC1C9EB00137ACD /* nastreport.hpp */,
A794201111107897003AECCD /* distancedb.cpp in Sources */,
A7E8A22F1125939F0011D39C /* chimerarealigner.cpp in Sources */,
A71CB8A311354B9F00848EF7 /* parselistscommand.cpp in Sources */,
+ A70F3FD01136E391004FDC52 /* mothurout.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
return data;
}
catch(exception& e) {
- errorOut(e, "Ace", "getValues");
+ m->errorOut(e, "Ace", "getValues");
exit(1);
}
}
//**********************************************************************************************************************
-AlignCommand::AlignCommand(string option){
+AlignCommand::AlignCommand(string option) {
try {
- // globaldata = GlobalData::getInstance();
+
abort = false;
//allow user to run help
templateFileName = validParameter.validFile(parameters, "template", true);
if (templateFileName == "not found") {
- mothurOut("template is a required parameter for the align.seqs command.");
- mothurOutEndLine();
+ m->mothurOut("template is a required parameter for the align.seqs command.");
+ m->mothurOutEndLine();
abort = true;
}else if (templateFileName == "not open") { abort = true; }
candidateFileName = validParameter.validFile(parameters, "candidate", false);
- if (candidateFileName == "not found") { mothurOut("candidate is a required parameter for the align.seqs command."); mothurOutEndLine(); abort = true; }
+ if (candidateFileName == "not found") { m->mothurOut("candidate is a required parameter for the align.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
splitAtDash(candidateFileName, candidateFileNames);
ifstream in;
ableToOpen = openInputFile(candidateFileNames[i], in);
if (ableToOpen == 1) {
- mothurOut(candidateFileNames[i] + " will be disregarded."); mothurOutEndLine();
+ m->mothurOut(candidateFileNames[i] + " will be disregarded."); m->mothurOutEndLine();
//erase from file list
candidateFileNames.erase(candidateFileNames.begin()+i);
i--;
}
//make sure there is at least one valid file left
- if (candidateFileNames.size() == 0) { mothurOut("no valid files."); mothurOutEndLine(); abort = true; }
+ if (candidateFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "AlignCommand");
+ m->errorOut(e, "AlignCommand", "AlignCommand");
exit(1);
}
}
void AlignCommand::help(){
try {
- mothurOut("The align.seqs command reads a file containing sequences and creates an alignment file and a report file.\n");
- mothurOut("The align.seqs command parameters are template, candidate, search, ksize, align, match, mismatch, gapopen and gapextend.\n");
- mothurOut("The template and candidate parameters are required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n");
- mothurOut("The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer and blast. The default is kmer.\n");
- mothurOut("The align parameter allows you to specify the alignment method to use. Your options are: gotoh, needleman, blast and noalign. The default is needleman.\n");
- mothurOut("The ksize parameter allows you to specify the kmer size for finding most similar template to candidate. The default is 8.\n");
- mothurOut("The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n");
- mothurOut("The mistmatch parameter allows you to specify the penalty for having different bases. The default is -1.0.\n");
- mothurOut("The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n");
- mothurOut("The gapextend parameter allows you to specify the penalty for extending a gap in an alignment. The default is -1.0.\n");
- mothurOut("The flip parameter is used to specify whether or not you want mothur to try the reverse complement if a sequence falls below the threshold. The default is false.\n");
- mothurOut("The threshold is used to specify a cutoff at which an alignment is deemed 'bad' and the reverse complement may be tried. The default threshold is 0.50, meaning 50% of the bases are removed in the alignment.\n");
- mothurOut("If the flip parameter is set to true the reverse complement of the sequence is aligned and the better alignment is reported.\n");
- mothurOut("The default for the threshold parameter is 0.50, meaning at least 50% of the bases must remain or the sequence is reported as potentially reversed.\n");
- mothurOut("The align.seqs command should be in the following format: \n");
- mothurOut("align.seqs(template=yourTemplateFile, candidate=yourCandidateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty) \n");
- mothurOut("Example align.seqs(candidate=candidate.fasta, template=core.filtered, align=kmer, search=gotoh, ksize=8, match=2.0, mismatch=3.0, gapopen=-2.0, gapextend=-1.0)\n");
- mothurOut("Note: No spaces between parameter labels (i.e. candidate), '=' and parameters (i.e.yourFastaFile).\n\n");
+ m->mothurOut("The align.seqs command reads a file containing sequences and creates an alignment file and a report file.\n");
+ m->mothurOut("The align.seqs command parameters are template, candidate, search, ksize, align, match, mismatch, gapopen and gapextend.\n");
+ m->mothurOut("The template and candidate parameters are required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n");
+ m->mothurOut("The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer and blast. The default is kmer.\n");
+ m->mothurOut("The align parameter allows you to specify the alignment method to use. Your options are: gotoh, needleman, blast and noalign. The default is needleman.\n");
+ m->mothurOut("The ksize parameter allows you to specify the kmer size for finding most similar template to candidate. The default is 8.\n");
+ m->mothurOut("The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n");
+ m->mothurOut("The mistmatch parameter allows you to specify the penalty for having different bases. The default is -1.0.\n");
+ m->mothurOut("The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n");
+ m->mothurOut("The gapextend parameter allows you to specify the penalty for extending a gap in an alignment. The default is -1.0.\n");
+ m->mothurOut("The flip parameter is used to specify whether or not you want mothur to try the reverse complement if a sequence falls below the threshold. The default is false.\n");
+ m->mothurOut("The threshold is used to specify a cutoff at which an alignment is deemed 'bad' and the reverse complement may be tried. The default threshold is 0.50, meaning 50% of the bases are removed in the alignment.\n");
+ m->mothurOut("If the flip parameter is set to true the reverse complement of the sequence is aligned and the better alignment is reported.\n");
+ m->mothurOut("The default for the threshold parameter is 0.50, meaning at least 50% of the bases must remain or the sequence is reported as potentially reversed.\n");
+ m->mothurOut("The align.seqs command should be in the following format: \n");
+ m->mothurOut("align.seqs(template=yourTemplateFile, candidate=yourCandidateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty) \n");
+ m->mothurOut("Example align.seqs(candidate=candidate.fasta, template=core.filtered, align=kmer, search=gotoh, ksize=8, match=2.0, mismatch=3.0, gapopen=-2.0, gapextend=-1.0)\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. candidate), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "help");
+ m->errorOut(e, "AlignCommand", "help");
exit(1);
}
}
else if(align == "blast") { alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch); }
else if(align == "noalign") { alignment = new NoAlign(); }
else {
- mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
- mothurOutEndLine();
+ m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
+ m->mothurOutEndLine();
alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
}
+ vector<string> outputNames;
for (int s = 0; s < candidateFileNames.size(); s++) {
- mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); mothurOutEndLine();
+ m->mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); m->mothurOutEndLine();
if (outputDir == "") { outputDir += hasPath(candidateFileNames[s]); }
string alignFileName = outputDir + getRootName(getSimpleName(candidateFileNames[s])) + "align";
driver(lines[0], alignFileName, reportFileName, accnosFileName, candidateFileNames[s]);
//delete accnos file if its blank else report to user
- if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); }
+ if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
else {
- mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
+ m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
if (!flip) {
- mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
- }else{ mothurOut(" If the reverse compliment proved to be better it was reported."); }
- mothurOutEndLine();
+ m->mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
+ }else{ m->mothurOut(" If the reverse compliment proved to be better it was reported."); }
+ m->mothurOutEndLine();
}
}
else{
appendAlignFiles(nonBlankAccnosFiles[h], accnosFileName);
remove(nonBlankAccnosFiles[h].c_str());
}
- mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
+ m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
if (!flip) {
- mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
- }else{ mothurOut(" If the reverse compliment proved to be better it was reported."); }
- mothurOutEndLine();
+ m->mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
+ }else{ m->mothurOut(" If the reverse compliment proved to be better it was reported."); }
+ m->mothurOutEndLine();
}else{ hasAccnos = false; }
}
#else
//delete accnos file if its blank else report to user
if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
else {
- mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
+ m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
if (!flip) {
- mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
- }else{ mothurOut(" If the reverse compliment proved to be better it was reported."); }
- mothurOutEndLine();
+ m->mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well.");
+ }else{ m->mothurOut(" If the reverse compliment proved to be better it was reported."); }
+ m->mothurOutEndLine();
}
#endif
- mothurOut("Output File Names: " + alignFileName + ", " + reportFileName);
- if (hasAccnos) { mothurOut(", " + accnosFileName + "."); }
- else { mothurOut("."); }
- mothurOutEndLine();
-
- mothurOut("It took " + toString(time(NULL) - start) + " secs to align " + toString(numFastaSeqs) + " sequences.");
- mothurOutEndLine();
- mothurOutEndLine();
+ outputNames.push_back(alignFileName);
+ outputNames.push_back(reportFileName);
+ if (hasAccnos) { outputNames.push_back(accnosFileName); }
+
+ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to align " + toString(numFastaSeqs) + " sequences.");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
}
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "execute");
+ m->errorOut(e, "AlignCommand", "execute");
exit(1);
}
}
delete candidateSeq;
//report progress
- if((i+1) % 100 == 0){ mothurOut(toString(i+1)); mothurOutEndLine(); }
+ if((i+1) % 100 == 0){ m->mothurOut(toString(i+1)); m->mothurOutEndLine(); }
}
//report progress
- if((line->numSeqs) % 100 != 0){ mothurOut(toString(line->numSeqs)); mothurOutEndLine(); }
+ if((line->numSeqs) % 100 != 0){ m->mothurOut(toString(line->numSeqs)); m->mothurOutEndLine(); }
alignmentFile.close();
inFASTA.close();
return 1;
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "driver");
+ m->errorOut(e, "AlignCommand", "driver");
exit(1);
}
}
}else if (pid == 0){
driver(lines[process], alignFileName + toString(getpid()) + ".temp", reportFileName + toString(getpid()) + ".temp", accnosFName + toString(getpid()) + ".temp", filename);
exit(0);
- }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
//force parent to wait until all the processes are done
#endif
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "createProcesses");
+ m->errorOut(e, "AlignCommand", "createProcesses");
exit(1);
}
}
output.close();
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "appendAlignFiles");
+ m->errorOut(e, "AlignCommand", "appendAlignFiles");
exit(1);
}
}
output.close();
}
catch(exception& e) {
- errorOut(e, "AlignCommand", "appendReportFiles");
+ m->errorOut(e, "AlignCommand", "appendReportFiles");
exit(1);
}
}
Alignment::Alignment(int A) : nCols(A), nRows(A) {
try {
+ m = MothurOut::getInstance();
alignment.resize(nRows); // For the Gotoh and Needleman-Wunsch we initialize the dynamic programming
for(int i=0;i<nRows;i++){ // matrix by initializing a matrix that is A x A. By default we will set A
alignment[i].resize(nCols); // at 2000 for 16S rRNA gene sequences
}
}
catch(exception& e) {
- errorOut(e, "Alignment", "Alignment");
+ m->errorOut(e, "Alignment", "Alignment");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Alignment", "resize");
+ m->errorOut(e, "Alignment", "resize");
exit(1);
}
}
seqBend = seqB.length() - seqBend - 1;
}
catch(exception& e) {
- errorOut(e, "Alignment", "traceBack");
+ m->errorOut(e, "Alignment", "traceBack");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Alignment", "~Alignment");
+ m->errorOut(e, "Alignment", "~Alignment");
exit(1);
}
}
int pairwiseLength;
int nRows, nCols, lA, lB;
vector<vector<AlignmentCell> > alignment;
+ MothurOut* m;
};
/**************************************************************************************************/
* used to calcualte the alignment. Initially everything is set to zero and all pointers are set to 'x'
*
*/
-
+#include "mothurout.h"
//********************************************************************************************************************
class AlignmentCell {
/**************************************************************************************************/
AlignmentDB::AlignmentDB(string fastaFileName, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch){ // This assumes that the template database is in fasta format, may
try { // need to alter this in the future?
+ m = MothurOut::getInstance();
longest = 0;
ifstream fastaFile;
openInputFile(fastaFileName, fastaFile);
- mothurOutEndLine();
- mothurOut("Reading in the " + fastaFileName + " template sequences...\t"); cout.flush();
+ m->mothurOutEndLine();
+ m->mothurOut("Reading in the " + fastaFileName + " template sequences...\t"); cout.flush();
while (!fastaFile.eof()) {
Sequence temp(fastaFile); gobble(fastaFile);
fastaFile.close();
//all of this is elsewhere already!
- mothurOut("DONE.");
- mothurOutEndLine(); cout.flush();
+ m->mothurOut("DONE.");
+ m->mothurOutEndLine(); cout.flush();
//in case you delete the seqs and then ask for them
emptySequence = Sequence();
else if(method == "suffix") { search = new SuffixDB(numSeqs); }
else if(method == "blast") { search = new BlastDB(gapOpen, gapExtend, match, misMatch); }
else {
- mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
- mothurOutEndLine();
+ m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
+ m->mothurOutEndLine();
search = new KmerDB(fastaFileName, 8);
}
search->setNumSeqs(numSeqs);
}
catch(exception& e) {
- errorOut(e, "AlignmentDB", "AlignmentDB");
+ m->errorOut(e, "AlignmentDB", "AlignmentDB");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "AlignmentDB", "findClosestSequence");
+ m->errorOut(e, "AlignmentDB", "findClosestSequence");
exit(1);
}
}
Database* search;
vector<Sequence> templateSequences;
Sequence emptySequence;
+ MothurOut* m;
};
/**************************************************************************************************/
return(true);
}
catch(exception& e) {
- errorOut(e, "AverageLinkage", "updateDistance");
+ m->errorOut(e, "AverageLinkage", "updateDistance");
exit(1);
}
}
int start = time(NULL);
if(probFileTest && probFileTest2){
- mothurOut("Reading template probabilities... "); cout.flush();
+ m->mothurOut("Reading template probabilities... "); cout.flush();
readProbFile(probFileTest, probFileTest2);
}else{
- mothurOut("Calculating template probabilities... "); cout.flush();
+ m->mothurOut("Calculating template probabilities... "); cout.flush();
ofstream out;
openOutputFile(probFileName, out);
}
- mothurOut("DONE."); mothurOutEndLine();
- mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); mothurOutEndLine();
+ m->mothurOut("DONE."); m->mothurOutEndLine();
+ m->mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "Bayesian", "Bayesian");
+ m->errorOut(e, "Bayesian", "Bayesian");
exit(1);
}
}
return tax;
}
catch(exception& e) {
- errorOut(e, "Bayesian", "getTaxonomy");
+ m->errorOut(e, "Bayesian", "getTaxonomy");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Bayesian", "bootstrapResults");
+ m->errorOut(e, "Bayesian", "bootstrapResults");
exit(1);
}
}
return indexofGenus;
}
catch(exception& e) {
- errorOut(e, "Bayesian", "getMostProbableTaxonomy");
+ m->errorOut(e, "Bayesian", "getMostProbableTaxonomy");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Bayesian", "parseTax");
+ m->errorOut(e, "Bayesian", "parseTax");
exit(1);
}
}
in.close();
}
catch(exception& e) {
- errorOut(e, "Bayesian", "readProbFile");
+ m->errorOut(e, "Bayesian", "readProbFile");
exit(1);
}
}
outputDir = o;
}
catch(exception& e) {
- errorOut(e, "Bellerophon", "Bellerophon");
+ m->errorOut(e, "Bellerophon", "Bellerophon");
exit(1);
}
}
if (pref[i].score[0] > 1.0) {
above1++;
outAcc << pref[i].name << endl;
- mothurOut(pref[i].name + " is a suspected chimera at breakpoint " + toString(pref[i].midpoint)); mothurOutEndLine();
- mothurOut("It's score is " + toString(pref[i].score[0]) + " with suspected left parent " + pref[i].leftParent[0] + " and right parent " + pref[i].rightParent[0]); mothurOutEndLine();
+ m->mothurOut(pref[i].name + " is a suspected chimera at breakpoint " + toString(pref[i].midpoint)); m->mothurOutEndLine();
+ m->mothurOut("It's score is " + toString(pref[i].score[0]) + " with suspected left parent " + pref[i].leftParent[0] + " and right parent " + pref[i].rightParent[0]); m->mothurOutEndLine();
}
}
//output results to screen
- mothurOutEndLine();
- mothurOut("Sequence with preference score above 1.0: " + toString(above1)); mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Sequence with preference score above 1.0: " + toString(above1)); m->mothurOutEndLine();
int spot;
spot = pref.size()-1;
- mothurOut("Minimum:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("Minimum:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = pref.size() * 0.975;
- mothurOut("2.5%-tile:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("2.5%-tile:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = pref.size() * 0.75;
- mothurOut("25%-tile:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("25%-tile:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = pref.size() * 0.50;
- mothurOut("Median: \t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("Median: \t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = pref.size() * 0.25;
- mothurOut("75%-tile:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("75%-tile:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = pref.size() * 0.025;
- mothurOut("97.5%-tile:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("97.5%-tile:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
spot = 0;
- mothurOut("Maximum:\t" + toString(pref[spot].score[0])); mothurOutEndLine();
+ m->mothurOut("Maximum:\t" + toString(pref[spot].score[0])); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "Bellerophon", "print");
+ m->errorOut(e, "Bellerophon", "print");
exit(1);
}
}
}
distCalculator = new eachGapDist();
-
+cout << "fastafile = " << fastafile << endl;
//read in sequences
seqs = readSeqs(fastafile);
-
- if (unaligned) { mothurOut("Your sequences need to be aligned when you use the bellerophon method."); mothurOutEndLine(); return 1; }
+ cout << "here:"<< endl;
+ if (unaligned) { m->mothurOut("Your sequences need to be aligned when you use the bellerophon method."); m->mothurOutEndLine(); return 1; }
int numSeqs = seqs.size();
- if (numSeqs == 0) { mothurOut("Error in reading you sequences."); mothurOutEndLine(); exit(1); }
+ if (numSeqs == 0) { m->mothurOut("Error in reading you sequences."); m->mothurOutEndLine(); exit(1); }
//set default window to 25% of sequence length
string seq0 = seqs[0]->getAligned();
if (window == 0) { window = seq0.length() / 4; }
else if (window > (seq0.length() / 2)) {
- mothurOut("Your sequence length is = " + toString(seq0.length()) + ". You have selected a window size greater than the length of half your aligned sequence. I will run it with a window size of " + toString((seq0.length() / 2))); mothurOutEndLine();
+ m->mothurOut("Your sequence length is = " + toString(seq0.length()) + ". You have selected a window size greater than the length of half your aligned sequence. I will run it with a window size of " + toString((seq0.length() / 2))); m->mothurOutEndLine();
window = (seq0.length() / 2);
}
if (increment > (seqs[0]->getAlignLength() - (2*window))) {
if (increment != 10) {
- mothurOut("You have selected a increment that is too large. I will use the default."); mothurOutEndLine();
+ m->mothurOut("You have selected a increment that is too large. I will use the default."); m->mothurOutEndLine();
increment = 10;
if (increment > (seqs[0]->getAlignLength() - (2*window))) { increment = 0; }
}
catch(exception& e) {
- errorOut(e, "Bellerophon", "getChimeras");
+ m->errorOut(e, "Bellerophon", "getChimeras");
exit(1);
}
}
return 1;
}
catch(exception& e) {
- errorOut(e, "Bellerophon", "createSparseMatrix");
+ m->errorOut(e, "Bellerophon", "createSparseMatrix");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Bellerophon", "generatePreferences");
+ m->errorOut(e, "Bellerophon", "generatePreferences");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "BergerParker", "getValues");
+ m->errorOut(e, "BergerParker", "getValues");
exit(1);
}
}
#include "binsequencecommand.h"
//**********************************************************************************************************************
-BinSeqCommand::BinSeqCommand(string option){
+BinSeqCommand::BinSeqCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if (globaldata->getListFile() == "") {
- mothurOut("You must read a listfile before running the bin.seqs command.");
- mothurOutEndLine();
+ m->mothurOut("You must read a listfile before running the bin.seqs command.");
+ m->mothurOutEndLine();
abort = true;
}
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the bin.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the bin.seqs command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
//check for optional parameter and set defaults
}
}
catch(exception& e) {
- errorOut(e, "BinSeqCommand", "BinSeqCommand");
+ m->errorOut(e, "BinSeqCommand", "BinSeqCommand");
exit(1);
}
}
void BinSeqCommand::help(){
try {
- mothurOut("The bin.seqs command can only be executed after a successful read.otu command of a listfile.\n");
- mothurOut("The bin.seqs command parameters are fasta, name, label and group. The fasta parameter is required.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n");
- mothurOut("The bin.seqs command should be in the following format: bin.seqs(fasta=yourFastaFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n");
- mothurOut("Example bin.seqs(fasta=amazon.fasta, group=amazon.groups, name=amazon.names).\n");
- mothurOut("The default value for label is all lines in your inputfile.\n");
- mothurOut("The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name.\n");
- mothurOut("If you provide a groupfile, then it also appends the sequences group to the name.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
+ m->mothurOut("The bin.seqs command can only be executed after a successful read.otu command of a listfile.\n");
+ m->mothurOut("The bin.seqs command parameters are fasta, name, label and group. The fasta parameter is required.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n");
+ m->mothurOut("The bin.seqs command should be in the following format: bin.seqs(fasta=yourFastaFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n");
+ m->mothurOut("Example bin.seqs(fasta=amazon.fasta, group=amazon.groups, name=amazon.names).\n");
+ m->mothurOut("The default value for label is all lines in your inputfile.\n");
+ m->mothurOut("The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name.\n");
+ m->mothurOut("If you provide a groupfile, then it also appends the sequences group to the name.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "BinSeqCommand", "help");
+ m->errorOut(e, "BinSeqCommand", "help");
exit(1);
}
}
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
delete list;
}
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "BinSeqCommand", "execute");
+ m->errorOut(e, "BinSeqCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "BinSeqCommand", "readNamesFile");
+ m->errorOut(e, "BinSeqCommand", "readNamesFile");
exit(1);
}
}
string outputFileName = outputDir + getRootName(getSimpleName(globaldata->getListFile())) + list->getLabel() + ".fasta";
openOutputFile(outputFileName, out);
+
+ //save to output list of output file names
+ outputNames.push_back(outputFileName);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
//for each bin in the list vector
for (int i = 0; i < list->size(); i++) {
}else {//if you do have groups
string group = groupMap->getGroup(name);
if (group == "not found") {
- mothurOut(name + " is missing from your group file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(name + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
remove(outputFileName.c_str());
return 1;
}else{
}
}
}else {
- mothurOut(name + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(name + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
remove(outputFileName.c_str());
return 1;
}
}else {//if you do have groups
string group = groupMap->getGroup(binnames);
if (group == "not found") {
- mothurOut(binnames + " is missing from your group file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(binnames + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
remove(outputFileName.c_str());
return 1;
}else{
}
}
}else {
- mothurOut(binnames + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(binnames + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
remove(outputFileName.c_str());
return 1;
}
}
catch(exception& e) {
- errorOut(e, "BinSeqCommand", "process");
+ m->errorOut(e, "BinSeqCommand", "process");
exit(1);
}
}
string filename, fastafile, namesfile, groupfile, label, outputDir;
ofstream out;
ifstream in, inNames;
+ vector<string> outputNames;
void readNamesFile();
int process(ListVector*);
pairwiseLength = 0;
// string dummy;
-// while(dummy != "query:"){ mothurOut(dummy, ""); mothurOutEndLine(); blastFile >> dummy; }
+// while(dummy != "query:"){ m->mothurOut(dummy, ""); m->mothurOutEndLine(); blastFile >> dummy; }
// blastFile >> seqBend;
-// mothurOut(toString(seqBend), ""); mothurOutEndLine();
+// m->mothurOut(toString(seqBend), ""); m->mothurOutEndLine();
// for(int i=0;i<seqBend;i++){
// seqAaln += 'Z';
// seqBaln += 'X';
return topMatches;
}
catch(exception& e) {
- errorOut(e, "BlastDB", "findClosestSequences");
+ m->errorOut(e, "BlastDB", "findClosestSequences");
exit(1);
}
return topMatches;
}
catch(exception& e) {
- errorOut(e, "BlastDB", "findClosest");
+ m->errorOut(e, "BlastDB", "findClosest");
exit(1);
}
}
count++;
}
catch(exception& e) {
- errorOut(e, "BlastDB", "addSequence");
+ m->errorOut(e, "BlastDB", "addSequence");
exit(1);
}
}
void BlastDB::generateDB() {
try {
- //mothurOut("Generating the temporary BLAST database...\t"); cout.flush();
+ //m->mothurOut("Generating the temporary BLAST database...\t"); cout.flush();
path = globaldata->argv;
path = path.substr(0, (path.find_last_of('m')));
string formatdbCommand = path + "blast/bin/formatdb -p F -o T -i " + dbFileName; // format the database, -o option gives us the ability
system(formatdbCommand.c_str()); // to get the right sequence names, i think. -p F
// option tells formatdb that seqs are DNA, not prot
- //mothurOut("DONE."); mothurOutEndLine(); mothurOutEndLine(); cout.flush();
+ //m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine(); cout.flush();
}
catch(exception& e) {
- errorOut(e, "BlastDB", "generateDB");
+ m->errorOut(e, "BlastDB", "generateDB");
exit(1);
}
}
bool valid = false;
double sum = 0;
double n = (double)sabund->getNumSeqs();
- if(m==0){ m=n; }
+ if(f==0){ f=n; }
double f1 = (double)sabund->get(1);
sum = 0;
for(int j = 1; j < sabund->size(); j++) {
for (int i = 0; i < sabund->get(j); i++) {
- sum += pow(1 - j / n, n) * (1 - pow(1 - j / n, m));
+ sum += pow(1 - j / n, n) * (1 - pow(1 - j / n, f));
}
}
- sum += v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m));
+ sum += v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), f));
}
data[0] = sum;
return data;
}
catch(exception& e) {
- errorOut(e, "Boneh", "getValues");
+ m->errorOut(e, "Boneh", "getValues");
exit(1);
}
}
class Boneh : public Calculator {
public:
- Boneh(int size) : m(size), Calculator("boneh", 1, false) {};
+ Boneh(int size) : f(size), Calculator("boneh", 1, false) {};
EstOutput getValues(SAbundVector*);
EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
private:
double getV(double, double, double);
- int m;
+ int f;
};
return data;
}
catch(exception& e) {
- errorOut(e, "Bootstrap", "getValues");
+ m->errorOut(e, "Bootstrap", "getValues");
exit(1);
}
}
//**********************************************************************************************************************
-BootSharedCommand::BootSharedCommand(string option){
+BootSharedCommand::BootSharedCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the bootstrap.shared command."); mothurOutEndLine(); abort = true; }
- else if (globaldata->getGroupFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the bootstrap.shared command."); mothurOutEndLine(); abort = true; }
+ if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the bootstrap.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if (globaldata->getGroupFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the bootstrap.shared command."); m->mothurOutEndLine(); abort = true; }
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "BootSharedCommand");
+ m->errorOut(e, "BootSharedCommand", "BootSharedCommand");
exit(1);
}
}
void BootSharedCommand::help(){
try {
- mothurOut("The bootstrap.shared command can only be executed after a successful read.otu command.\n");
- mothurOut("The bootstrap.shared command parameters are groups, calc, iters and label.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
- mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like trees created for, and is also separated by dashes.\n");
- mothurOut("The bootstrap.shared command should be in the following format: bootstrap.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels, iters=yourIters).\n");
- mothurOut("Example bootstrap.shared(groups=A-B-C, calc=jabund-sorabund, iters=100).\n");
- mothurOut("The default value for groups is all the groups in your groupfile.\n");
- mothurOut("The default value for calc is jclass-thetayc. The default for iters is 1000.\n");
+ m->mothurOut("The bootstrap.shared command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The bootstrap.shared command parameters are groups, calc, iters and label.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
+ m->mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like trees created for, and is also separated by dashes.\n");
+ m->mothurOut("The bootstrap.shared command should be in the following format: bootstrap.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels, iters=yourIters).\n");
+ m->mothurOut("Example bootstrap.shared(groups=A-B-C, calc=jabund-sorabund, iters=100).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+ m->mothurOut("The default value for calc is jclass-thetayc. The default for iters is 1000.\n");
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "help");
+ m->errorOut(e, "BootSharedCommand", "help");
exit(1);
}
}
if(allLines == 1 || labels.count(order->getLabel()) == 1){
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
process(order);
processedLabels.insert(order->getLabel());
delete order;
order = input->getSharedOrderVector(lastLabel);
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
process(order);
processedLabels.insert(order->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (needToRun == true) {
if (order != NULL) { delete order; }
order = input->getSharedOrderVector(lastLabel);
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
process(order);
delete order;
//reset groups parameter
globaldata->Groups.clear();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "execute");
+ m->errorOut(e, "BootSharedCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "createTree");
+ m->errorOut(e, "BootSharedCommand", "createTree");
exit(1);
}
}
/***********************************************************/
void BootSharedCommand::printSims() {
try {
- mothurOut("simsMatrix"); mothurOutEndLine();
- for (int m = 0; m < simMatrix.size(); m++) {
+ m->mothurOut("simsMatrix"); m->mothurOutEndLine();
+ for (int k = 0; k < simMatrix.size(); k++) {
for (int n = 0; n < simMatrix.size(); n++) {
- mothurOut(simMatrix[m][n]); mothurOut("\t");
+ m->mothurOut(toString(simMatrix[k][n])); m->mothurOut("\t");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
}
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "printSims");
+ m->errorOut(e, "BootSharedCommand", "printSims");
exit(1);
}
}
//create a new filename
outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
openOutputFile(outputFile, *(out[z]));
+ outputNames.push_back(outputFile);
}
- mothurOut("Generating bootstrap trees..."); cout.flush();
+ m->mothurOut("Generating bootstrap trees..."); cout.flush();
//create a file for each calculator with the 1000 trees in it.
for (int p = 0; p < iters; p++) {
}
}
- mothurOut("\tDone."); mothurOutEndLine();
+ m->mothurOut("\tDone."); m->mothurOutEndLine();
//delete globaldata's tree
//for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
//globaldata->gTree.clear();
//create consensus trees for each bootstrapped tree set
for (int k = 0; k < trees.size(); k++) {
- mothurOut("Generating consensus tree for " + treeCalculators[k]->getName()); mothurOutEndLine();
+ m->mothurOut("Generating consensus tree for " + treeCalculators[k]->getName()); m->mothurOutEndLine();
//set global data to calc trees
globaldata->gTree = trees[k];
consensus->execute();
delete consensus;
+ outputNames.push_back(filename + ".cons.pairs");
+ outputNames.push_back(filename + ".cons.tre");
+
//delete globaldata's tree
//for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
//globaldata->gTree.clear();
}
catch(exception& e) {
- errorOut(e, "BootSharedCommand", "process");
+ m->errorOut(e, "BootSharedCommand", "process");
exit(1);
}
}
set<string> labels; //holds labels to be used
string outputFile, calc, groups, label, outputDir;
int numGroups, iters;
- vector<string> Estimators, Groups; //holds estimators to be used
+ vector<string> Estimators, Groups, outputNames; //holds estimators to be used
};
data[1] = 0.886/sqrt(rdata.size());
data[2] = 1.031/sqrt(rdata.size());
- /*mothurOut(critVal); mothurOutEndLine();
- mothurOut("If D-Statistic is less than the critical value then the data fits the Broken Stick model w/ 95% confidence.\n\n");*/
+ /*m->mothurOut(critVal); m->mothurOutEndLine();
+ m->mothurOut("If D-Statistic is less than the critical value then the data fits the Broken Stick model w/ 95% confidence.\n\n");*/
if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
return data;
}
catch(exception& e) {
- errorOut(e, "BStick", "getValues");
+ m->errorOut(e, "BStick", "getValues");
exit(1);
}
}
#include "calculator.h"
-/***********************************************************************
-void VecCalc::printElements(vector<double> vec){
- try {
- for(int i = 0; i < vec.size(); i++)
- cout << vec.at(i) << " ";
- cout << "\n\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function printElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function printElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************
-
-void VecCalc::printElements(vector<string> vec){
- try {
- for(int i = 0; i < vec.size(); i++)
- cout << vec.at(i) << " ";
- cout << "\n\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function printElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function printElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-int VecCalc::findString(vector<string> vec, string str){
- try {
- for(int i = 0; i < vec.size(); i++)
- if(str.compare(vec.at(i)) == 0)
- return i;
- return -1;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function findString. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function findString. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double VecCalc::mean(vector<double> vec){
- return sumElements(vec)/vec.size();
-}
-/***********************************************************************
-double VecCalc::stError(vector<double> vec){
- try {
- double sum = 0;
- double m = mean(vec);
- for(int i = 0; i < vec.size(); i++)
- sum += pow(vec.at(i)-m,2);
- return pow(sum/(vec.size()*(vec.size()-1)), .5);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function stError. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function stError. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
/***********************************************************************/
int VecCalc::sumElements(vector<int> vec){
- try {
return sumElements(vec,0);
- }
- catch(exception& e) {
- errorOut(e, "VecCalc", "sumElements");
- exit(1);
- }
}
/***********************************************************************/
int VecCalc::sumElements(vector<int> vec, int index){
- try {
+
int sum = 0;
for(int i = index; i < vec.size(); i++)
sum += vec.at(i);
return sum;
- }
- catch(exception& e) {
- errorOut(e, "VecCalc", "sumElements");
- exit(1);
- }
+
}
/***********************************************************************/
double VecCalc::sumElements(vector<double> vec){
- try {
double sum = 0;
for(int i = 0; i < vec.size(); i++)
sum += vec.at(i);
return sum;
- }
- catch(exception& e) {
- errorOut(e, "VecCalc", "sumElements");
- exit(1);
- }
+
}
/***********************************************************************/
double VecCalc::sumElements(vector<double> vec, int index){
- try {
+
double sum = 0;
for(int i = index; i < vec.size(); i++)
sum += vec.at(i);
return sum;
- }
- catch(exception& e) {
- errorOut(e, "VecCalc", "sumElements");
- exit(1);
- }
-}
-/***********************************************************************
-double VecCalc::findMax(vector<double> vec){
- try {
- double max = -1000000.0;
- for(int i = 0; i < vec.size(); i++)
- if(vec.at(i) > max)
- max = vec.at(i);
- return max;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function findMax. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function findMax. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
+
}
/***********************************************************************/
int VecCalc::numNZ(vector<int> vec){
- try {
+
int numNZ = 0;
for(int i = 0; i < vec.size(); i++)
if(vec.at(i) != 0)
numNZ++;
return numNZ;
- }
- catch(exception& e) {
- errorOut(e, "VecCalc", "numNZ");
- exit(1);
- }
+
}
/***********************************************************************/
double VecCalc::numNZ(vector<double> vec){
- try {
+
double numNZ = 0;
for(int i = 0; i < vec.size(); i++)
if(vec.at(i) != 0)
numNZ++;
return numNZ;
}
- catch(exception& e) {
- errorOut(e, "VecCalc", "numNZ");
- exit(1);
- }
-}
-/***********************************************************************
-double VecCalc::numPos(vector<double> vec){
- try {
- double numPos = 0;
- for(int i = 0 ; i < vec.size(); i++)
- if(vec.at(i) > 0)
- numPos++;
- return numPos;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function numPos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function numPos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double VecCalc::findMaxDiff(vector<double> vec1, vector<double> vec2){
- try {
- double maxDiff = -10000000000.0;
- for(int i = 0; i < vec1.size(); i++)
- if(fabs(vec1.at(i)-vec2.at(i)) > maxDiff)
- maxDiff = fabs(vec1.at(i)-vec2.at(i));
- return maxDiff;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function findMaxDiff. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function findMaxDiff. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double VecCalc::findDStat(vector<double> vec1, vector<double> vec2, double num){
- try {
- double mDiff = findMaxDiff(vec1, vec2);
- return (mDiff+.5)/num;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function findDStat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function findDStat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<int> VecCalc::findQuartiles(vector<double> vec){
- try {
- vector<int> quartiles;
- double max = vec.at(vec.size()-1);
- double r1 = max/4;
- double r2 = max*3/4;
- bool r1found = false;
- bool r2found = false;
- for(int i = 0; i < vec.size(); i++)
- {
- if(vec.at(i) > r1 && !r1found)
- {
- quartiles.push_back(i);
- r1found = true;
- }
- if(vec.at(i) > r2 && !r2found)
- {
- quartiles.push_back(i);
- i = vec.size();
- }
- }
- return quartiles;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function findQuartiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function findQuartiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::add(vector<double> vec, double x){
- try {
- vector<double> newVec;
- for(int i = 0; i < vec.size(); i++)
- newVec.push_back(vec.at(i)+x);
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function add. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function add. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::multiply(vector<double> vec, double x){
- try {
- vector<double> newVec;
- for(int i = 0; i < vec.size(); i++)
- newVec.push_back(vec.at(i)*x);
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function multiply. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function multiply. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::power(vector<double> vec, double p){
- try {
- vector<double> newVec;
- for(int i = 0; i < vec.size(); i++)
- newVec.push_back(pow(vec.at(i), p));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function power. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function power. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::addVecs(vector<double> vec1, vector<double> vec2) //Vectors must be the same size.
-{ try {
- vector<double> newVec;
- for(int i = 0; i < vec1.size(); i++)
- newVec.push_back(vec1.at(i)+vec2.at(i));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function addVecs. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function addVecs. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::multVecs(vector<double> vec1, vector<double> vec2) //Vectors must be the same size.
-{ try {
- vector<double> newVec;
- for(int i = 0; i < vec1.size(); i++)
- newVec.push_back(vec1.at(i)*vec2.at(i));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function multVecs. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function multVecs. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::remDup(vector<double> vec){
- try {
- vector<double> newVec;
- newVec.push_back(vec.at(0));
- for(int i = 1; i < vec.size(); i++)
- if(vec.at(i) != vec.at(i-1))
- newVec.push_back(vec.at(i));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function remDup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function remDup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::genCVec(vector<double> vec1){
- try {
- vector<double> vec2;
- double sum = 0;
- for(int i = 0; i < vec1.size(); i++)
- {
- sum += vec1.at(i);
- vec2.push_back(sum);
- }
- return vec2;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function genCVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function genCVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::genRelVec(vector<double> vec){
- try {
- vector<double> newVec;
- double sum = sumElements(vec);
- for(int i = 0; i < vec.size(); i++)
- newVec.push_back(vec.at(i)/sum);
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function genRelVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function genRelVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::genDiffVec(vector<double> vec1, vector<double> vec2){
- try {
- vector<double> newVec;
- for(int i = 0; i < vec1.size(); i++)
- newVec.push_back(vec1.at(i)-vec2.at(i));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function genDiffVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function genDiffVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::genCSVec(vector<double> vec){
- try {
- vector<double> newVec;
- double curInd = vec.at(vec.size()-1);
- double sumSpec = 0;
- double cSumSpec = 0;
- for(int i = vec.size()-1; i >= 0; i--)
- {
- if(vec.at(i) == curInd)
- sumSpec++;
- else
- {
- cSumSpec += sumSpec;
- newVec.push_back(cSumSpec);
- sumSpec = 1;
- curInd = vec.at(i);
- }
- if(i == 0)
- newVec.push_back(cSumSpec + sumSpec);
- }
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function genCSVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function genCSVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::genTotVec(vector<vector<double> > vec){
- try {
- vector<double> newVec = vec.at(0);
- for(int i = 1; i < vec.size(); i++)
- newVec = addVecs(newVec, vec.at(i));
- return newVec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function genTotVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function genTotVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<double> VecCalc::quicksort(vector<double> vec){
- try {
- sort(vec.rbegin(), vec.rend());
- return vec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function quicksort. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function quicksort. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<vector<double> > VecCalc::gen2DVec(vector<double> vec, int div, int type){
- try {
- vector<vector<double> > vec2D;
- int gap = vec.size()/div;
- for(int i = 0; i < div; i++)
- {
- vector<double> inVec;
- for(int j = 0; j < gap; j++)
- if(type == 0)
- inVec.push_back(vec.at(j + i*gap)); //Rows
- else
- inVec.push_back(vec.at(i + j*div)); //Columns
- vec2D.push_back(inVec);
- }
- return vec2D;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function gen2DVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function gen2DVec. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-vector<string> VecCalc::getSData(char name[]){
- try {
- vector<string> vec;
- string data;
- ifstream file(name);
- if(file.is_open())
- {
- while(file >> data)
- vec.push_back(data);
- file.close();
- }
- return vec;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function getSData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the VecCalc class function getSData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-
-/***********************************************************************
-void BrokenStick::doBStick(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- vec = vecCalc.quicksort(vec);
- double numInd = vecCalc.sumElements(vec);
- double numSpec = vecCalc.numNZ(vec);
- vector<double> cObsVec = vecCalc.genCVec(vec);
- vector<double> cExpVec;
- vec = vecCalc.power(vec, -1);
- double sumExp = 0;
- for(int i = 0; i < numSpec; i++)
- {
- double n = 0;
- for(int j = i; j < numSpec; j++)
- n += 1/(double)(j+1);
-
- sumExp += numInd/numSpec*n;
- cExpVec.push_back(sumExp);
- }
-
- //Statistical analysis
- double maxDiff = vecCalc.findMaxDiff(cObsVec, cExpVec);
- double DStatistic = maxDiff/numInd;
-
- cout << "D-Statistic = " << DStatistic << "\n";
- if(vec.size() > 30)
- cout << "Critical value for 95% confidence interval = " << .886/sqrt(vec.size()) << "\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the BrokenStick class Function doBStick. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the BrokenStick class function doBStick. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************
-double kEq(double k, double spec)
-{
- return k/(1-k)*pow(1-k, spec)/(1-pow(1-k, spec));
-}
-/***********************************************************************/
-/*void GeometricSeries::doGeomTest(vector<double> vec)//vec = the data vector
-{ try {
- VecCalc vecCalc;
- vec = vecCalc.quicksort(vec);//Sorts vec
- double numInd = vecCalc.sumElements(vec);//numInd = The total number of individuals in the data set.
- double numSpec = vecCalc.numNZ(vec);//numSpec = the number of nonzero elements in the data set.
- double min = -1.0*vecCalc.findMax(vecCalc.multiply(vec, -1));
- double k = .5;
- double step = .49999;
- while(fabs(min - numInd*kEq(k, numSpec)) > .0001)//This uses a binary search to find the value of k.
- {
- if(numInd*kEq(k, numSpec) > min)
- k += step;
- else
- k -= step;
- step /= 2;
- }
- cout << "k = " << k << "\n";
- double cK = 1/(1-pow(1-k, numSpec));
-
- vector<double> cObsVec = vecCalc.genCVec(vec);
- vector<double> cExpVec;
- double sumExp = 0;
- for(int i = 0; i < vec.size(); i++)
- {
- sumExp += numInd*cK*k*pow(1-k, i);
- cExpVec.push_back(sumExp);
- }
- double maxDiff = vecCalc.findMaxDiff(cObsVec, cExpVec);
- double DStatistic = maxDiff/numInd;
-
- //Statistical Analysis
- cout << "D-Statistic = " << DStatistic << "\n";
- if(vec.size() > 30)
- cout << "Critical value for 95% confidence interval = " << .886/sqrt(vec.size()) << "\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GeometricSeries class Function doGeomTest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GeometricSeries class function doGeomTest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}*/
-
-/***********************************************************************
-void Jackknifing::doJK(vector<double> vec, double cols)//vec = the data vector if the data table was read left-to-right, top-to-bottom. cols = The number of columns in the data table.
-{ try {
- VecCalc vecCalc;
- SSBPDiversityIndices ssbp;
- double rows = vec.size()/cols;
- vector<vector<double> > species = vecCalc.gen2DVec(vec, rows, 0);//converts vec into a 2 dimensional vector
- vector<double> sumRows;
- vector<double> pVals;
-
- for(int i = 0; i < rows; i++)
- sumRows.push_back(vecCalc.sumElements(species.at(i)));
- double st = 1/ssbp.getSimp(sumRows);//The observed estimate using the Simpson Index. Can be changed to use other indexes of diversity.
- for(int i = 0; i < cols; i++)
- {
- vector<double> newVec;
- for(int j = 0; j < rows; j++)
- newVec.push_back(vecCalc.sumElements(species.at(j))-species.at(j).at(i));
- pVals.push_back(cols*st-((cols-1)/ssbp.getSimp(newVec)));
- }
-
- double mean = vecCalc.mean(pVals);
- double stErr = vecCalc.stError(pVals);//stErr = standard error
- TDTable table;
- double confidence = .95;
- double confLimit;
- cout << "Confidence Level (.8, .9, .95, .98, .99, .998, .999): ";
- cin >> confidence;
- double confLevels[] = {.80,.90,.95,.98,.99,.998,.999};
- for(int i = 0; i < 7; i++)
- if(confidence == confLevels[i])
- {
- confLimit = table.getConfLimit(cols-2,i);
- i = 7;
- }
-
- //Statistical Analysis
- cout << "Lower limit = " << mean - confLimit*stErr << "\n";
- cout << "Upper limit = " << mean + confLimit*stErr << "\n";
- cout << "Observed estimate = " << st << "\n\n";
- cout << "Jackknifed estimate = " << mean << "\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the Jackknifing class Function doJK. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the Jackknifing class function doJK. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-void KS2SampleTest::doKSTest(vector<double> abun1, vector<double> abun2)//abun1 = 1st vector of abundances, abun2 = 2nd vector of abundances
-{ try {
- VecCalc vecCalc;
- double numNZ1 = vecCalc.numNZ(abun1);//Number of nonzero elements in abun1
- double numNZ2 = vecCalc.numNZ(abun2);//Number of nonzero elements in abun2
- abun1 = vecCalc.quicksort(abun1);//Sorts abun1
- abun2 = vecCalc.quicksort(abun2);//Sorts abun2
- abun1 = vecCalc.genRelVec(abun1);//Generates the relative vector for abun1
- abun2 = vecCalc.genRelVec(abun2);//Generates the relative vector for abun2
-
- abun1 = vecCalc.genCVec(abun1);//Generates the cumulative vector for abun1
- abun2 = vecCalc.genCVec(abun2);//Generates the cumulative vector for abun2
-
- double maxDiff = vecCalc.findMaxDiff(abun1, abun2);
- double DStatistic = maxDiff*numNZ1*numNZ2;
-
- cout << "Null Hypothesis = There is no difference.\n";
- cout << "D-Statistic = " << DStatistic << "\n";
-
- double a = pow((numNZ1 + numNZ2)/(numNZ1*numNZ2),.5);
- double pVal = exp(-2*pow(maxDiff/a,2));
-
- if(numNZ1 > 25 && numNZ2 > 25) //If the sample sizes are both bigger than 25.
- cout << "P-Value = " << pVal << "\n\n";
- else
- {
- cout << "D-Statistic must be higher than the critical value to reject the null hypothesis.\n" ;
- cout << "90% Confidence Critical Value = " << 1.22*a*numNZ1*numNZ2 << "\n";
- cout << "95% Confidence Critical Value = " << 1.36*a*numNZ1*numNZ2 << "\n";
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the KS2SampleTest class Function doKSTest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the KS2SampleTest class function doKSTest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************
-
-void QStatistic::doQStat(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- vector<double> cVec = vecCalc.genCSVec(vec);
- vector<int> q = vecCalc.findQuartiles(cVec);//q.at(0) is the index of the first quartile; q.at(1) is the index of the second quartile.
- vector<double> nDupVec = vecCalc.remDup(vec);//nDupVec only contains one of every unique element in cVec.
- double Q;
- if(q.at(0) != 0)//The case if neither quartile is 0 or 1
- Q = (.5*(cVec.at(q.at(0))-cVec.at(q.at(0)-1)) + (cVec.at(q.at(1)-1)-cVec.at(q.at(0))) + .5*(cVec.at(q.at(1))-cVec.at(q.at(1)-1)))/log(nDupVec.at(nDupVec.size()-1-q.at(1))/nDupVec.at(nDupVec.size()-1-q.at(0)));
- else if(q.at(0) == 0 && (q.at(1) == 0 || q.at(1) == 1))//The case if the quartiles are both at index 0 or one is at 0 and the other at 1.
- Q = (.5*cVec.at(0) + .5*(cVec.at(1)-cVec.at(0)))/log(nDupVec.at(nDupVec.size()-2)/nDupVec.at(nDupVec.size()-1));
- else if(q.at(0) == 0 && q.at(1) > 1) //The case if the lower quartile is at index 0 and upper quartile index is above index 1.
- Q = (.5*cVec.at(0) + (cVec.at(q.at(1)-1)-cVec.at(q.at(0))) + .5*(cVec.at(q.at(1))-cVec.at(q.at(1)-1)))/log(nDupVec.at(nDupVec.size()-1-q.at(1))/nDupVec.at(nDupVec.size()-1));
-
- cout << "Q = " << Q << "\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the QStatistic class Function doQStat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the QStatistic class function doQStat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double SSBPDiversityIndices::getShan(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- double nz = vecCalc.numNZ(vec);
- double nSum = vecCalc.sumElements(vec);
- double H = 0;
- for(int i = 0; i < nz; i++)
- H += vec.at(i)/nSum*log(vec.at(i)/nSum);
- H *= -1;
- return H;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SSBPDiversityIndices class Function getShan. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SSBPDiversityIndices class function getShan. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double SSBPDiversityIndices::getSimp(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- double nSum = vecCalc.sumElements(vec);
- double D = 0;
- for(int j = 0; j < vec.size(); j++)
- D += vec.at(j)*(vec.at(j)-1)/(nSum*(nSum-1));
- return D;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SSBPDiversityIndices class Function getSimp. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SSBPDiversityIndices class function getSimp. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-double SSBPDiversityIndices::getBP(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- double nSum = vecCalc.sumElements(vec);
- return vecCalc.findMax(vec)/nSum;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SSBPDiversityIndices class Function getBP. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SSBPDiversityIndices class function getBP. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-void SSBPDiversityIndices::doSSBP(vector<double> vec)//vec = The data vector.
-{ try {
- VecCalc vecCalc;
- double nz = vecCalc.numNZ(vec);
-
- //Shannon index
- double H = getShan(vec);
- cout << "H = " << H << "\n";
- cout << "Eveness = " << H/log(nz) << "\n\n";
-
- //Simpson index
- double D = getSimp(vec);
- cout << "D diversity = " << 1/D << "\n";
- cout << "Eveness = " << 1/D/nz << "\n\n";
-
- //Berger-Parker index
- double BP = getBP(vec);
- cout << "BP index = " << BP << "\n\n";
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SSBPDiversityIndices class Function doSSBP. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SSBPDiversityIndices class function doSSBP. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
/***********************************************************************/
double TDTable::getConfLimit(int row, int col) //Rows are the degrees of freedom
-{ try {
+{
//Found on http://www.vgtu.lt/leidiniai/elektroniniai/Probability.pdf/Table%203.pdf
//Confidence Level .90 .95 .975 .99 .995 .999 .9995
{1.310, 1.697, 2.042, 2.457, 2.750, 3.385, 3.646}};
return values[row][col];
- }
- catch(exception& e) {
- errorOut(e, "TDTable", "getConfLimit");
- exit(1);
- }
+
}
-/***********************************************************************
-double KOSTable::getConfLimit(int index) //Table of Critical values for N = 4-20 for One-Sample Kolmogorov-Smirnov Test
-{ try {
- //Confidence Level = .05
- //Sample size = 4-20.
- //Found on http://www.utdallas.edu/~herve/MolinAbdi1998-LillieforsTechReport.pdf
+/***********************************************************************/
- double values[21] = {.9011,
- .6372,
- .5203,
- .4506,
- 0.3754,
- 0.3427,
- 0.3245,
- 0.3041,
- 0.2875,
- 0.2744,
- 0.2616,
- 0.2506,
- 0.2426,
- 0.2337,
- 0.2257,
- 0.2196,
- 0.2128,
- 0.2071,
- 0.2018,
- 0.1965,
- 0.1920,
- };
- return values[index];
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the TDTable class Function getConfLimit. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the TDTable class function getConfLimit. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/***********************************************************************
-void TrunLN::doTrunLN(vector<double> indVec, vector<double> specVec) //indVec = individuals vector, specVec = species vector
-{
- VecCalc vecCalc;
- double numSpec = vecCalc.sumElements(specVec); //numSpec = The total number of species
- double numInd = vecCalc.sumElements(vecCalc.multVecs(indVec,specVec)); //numInd = The total number of individuals
-
- double obsMean = 0;
- for(int i = 0; i < indVec.size(); i++)
- obsMean += log10(indVec.at(i));
- obsMean /= numSpec; //obsMean = observed mean of the individuals vector
- cout << "obsMean = " << obsMean << "\n";
- double variance = 0;
- for(int t = 0; t < indVec.size(); t++)
- variance += pow(log10(indVec.at(t))-obsMean,2)/numSpec;
-
- double rO = 0;
- for(int k = 0; k < indVec.size(); k++)
- rO += log10(indVec.at(k));
- rO /= indVec.size();
- double veilLine = .5;//The desired veil line.
- double auxFunc = -(obsMean-rO)/(obsMean-log10(veilLine));
- double uX = obsMean-auxFunc*(obsMean-log10(veilLine));
- double vX = variance + auxFunc*pow(obsMean-log10(veilLine),2);
- double z = (log10(veilLine)-uX)/pow(vX, .5);
- double p = .5*(erf(z)+1);
- double specRichness = numSpec/(1-p);
-
- double numUnseen = .5*(erf((log10(.5)-uX)/pow(vX,.5))+1)*specRichness;
-
-
- vector<double> cExp;
- for(int i = 1; i < 8; i++)
- {
- double a = pow(10, i-1)+.5;
- double b = log10(a);
- double c = (b - uX)/pow(vX,.5);
- double d = .5*(erf(c)+1);
- double numS = d*specRichness;
- double toPush = numS - numUnseen;
- cExp.push_back(toPush);
- }
- vector<double> cObs;
- double sumOct = 0;
- for(int i = 0; i < 8; i++)
- {
- sumOct = 0;
- for(int r = 0; r < indVec.size(); r++)
- {
- if(indVec.at(r) < pow(10, i-1)+.5)
- sumOct += specVec.at(r);
- else
- {
- cObs.push_back(sumOct);
- sumOct = specVec.at(r);
- r = indVec.size();
- }
- if(r == indVec.size()-1)
- cObs.push_back(sumOct);
- }
- }
- //Statistical Analysis
- double d = vecCalc.findDStat(cExp, cObs, numSpec);
- cout << "DStat = " << d << "\n";
- cout << ".05 confidence value = " << .89196/sqrt(numSpec) << "\n";
- cout << ".01 confidence value = " << 1.0471/sqrt(numSpec) << "\n\n";
-}
-/***********************************************************************/
#include "sharedsabundvector.h"
#include "rabundvector.hpp"
#include "uvest.h"
+#include "mothurout.h"
/* The calculator class is the parent class for all the different estimators implemented in mothur except the tree calculators.
It has 2 pure functions EstOutput getValues(SAbundVector*), which works on a single group, and
class Calculator {
public:
- Calculator(){};
+ Calculator(){ m = MothurOut::getInstance(); }
virtual ~Calculator(){};
- Calculator(string n, int c, bool m) : name(n), cols(c), multiple(m) {};
+ Calculator(string n, int c, bool f) : name(n), cols(c), multiple(f) {};
virtual EstOutput getValues(SAbundVector*) = 0;
virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
virtual void print(ostream& f) { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
virtual int getCols() { return cols; }
virtual bool getMultiple() { return multiple; }
protected:
+ MothurOut* m;
EstOutput data;
string name;
int cols;
void Ccode::print(ostream& out, ostream& outAcc) {
try {
- mothurOutEndLine();
-
ofstream out2;
openOutputFileAppend(mapInfo, out2);
out << endl;
if (results) {
- mothurOut(querySeq->getName() + " was found have at least one chimeric window."); mothurOutEndLine();
+ m->mothurOut(querySeq->getName() + " was found have at least one chimeric window."); m->mothurOutEndLine();
outAcc << querySeq->getName() << endl;
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "print");
+ m->errorOut(e, "Ccode", "print");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "Ccode", "getChimeras");
+ m->errorOut(e, "Ccode", "getChimeras");
exit(1);
}
}
//check to make sure that is not whole seq
- if ((rearPos - frontPos - 1) <= 0) { mothurOut("Error, when I trim your sequences, the entire sequence is trimmed."); mothurOutEndLine(); exit(1); }
+ if ((rearPos - frontPos - 1) <= 0) { m->mothurOut("Error, when I trim your sequences, the entire sequence is trimmed."); m->mothurOutEndLine(); exit(1); }
map<int, int> tempTrim;
tempTrim[frontPos] = rearPos;
spotMap = newMap;
}
catch(exception& e) {
- errorOut(e, "Ccode", "trimSequences");
+ m->errorOut(e, "Ccode", "trimSequences");
exit(1);
}
}
//default is wanted = 10% of total length
if (windowSizes > length) {
- mothurOut("You have slected a window larger than your sequence length after all filters, masks and trims have been done. I will use the default 10% of sequence length.");
+ m->mothurOut("You have slected a window larger than your sequence length after all filters, masks and trims have been done. I will use the default 10% of sequence length.");
windowSizes = length / 10;
}else if (windowSizes == 0) { windowSizes = length / 10; }
else if (windowSizes > (length * 0.20)) {
- mothurOut("You have selected a window that is larger than 20% of your sequence length. This is not recommended, but I will continue anyway."); mothurOutEndLine();
+ m->mothurOut("You have selected a window that is larger than 20% of your sequence length. This is not recommended, but I will continue anyway."); m->mothurOutEndLine();
}else if (windowSizes < (length * 0.05)) {
- mothurOut("You have selected a window that is smaller than 5% of your sequence length. This is not recommended, but I will continue anyway."); mothurOutEndLine();
+ m->mothurOut("You have selected a window that is smaller than 5% of your sequence length. This is not recommended, but I will continue anyway."); m->mothurOutEndLine();
}
//save starting points of each window
return win;
}
catch(exception& e) {
- errorOut(e, "Ccode", "findWindows");
+ m->errorOut(e, "Ccode", "findWindows");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "getDiff");
+ m->errorOut(e, "Ccode", "getDiff");
exit(1);
}
}
seqs = goodSeqs;
}else { //warn, but dont remove any
- mothurOut(querySeq->getName() + " does not have an adaquate number of reference sequences that are within 20% and 0.5% similarity. I will continue, but please check."); mothurOutEndLine();
+ m->mothurOut(querySeq->getName() + " does not have an adaquate number of reference sequences that are within 20% and 0.5% similarity. I will continue, but please check."); m->mothurOutEndLine();
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "removeBadReferenceSeqs");
+ m->errorOut(e, "Ccode", "removeBadReferenceSeqs");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "findClosestSides");
+ m->errorOut(e, "Ccode", "findClosestSides");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "getAverageRef");
+ m->errorOut(e, "Ccode", "getAverageRef");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "getAverageQuery");
+ m->errorOut(e, "Ccode", "getAverageQuery");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "findVarianceRef");
+ m->errorOut(e, "Ccode", "findVarianceRef");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "findVarianceQuery");
+ m->errorOut(e, "Ccode", "findVarianceQuery");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Ccode", "determineChimeras");
+ m->errorOut(e, "Ccode", "determineChimeras");
exit(1);
}
}
else if (numseq > 2) tvalue = 2.353;
else if (numseq > 1) tvalue = 2.920;
else if (numseq <= 1) {
- mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); mothurOutEndLine();
+ m->mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); m->mothurOutEndLine();
}
return tvalue;
}
catch(exception& e) {
- errorOut(e, "Ccode", "getT");
+ m->errorOut(e, "Ccode", "getT");
exit(1);
}
}
else if (numseq > 1) fvalue = 18.5;
else if (numseq > 0) fvalue = 161;
else if (numseq <= 0) {
- mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); mothurOutEndLine();
+ m->mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); m->mothurOutEndLine();
}
return fvalue;
}
catch(exception& e) {
- errorOut(e, "Ccode", "getF");
+ m->errorOut(e, "Ccode", "getF");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Chao1", "getValues");
+ m->errorOut(e, "Chao1", "getValues");
exit(1);
}
}
//cout << "a = " << a[i] << " t = " << t[i] << " g = " << g[i] << " c = " << c[i] << endl;
}
- mothurOut("Filter removed " + toString(numColRemoved) + " columns."); mothurOutEndLine();
+ m->mothurOut("Filter removed " + toString(numColRemoved) + " columns."); m->mothurOutEndLine();
return filterString;
}
catch(exception& e) {
- errorOut(e, "Chimera", "createFilter");
+ m->errorOut(e, "Chimera", "createFilter");
exit(1);
}
}
return maskMap;
}
catch(exception& e) {
- errorOut(e, "Chimera", "runFilter");
+ m->errorOut(e, "Chimera", "runFilter");
exit(1);
}
}
vector<Sequence*> Chimera::readSeqs(string file) {
try {
- mothurOut("Reading sequences... "); cout.flush();
+ m->mothurOut("Reading sequences... "); cout.flush();
ifstream in;
openInputFile(file, in);
+
vector<Sequence*> container;
int count = 0;
length = 0;
}
in.close();
- mothurOut("Done."); mothurOutEndLine();
+ m->mothurOut("Done."); m->mothurOutEndLine();
return container;
}
catch(exception& e) {
- errorOut(e, "Chimera", "readSeqs");
+ m->errorOut(e, "Chimera", "readSeqs");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Chimera", "setMask");
+ m->errorOut(e, "Chimera", "setMask");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Chimera", "readQuantiles");
+ m->errorOut(e, "Chimera", "readQuantiles");
exit(1);
}
}
}
}
- if(spot == -1) { mothurOut("Error: Could not find sequence."); mothurOutEndLine(); return NULL; }
+ if(spot == -1) { m->mothurOut("Error: Could not find sequence."); m->mothurOutEndLine(); return NULL; }
temp = new Sequence(templateSeqs[spot]->getName(), templateSeqs[spot]->getAligned());
return temp;
}
catch(exception& e) {
- errorOut(e, "Chimera", "getSequence");
+ m->errorOut(e, "Chimera", "getSequence");
exit(1);
}
}
public:
- Chimera(){};
- Chimera(string);
- Chimera(string, bool, string);
- Chimera(string, string);
+ Chimera(){ m = MothurOut::getInstance(); }
+ Chimera(string) { m = MothurOut::getInstance(); }
+ Chimera(string, bool, string) { m = MothurOut::getInstance(); }
+ Chimera(string, string) { m = MothurOut::getInstance(); }
virtual ~Chimera(){ for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i]; } };
virtual void setFilter(bool f) { filter = f; }
virtual void setCorrection(bool c) { correction = c; }
float divR;
string seqMask, quanfile, filterString, name, outputDir, templateFileName;
Sequence* getSequence(string); //find sequence from name
+ MothurOut* m;
};
/***********************************************************************/
delete kmer;
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "~AlignSim");
+ m->errorOut(e, "ChimeraCheckRDP", "~AlignSim");
exit(1);
}
}
void ChimeraCheckRDP::print(ostream& out, ostream& outAcc) {
try {
- mothurOut("Processing: " + querySeq->getName()); mothurOutEndLine();
+ m->mothurOut("Processing: " + querySeq->getName()); m->mothurOutEndLine();
out << querySeq->getName() << endl;
out << "IS scores: " << '\t';
}
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "print");
+ m->errorOut(e, "ChimeraCheckRDP", "print");
exit(1);
}
}
void ChimeraCheckRDP::doPrep() {
try {
templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0);
- mothurOutEndLine();
+ m->mothurOutEndLine();
kmer = new Kmer(kmerSize);
}
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "doPrep");
+ m->errorOut(e, "ChimeraCheckRDP", "doPrep");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "getChimeras");
+ m->errorOut(e, "ChimeraCheckRDP", "getChimeras");
exit(1);
}
}
int start = seq.length() / 10;
//for each window
- for (int m = start; m < (seq.length() - start); m+=increment) {
+ for (int f = start; f < (seq.length() - start); f+=increment) {
- if ((m - kmerSize) < 0) { mothurOut("Your sequence is too short for your kmerSize."); mothurOutEndLine(); exit(1); }
+ if ((f - kmerSize) < 0) { m->mothurOut("Your sequence is too short for your kmerSize."); m->mothurOutEndLine(); exit(1); }
sim temp;
- string fragLeft = seq.substr(0, m); //left side of breakpoint
- string fragRight = seq.substr(m); //right side of breakpoint
+ string fragLeft = seq.substr(0, f); //left side of breakpoint
+ string fragRight = seq.substr(f); //right side of breakpoint
//make a sequence of the left side and right side
Sequence* left = new Sequence(queryName, fragLeft);
//right side is tricky - since the counts grow on eachother to find the correct counts of only the right side you must subtract the counts of the left side
//iterate through left sides map to subtract the number of times you saw things before you got the the right side
map<int, int> rightside = queryKmerInfo[queryKmerInfo.size()-1];
- for (map<int, int>::iterator itleft = queryKmerInfo[m-kmerSize].begin(); itleft != queryKmerInfo[m-kmerSize].end(); itleft++) {
+ for (map<int, int>::iterator itleft = queryKmerInfo[f-kmerSize].begin(); itleft != queryKmerInfo[f-kmerSize].end(); itleft++) {
int howManyTotal = queryKmerInfo[queryKmerInfo.size()-1][itleft->first]; //times that kmer was seen in total
//itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
}
map<int, int> closerightside = closeRightKmerInfo[closeRightKmerInfo.size()-1];
- for (map<int, int>::iterator itright = closeRightKmerInfo[m-kmerSize].begin(); itright != closeRightKmerInfo[m-kmerSize].end(); itright++) {
+ for (map<int, int>::iterator itright = closeRightKmerInfo[f-kmerSize].begin(); itright != closeRightKmerInfo[f-kmerSize].end(); itright++) {
int howManyTotal = closeRightKmerInfo[(closeRightKmerInfo.size()-1)][itright->first]; //times that kmer was seen in total
//itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
}
- int nLeft = calcKmers(closeLeftKmerInfo[m-kmerSize], queryKmerInfo[m-kmerSize]);
+ int nLeft = calcKmers(closeLeftKmerInfo[f-kmerSize], queryKmerInfo[f-kmerSize]);
int nRight = calcKmers(closerightside, rightside);
temp.leftParent = closestLeft.getName();
temp.rightParent = closestRight.getName();
temp.score = is;
- temp.midpoint = m;
+ temp.midpoint = f;
isValues.push_back(temp);
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "findIS");
+ m->errorOut(e, "ChimeraCheckRDP", "findIS");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "readName");
+ m->errorOut(e, "ChimeraCheckRDP", "readName");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "calcKmers");
+ m->errorOut(e, "ChimeraCheckRDP", "calcKmers");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
+ m->errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
exit(1);
}
}
#include "nast.hpp"
//***************************************************************************************************************
-ChimeraReAligner::ChimeraReAligner(vector<Sequence*> t, int m, int mm) : match(m), misMatch(mm) { templateSeqs = t; }
+ChimeraReAligner::ChimeraReAligner(vector<Sequence*> t, int ms, int mm) : match(ms), misMatch(mm) { templateSeqs = t; m = MothurOut::getInstance(); }
//***************************************************************************************************************
ChimeraReAligner::~ChimeraReAligner() {}
//***************************************************************************************************************
}
catch(exception& e) {
- errorOut(e, "ChimeraReAligner", "reAlign");
+ m->errorOut(e, "ChimeraReAligner", "reAlign");
exit(1);
}
}
}
}
- if(spot == -1) { mothurOut("Error: Could not find sequence."); mothurOutEndLine(); return NULL; }
+ if(spot == -1) { m->mothurOut("Error: Could not find sequence."); m->mothurOutEndLine(); return NULL; }
temp = new Sequence(templateSeqs[spot]->getName(), templateSeqs[spot]->getAligned());
return temp;
}
catch(exception& e) {
- errorOut(e, "ChimeraReAligner", "getSequence");
+ m->errorOut(e, "ChimeraReAligner", "getSequence");
exit(1);
}
}
int match, misMatch;
Sequence* getSequence(string); //find sequence from name
+ MothurOut* m;
};
/***********************************************************/
//***************************************************************************************************************
-ChimeraSeqsCommand::ChimeraSeqsCommand(string option){
+ChimeraSeqsCommand::ChimeraSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
- else if (fastafile == "not found") { fastafile = ""; mothurOut("fasta is a required parameter for the chimera.seqs command."); mothurOutEndLine(); abort = true; }
+ else if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.seqs command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
else if (temp == "not found") { temp = "20"; }
convert(temp, numwanted);
- if ((search != "distance") && (search != "blast") && (search != "kmer")) { mothurOut(search + " is not a valid search."); mothurOutEndLine(); abort = true; }
+ if ((search != "distance") && (search != "blast") && (search != "kmer")) { m->mothurOut(search + " is not a valid search."); m->mothurOutEndLine(); abort = true; }
- if (((method != "bellerophon")) && (templatefile == "")) { mothurOut("You must provide a template file with the pintail, ccode, chimeraslayer or chimeracheck methods."); mothurOutEndLine(); abort = true; }
+ if (((method != "bellerophon")) && (templatefile == "")) { m->mothurOut("You must provide a template file with the pintail, ccode, chimeraslayer or chimeracheck methods."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "ChimeraSeqsCommand");
+ m->errorOut(e, "ChimeraSeqsCommand", "ChimeraSeqsCommand");
exit(1);
}
}
try {
//"fasta", "filter", "correction", "processors", "method", "window", "increment", "template", "conservation", "quantile", "mask", "numwanted", "ksize", "svg", "name"
- //mothurOut("chimera.seqs ASSUMES that your sequences are ALIGNED and if using a template that the template file sequences are the same length as the fasta file sequences.\n\n");
- mothurOut("The chimera.seqs command reads a fastafile and creates list of potentially chimeric sequences.\n");
- mothurOut("The chimera.seqs command parameters are fasta, filter, correction, processors, mask, method, window, increment, template, conservation, quantile, numwanted, ksize, svg, name, iters, search, realign.\n");
- mothurOut("The fasta parameter is always required and template is required if using pintail, ccode or chimeracheck.\n");
- mothurOut("The filter parameter allows you to specify if you would like to apply a vertical and 50% soft filter. \n");
- mothurOut("The correction parameter allows you to put more emphasis on the distance between highly similar sequences and less emphasis on the differences between remote homologs.\n");
- mothurOut("The processors parameter allows you to specify how many processors you would like to use. The default is 1. \n");
- mothurOut("The method parameter allows you to specify the method for finding chimeric sequences. The default is pintail. Options include bellerophon, ccode and chimeracheck \n");
- mothurOut("The mask parameter allows you to specify a file containing one sequence you wish to use as a mask for the your sequences. \n");
- mothurOut("The window parameter allows you to specify the window size for searching for chimeras. \n");
- mothurOut("The increment parameter allows you to specify how far you move each window while finding chimeric sequences.\n");
- mothurOut("The template parameter allows you to enter a template file containing known non-chimeric sequences. \n");
- mothurOut("The conservation parameter allows you to enter a frequency file containing the highest bases frequency at each place in the alignment.\n");
- mothurOut("The quantile parameter allows you to enter a file containing quantiles for a template files sequences.\n");
- mothurOut("The numwanted parameter allows you to specify how many sequences you would each query sequence compared with.\n");
- mothurOut("The ksize parameter allows you to input kmersize. \n");
- mothurOut("The svg parameter allows you to specify whether or not you would like a svg file outputted for each query sequence.\n");
- mothurOut("The name parameter allows you to enter a file containing names of sequences you would like .svg files for.\n");
- mothurOut("The iters parameter allows you to specify the number of bootstrap iters to do with the chimeraslayer method.\n");
- mothurOut("The minsim parameter allows you .... \n");
- mothurOut("The mincov parameter allows you to specify minimum coverage by closest matches found in template. Default is 70, meaning 70%. \n");
- mothurOut("The minbs parameter allows you to specify minimum bootstrap support for calling a sequence chimeric. Default is 90, meaning 90%. \n");
- mothurOut("The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) \n");
- mothurOut("The search parameter allows you to specify search method for finding the closest parent. Choices are distance, blast, and kmer, default distance. -used only by chimeraslayer. \n");
- mothurOut("The realign parameter allows you to realign the query to the potential paretns. Choices are true or false, default false. -used only by chimeraslayer. \n");
- mothurOut("NOT ALL PARAMETERS ARE USED BY ALL METHODS. Please look below for method specifics.\n\n");
- mothurOut("Details for each method: \n");
- mothurOut("\tpintail: \n");
- mothurOut("\t\tparameters: fasta=required, template=required, filter=F, mask=no mask, processors=1, window=300, increment=25, conservation=not required, but will improve speed, quantile=not required, but will greatly improve speed. \n");
- mothurOut("\t\tIf you have run chimera.seqs using pintail a .quan and .freq file will be created for your template, if you have not provided them for use in future command executions.\n");
- mothurOut("\tbellerophon: \n");
- mothurOut("\t\tparameters: fasta=required, filter=F, processors=1, window=1/4 length of seq, increment=25, correction=T. \n");
- mothurOut("\tccode: \n");
- mothurOut("\t\tparameters: fasta=required, template=required, filter=F, mask=no mask, processors=1, window=10% of length, numwanted=20\n");
- mothurOut("\tchimeracheck: \n");
- mothurOut("\t\tparameters: fasta=required, template=required, processors=1, increment=10, ksize=7, svg=F, name=none\n\n");
- mothurOut("\tchimeraslayer: \n");
- mothurOut("\t\tparameters: fasta=required, template=required, processors=1, increment=10, mask=no mask, numwanted=10, match=5, mismatch=-4, divergence=1.0, minsim=90, parents=5, iters=1000, window=100. \n\n");
- mothurOut("The chimera.seqs command should be in the following format: \n");
- mothurOut("chimera.seqs(fasta=yourFastaFile, filter=yourFilter, correction=yourCorrection, processors=yourProcessors, method=bellerophon) \n");
- mothurOut("Example: chimera.seqs(fasta=AD.align, filter=True, correction=true, method=bellerophon, window=200) \n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
+ //m->mothurOut("chimera.seqs ASSUMES that your sequences are ALIGNED and if using a template that the template file sequences are the same length as the fasta file sequences.\n\n");
+ m->mothurOut("The chimera.seqs command reads a fastafile and creates list of potentially chimeric sequences.\n");
+ m->mothurOut("The chimera.seqs command parameters are fasta, filter, correction, processors, mask, method, window, increment, template, conservation, quantile, numwanted, ksize, svg, name, iters, search, realign.\n");
+ m->mothurOut("The fasta parameter is always required and template is required if using pintail, ccode or chimeracheck.\n");
+ m->mothurOut("The filter parameter allows you to specify if you would like to apply a vertical and 50% soft filter. \n");
+ m->mothurOut("The correction parameter allows you to put more emphasis on the distance between highly similar sequences and less emphasis on the differences between remote homologs.\n");
+ m->mothurOut("The processors parameter allows you to specify how many processors you would like to use. The default is 1. \n");
+ m->mothurOut("The method parameter allows you to specify the method for finding chimeric sequences. The default is pintail. Options include bellerophon, ccode and chimeracheck \n");
+ m->mothurOut("The mask parameter allows you to specify a file containing one sequence you wish to use as a mask for the your sequences. \n");
+ m->mothurOut("The window parameter allows you to specify the window size for searching for chimeras. \n");
+ m->mothurOut("The increment parameter allows you to specify how far you move each window while finding chimeric sequences.\n");
+ m->mothurOut("The template parameter allows you to enter a template file containing known non-chimeric sequences. \n");
+ m->mothurOut("The conservation parameter allows you to enter a frequency file containing the highest bases frequency at each place in the alignment.\n");
+ m->mothurOut("The quantile parameter allows you to enter a file containing quantiles for a template files sequences.\n");
+ m->mothurOut("The numwanted parameter allows you to specify how many sequences you would each query sequence compared with.\n");
+ m->mothurOut("The ksize parameter allows you to input kmersize. \n");
+ m->mothurOut("The svg parameter allows you to specify whether or not you would like a svg file outputted for each query sequence.\n");
+ m->mothurOut("The name parameter allows you to enter a file containing names of sequences you would like .svg files for.\n");
+ m->mothurOut("The iters parameter allows you to specify the number of bootstrap iters to do with the chimeraslayer method.\n");
+ m->mothurOut("The minsim parameter allows you .... \n");
+ m->mothurOut("The mincov parameter allows you to specify minimum coverage by closest matches found in template. Default is 70, meaning 70%. \n");
+ m->mothurOut("The minbs parameter allows you to specify minimum bootstrap support for calling a sequence chimeric. Default is 90, meaning 90%. \n");
+ m->mothurOut("The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) \n");
+ m->mothurOut("The search parameter allows you to specify search method for finding the closest parent. Choices are distance, blast, and kmer, default distance. -used only by chimeraslayer. \n");
+ m->mothurOut("The realign parameter allows you to realign the query to the potential paretns. Choices are true or false, default false. -used only by chimeraslayer. \n");
+ m->mothurOut("NOT ALL PARAMETERS ARE USED BY ALL METHODS. Please look below for method specifics.\n\n");
+ m->mothurOut("Details for each method: \n");
+ m->mothurOut("\tpintail: \n");
+ m->mothurOut("\t\tparameters: fasta=required, template=required, filter=F, mask=no mask, processors=1, window=300, increment=25, conservation=not required, but will improve speed, quantile=not required, but will greatly improve speed. \n");
+ m->mothurOut("\t\tIf you have run chimera.seqs using pintail a .quan and .freq file will be created for your template, if you have not provided them for use in future command executions.\n");
+ m->mothurOut("\tbellerophon: \n");
+ m->mothurOut("\t\tparameters: fasta=required, filter=F, processors=1, window=1/4 length of seq, increment=25, correction=T. \n");
+ m->mothurOut("\tccode: \n");
+ m->mothurOut("\t\tparameters: fasta=required, template=required, filter=F, mask=no mask, processors=1, window=10% of length, numwanted=20\n");
+ m->mothurOut("\tchimeracheck: \n");
+ m->mothurOut("\t\tparameters: fasta=required, template=required, processors=1, increment=10, ksize=7, svg=F, name=none\n\n");
+ m->mothurOut("\tchimeraslayer: \n");
+ m->mothurOut("\t\tparameters: fasta=required, template=required, processors=1, increment=10, mask=no mask, numwanted=10, match=5, mismatch=-4, divergence=1.0, minsim=90, parents=5, iters=1000, window=100. \n\n");
+ m->mothurOut("The chimera.seqs command should be in the following format: \n");
+ m->mothurOut("chimera.seqs(fasta=yourFastaFile, filter=yourFilter, correction=yourCorrection, processors=yourProcessors, method=bellerophon) \n");
+ m->mothurOut("Example: chimera.seqs(fasta=AD.align, filter=True, correction=true, method=bellerophon, window=200) \n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "help");
+ m->errorOut(e, "ChimeraSeqsCommand", "help");
exit(1);
}
}
else if (method == "ccode") { chimera = new Ccode(fastafile, outputDir); }
else if (method == "chimeracheck") { chimera = new ChimeraCheckRDP(fastafile, outputDir); }
else if (method == "chimeraslayer") { chimera = new ChimeraSlayer(search, realign, fastafile); }
- else { mothurOut("Not a valid method."); mothurOutEndLine(); return 0; }
+ else { m->mothurOut("Not a valid method."); m->mothurOutEndLine(); return 0; }
//set user options
- if (maskfile == "default") { mothurOut("I am using the default 236627 EU009184.1 Shigella dysenteriae str. FBD013."); mothurOutEndLine(); }
+ if (maskfile == "default") { m->mothurOut("I am using the default 236627 EU009184.1 Shigella dysenteriae str. FBD013."); m->mothurOutEndLine(); }
chimera->setCons(consfile);
chimera->setQuantiles(quanfile);
chimera->setMinBS(minBS);
chimera->setMinSNP(minSNP);
chimera->setIters(iters);
- chimera->setTemplateFile(templatefile);
+
string outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + method + maskfile + ".chimeras";
string accnosFileName = outputDir + getRootName(getSimpleName(fastafile)) + method + maskfile + ".accnos";
-
+ bool hasAccnos = true;
- if ((method != "bellerophon") && (method != "chimeracheck")) {
- if (chimera->getUnaligned()) {
- mothurOut("Your template sequences are different lengths, please correct."); mothurOutEndLine();
- delete chimera;
- return 0;
- }
- }else if (method == "bellerophon") {//run bellerophon separately since you need to read entire fastafile to run it
+ if (method == "bellerophon") {//run bellerophon separately since you need to read entire fastafile to run it
chimera->getChimeras();
ofstream out;
out.close();
out2.close();
+ //delete accnos file if its blank
+ if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine();
+ if (hasAccnos) { m->mothurOut(accnosFileName); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
+ //reads template
+ chimera->setTemplateFile(templatefile);
+
+ if (method != "chimeracheck") {
+ if (chimera->getUnaligned()) {
+ m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine();
+ delete chimera;
+ return 0;
+ }
+ }
+
//some methods need to do prep work before processing the chimeras
chimera->doPrep();
chimera->printHeader(outHeader);
outHeader.close();
-
+
//break up file
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
if(processors == 1){
driver(lines[0], outputFileName, fastafile, accnosFileName);
+ //delete accnos file if its blank
+ if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
+
}else{
vector<int> positions;
processIDS.resize(0);
createProcesses(outputFileName, fastafile, accnosFileName);
rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
- rename((accnosFileName + toString(processIDS[0]) + ".temp").c_str(), accnosFileName.c_str());
- //append alignment and report files
+ //append output files
for(int i=1;i<processors;i++){
appendOutputFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
remove((outputFileName + toString(processIDS[i]) + ".temp").c_str());
+ }
+
+ vector<string> nonBlankAccnosFiles;
+ //delete blank accnos files generated with multiple processes
+ for(int i=0;i<processors;i++){
+ if (!(isBlank(accnosFileName + toString(processIDS[i]) + ".temp"))) {
+ nonBlankAccnosFiles.push_back(accnosFileName + toString(processIDS[i]) + ".temp");
+ }else { remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str()); }
+ }
+
+ //append accnos files
+ if (nonBlankAccnosFiles.size() != 0) {
+ rename(nonBlankAccnosFiles[0].c_str(), accnosFileName.c_str());
- appendOutputFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
- remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str());
+ for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
+ appendOutputFiles(nonBlankAccnosFiles[h], accnosFileName);
+ remove(nonBlankAccnosFiles[h].c_str());
+ }
+ }else{ hasAccnos = false; }
- }
}
#else
lines.push_back(new linePair(0, numSeqs));
driver(lines[0], outputFileName, fastafile, accnosFileName);
+
+ //delete accnos file if its blank
+ if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
#endif
- //mothurOut("Output File Names: ");
- //if ((filter) && (method == "bellerophon")) { mothurOut(
+ //m->mothurOut("Output File Names: ");
+ //if ((filter) && (method == "bellerophon")) { m->mothurOut(
//if (outputDir == "") { fastafile = getRootName(fastafile) + "filter.fasta"; }
// else { fastafile = outputDir + getRootName(getSimpleName(fastafile)) + "filter.fasta"; }
delete chimera;
- if (method == "chimeracheck") { remove(accnosFileName.c_str()); mothurOutEndLine(); mothurOut("This method does not determine if a sequence is chimeric, but allows you to make that determination based on the IS values."); mothurOutEndLine(); }
+ if (method == "chimeracheck") { remove(accnosFileName.c_str()); m->mothurOutEndLine(); m->mothurOut("This method does not determine if a sequence is chimeric, but allows you to make that determination based on the IS values."); m->mothurOutEndLine(); }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine();
+ if (hasAccnos) { m->mothurOut(accnosFileName); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
- mothurOutEndLine(); mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "execute");
+ m->errorOut(e, "ChimeraSeqsCommand", "execute");
exit(1);
}
}//**********************************************************************************************************************
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
if ((candidateSeq->getAligned().length() != templateSeqsLength) && (method != "chimeracheck")) { //chimeracheck does not require seqs to be aligned
- mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); mothurOutEndLine();
+ m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
}else{
//find chimeras
chimera->getChimeras(candidateSeq);
delete candidateSeq;
//report progress
- if((i+1) % 100 == 0){ mothurOut("Processing sequence: " + toString(i+1)); mothurOutEndLine(); }
+ if((i+1) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(i+1)); m->mothurOutEndLine(); }
}
//report progress
- if((line->numSeqs) % 100 != 0){ mothurOut("Processing sequence: " + toString(line->numSeqs)); mothurOutEndLine(); }
+ if((line->numSeqs) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(line->numSeqs)); m->mothurOutEndLine(); }
out.close();
out2.close();
return 1;
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "driver");
+ m->errorOut(e, "ChimeraSeqsCommand", "driver");
exit(1);
}
}
}else if (pid == 0){
driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename, accnos + toString(getpid()) + ".temp");
exit(0);
- }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
//force parent to wait until all the processes are done
#endif
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "createProcesses");
+ m->errorOut(e, "ChimeraSeqsCommand", "createProcesses");
exit(1);
}
}
output.close();
}
catch(exception& e) {
- errorOut(e, "ChimeraSeqsCommand", "appendOuputFiles");
+ m->errorOut(e, "ChimeraSeqsCommand", "appendOuputFiles");
exit(1);
}
}
//run filter on template
for (int i = 0; i < templateSeqs.size(); i++) { runFilter(templateSeqs[i]); }
- mothurOutEndLine(); mothurOut("It took " + toString(time(NULL) - start) + " secs to filter."); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to filter."); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "ChimeraSlayer", "doprep");
+ m->errorOut(e, "ChimeraSlayer", "doprep");
exit(1);
}
}
ChimeraSlayer::~ChimeraSlayer() { delete decalc; if (searchMethod == "kmer") { delete databaseRight; delete databaseLeft; } }
//***************************************************************************************************************
void ChimeraSlayer::printHeader(ostream& out) {
- mothurOutEndLine();
- mothurOut("Only reporting sequence supported by " + toString(minBS) + "% of bootstrapped results.");
- mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Only reporting sequence supported by " + toString(minBS) + "% of bootstrapped results.");
+ m->mothurOutEndLine();
out << "Name\tLeftParent\tRightParent\tDivQLAQRB\tPerIDQLAQRB\tBootStrapA\tDivQLBQRA\tPerIDQLBQRA\tBootStrapB\tFlag\tLeftWindow\tRightWindow\n";
}
if (chimeraFlag == "yes") {
if ((chimeraResults[0].bsa >= minBS) || (chimeraResults[0].bsb >= minBS)) {
- mothurOut(querySeq->getName() + "\tyes"); mothurOutEndLine();
+ m->mothurOut(querySeq->getName() + "\tyes"); m->mothurOutEndLine();
outAcc << querySeq->getName() << endl;
}
}
}
catch(exception& e) {
- errorOut(e, "ChimeraSlayer", "print");
+ m->errorOut(e, "ChimeraSlayer", "print");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "ChimeraSlayer", "getChimeras");
+ m->errorOut(e, "ChimeraSlayer", "getChimeras");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ChimeraSlayer", "printBlock");
+ m->errorOut(e, "ChimeraSlayer", "printBlock");
exit(1);
}
}
/**************************************************************************************************/
Classify::Classify(string tfile, string tempFile, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch) : taxFile(tfile), templateFile(tempFile) {
try {
-
+ m = MothurOut::getInstance();
readTaxonomy(taxFile);
int start = time(NULL);
inFASTA.close();
}
- mothurOut("Generating search database... "); cout.flush();
+ m->mothurOut("Generating search database... "); cout.flush();
bool needToGenerate = true;
string kmerDBName;
else if(method == "blast") { database = new BlastDB(gapOpen, gapExtend, match, misMatch); }
else if(method == "distance") { database = new DistanceDB(); }
else {
- mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
- mothurOutEndLine();
+ m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
+ m->mothurOutEndLine();
database = new KmerDB(tempFile, 8);
}
database->setNumSeqs(names.size());
- mothurOut("DONE."); mothurOutEndLine();
- mothurOut("It took " + toString(time(NULL) - start) + " seconds generate search database. "); mothurOutEndLine();
+ m->mothurOut("DONE."); m->mothurOutEndLine();
+ m->mothurOut("It took " + toString(time(NULL) - start) + " seconds generate search database. "); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "Classify", "Classify");
+ m->errorOut(e, "Classify", "Classify");
exit(1);
}
}
ifstream inTax;
openInputFile(file, inTax);
- mothurOutEndLine();
- mothurOut("Reading in the " + file + " taxonomy...\t"); cout.flush();
+ m->mothurOutEndLine();
+ m->mothurOut("Reading in the " + file + " taxonomy...\t"); cout.flush();
string name, taxInfo;
//read template seqs and save
phyloTree->assignHeirarchyIDs(0);
inTax.close();
- mothurOut("DONE.");
- mothurOutEndLine(); cout.flush();
+ m->mothurOut("DONE.");
+ m->mothurOutEndLine(); cout.flush();
}
catch(exception& e) {
- errorOut(e, "Classify", "readTaxonomy");
+ m->errorOut(e, "Classify", "readTaxonomy");
exit(1);
}
}
return taxons;
}
catch(exception& e) {
- errorOut(e, "Classify", "parseTax");
+ m->errorOut(e, "Classify", "parseTax");
exit(1);
}
}
void readTaxonomy(string);
vector<string> parseTax(string);
+ MothurOut* m;
};
/**************************************************************************************************/
//**********************************************************************************************************************
-ClassifySeqsCommand::ClassifySeqsCommand(string option){
+ClassifySeqsCommand::ClassifySeqsCommand(string option) {
try {
abort = false;
//check for required parameters
templateFileName = validParameter.validFile(parameters, "template", true);
if (templateFileName == "not found") {
- mothurOut("template is a required parameter for the classify.seqs command.");
- mothurOutEndLine();
+ m->mothurOut("template is a required parameter for the classify.seqs command.");
+ m->mothurOutEndLine();
abort = true;
}
else if (templateFileName == "not open") { abort = true; }
fastaFileName = validParameter.validFile(parameters, "fasta", false);
- if (fastaFileName == "not found") { mothurOut("fasta is a required parameter for the classify.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastaFileName == "not found") { m->mothurOut("fasta is a required parameter for the classify.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
splitAtDash(fastaFileName, fastaFileNames);
ifstream in;
ableToOpen = openInputFile(fastaFileNames[i], in);
if (ableToOpen == 1) {
- mothurOut(fastaFileNames[i] + " will be disregarded."); mothurOutEndLine();
+ m->mothurOut(fastaFileNames[i] + " will be disregarded."); m->mothurOutEndLine();
//erase from file list
fastaFileNames.erase(fastaFileNames.begin()+i);
i--;
}
//make sure there is at least one valid file left
- if (fastaFileNames.size() == 0) { mothurOut("no valid files."); mothurOutEndLine(); abort = true; }
+ if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
}
taxonomyFileName = validParameter.validFile(parameters, "taxonomy", true);
if (taxonomyFileName == "not found") {
- mothurOut("taxonomy is a required parameter for the classify.seqs command.");
- mothurOutEndLine();
+ m->mothurOut("taxonomy is a required parameter for the classify.seqs command.");
+ m->mothurOutEndLine();
abort = true;
}
else if (taxonomyFileName == "not open") { abort = true; }
int ableToOpen;
ifstream in;
ableToOpen = openInputFile(namefileNames[i], in);
- if (ableToOpen == 1) { mothurOut("Unable to match name file with fasta file."); mothurOutEndLine(); abort = true; }
+ if (ableToOpen == 1) { m->mothurOut("Unable to match name file with fasta file."); m->mothurOutEndLine(); abort = true; }
in.close();
}
}
if (namefile != "") {
- if (namefileNames.size() != fastaFileNames.size()) { abort = true; mothurOut("If you provide a name file, you must have one for each fasta file."); mothurOutEndLine(); }
+ if (namefileNames.size() != fastaFileNames.size()) { abort = true; m->mothurOut("If you provide a name file, you must have one for each fasta file."); m->mothurOutEndLine(); }
}
//check for optional parameter and set defaults
if ((method == "bayesian") && (search != "kmer")) {
- mothurOut("The bayesian method requires the kmer search." + search + "will be disregarded." ); mothurOutEndLine();
+ m->mothurOut("The bayesian method requires the kmer search." + search + "will be disregarded." ); m->mothurOutEndLine();
search = "kmer";
}
}
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand");
+ m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand");
exit(1);
}
}
void ClassifySeqsCommand::help(){
try {
- mothurOut("The classify.seqs command reads a fasta file containing sequences and creates a .taxonomy file and a .tax.summary file.\n");
- mothurOut("The classify.seqs command parameters are template, fasta, name, search, ksize, method, taxonomy, processors, match, mismatch, gapopen, gapextend, numwanted and probs.\n");
- mothurOut("The template, fasta and taxonomy parameters are required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n");
- mothurOut("The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer, blast and distance. The default is kmer.\n");
- mothurOut("The name parameter allows you add a names file with your fasta file, if you enter multiple fasta files, you must enter matching names files for them.\n");
- mothurOut("The method parameter allows you to specify classification method to use. Your options are: bayesian and knn. The default is bayesian.\n");
- mothurOut("The ksize parameter allows you to specify the kmer size for finding most similar template to candidate. The default is 8.\n");
- mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n");
- mothurOut("The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n");
- mothurOut("The mistmatch parameter allows you to specify the penalty for having different bases. The default is -1.0.\n");
- mothurOut("The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n");
- mothurOut("The gapextend parameter allows you to specify the penalty for extending a gap in an alignment. The default is -1.0.\n");
- mothurOut("The numwanted parameter allows you to specify the number of sequence matches you want with the knn method. The default is 10.\n");
- mothurOut("The cutoff parameter allows you to specify a bootstrap confidence threshold for your taxonomy. The default is 0.\n");
- mothurOut("The probs parameter shut off the bootstrapping results for the bayesian method. The default is true, meaning you want the bootstrapping to be run.\n");
- mothurOut("The iters parameter allows you to specify how many iterations to do when calculating the bootstrap confidence score for your taxonomy with the bayesian method. The default is 100.\n");
- mothurOut("The classify.seqs command should be in the following format: \n");
- mothurOut("classify.seqs(template=yourTemplateFile, fasta=yourFastaFile, method=yourClassificationMethod, search=yourSearchmethod, ksize=yourKmerSize, taxonomy=yourTaxonomyFile, processors=yourProcessors) \n");
- mothurOut("Example classify.seqs(fasta=amazon.fasta, template=core.filtered, method=knn, search=gotoh, ksize=8, processors=2)\n");
- mothurOut("The .taxonomy file consists of 2 columns: 1 = your sequence name, 2 = the taxonomy for your sequence. \n");
- mothurOut("The .tax.summary is a summary of the different taxonomies represented in your fasta file. \n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
+ m->mothurOut("The classify.seqs command reads a fasta file containing sequences and creates a .taxonomy file and a .tax.summary file.\n");
+ m->mothurOut("The classify.seqs command parameters are template, fasta, name, search, ksize, method, taxonomy, processors, match, mismatch, gapopen, gapextend, numwanted and probs.\n");
+ m->mothurOut("The template, fasta and taxonomy parameters are required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n");
+ m->mothurOut("The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer, blast and distance. The default is kmer.\n");
+ m->mothurOut("The name parameter allows you add a names file with your fasta file, if you enter multiple fasta files, you must enter matching names files for them.\n");
+ m->mothurOut("The method parameter allows you to specify classification method to use. Your options are: bayesian and knn. The default is bayesian.\n");
+ m->mothurOut("The ksize parameter allows you to specify the kmer size for finding most similar template to candidate. The default is 8.\n");
+ m->mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n");
+ m->mothurOut("The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n");
+ m->mothurOut("The mistmatch parameter allows you to specify the penalty for having different bases. The default is -1.0.\n");
+ m->mothurOut("The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n");
+ m->mothurOut("The gapextend parameter allows you to specify the penalty for extending a gap in an alignment. The default is -1.0.\n");
+ m->mothurOut("The numwanted parameter allows you to specify the number of sequence matches you want with the knn method. The default is 10.\n");
+ m->mothurOut("The cutoff parameter allows you to specify a bootstrap confidence threshold for your taxonomy. The default is 0.\n");
+ m->mothurOut("The probs parameter shut off the bootstrapping results for the bayesian method. The default is true, meaning you want the bootstrapping to be run.\n");
+ m->mothurOut("The iters parameter allows you to specify how many iterations to do when calculating the bootstrap confidence score for your taxonomy with the bayesian method. The default is 100.\n");
+ m->mothurOut("The classify.seqs command should be in the following format: \n");
+ m->mothurOut("classify.seqs(template=yourTemplateFile, fasta=yourFastaFile, method=yourClassificationMethod, search=yourSearchmethod, ksize=yourKmerSize, taxonomy=yourTaxonomyFile, processors=yourProcessors) \n");
+ m->mothurOut("Example classify.seqs(fasta=amazon.fasta, template=core.filtered, method=knn, search=gotoh, ksize=8, processors=2)\n");
+ m->mothurOut("The .taxonomy file consists of 2 columns: 1 = your sequence name, 2 = the taxonomy for your sequence. \n");
+ m->mothurOut("The .tax.summary is a summary of the different taxonomies represented in your fasta file. \n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "help");
+ m->errorOut(e, "ClassifySeqsCommand", "help");
exit(1);
}
}
if(method == "bayesian"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters); }
else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted); }
else {
- mothurOut(search + " is not a valid method option. I will run the command using bayesian.");
- mothurOutEndLine();
+ m->mothurOut(search + " is not a valid method option. I will run the command using bayesian.");
+ m->mothurOutEndLine();
classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters);
}
+ vector<string> outputNames;
for (int s = 0; s < fastaFileNames.size(); s++) {
inNames.close();
}
- mothurOut("Classifying sequences from " + fastaFileNames[s] + " ..." ); mothurOutEndLine();
+ m->mothurOut("Classifying sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
if (outputDir == "") { outputDir += hasPath(fastaFileNames[s]); }
string newTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + getRootName(getSimpleName(taxonomyFileName)) + "taxonomy";
string tempTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
string taxSummary = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + getRootName(getSimpleName(taxonomyFileName)) + "tax.summary";
+ outputNames.push_back(newTaxonomyFile);
+ outputNames.push_back(taxSummary);
+
int start = time(NULL);
int numFastaSeqs = 0;
for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear();
itNames = nameMap.find(name);
if (itNames == nameMap.end()) {
- mothurOut(name + " is not in your name file please correct."); mothurOutEndLine(); exit(1);
+ m->mothurOut(name + " is not in your name file please correct."); m->mothurOutEndLine(); exit(1);
}else{
for (int i = 0; i < itNames->second; i++) {
taxaBrowser.addSeqToTree(name+toString(i), taxon); //add it as many times as there are identical seqs
remove(newTaxonomyFile.c_str());
rename(unclass.c_str(), newTaxonomyFile.c_str());
- mothurOutEndLine();
- mothurOut("It took " + toString(time(NULL) - start) + " secs to classify " + toString(numFastaSeqs) + " sequences."); mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
+ m->mothurOutEndLine();
+ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to classify " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
}
delete classify;
return 0;
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "execute");
+ m->errorOut(e, "ClassifySeqsCommand", "execute");
exit(1);
}
}
return newTax;
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "addUnclassifieds");
+ m->errorOut(e, "ClassifySeqsCommand", "addUnclassifieds");
exit(1);
}
}
}else if (pid == 0){
driver(lines[process], taxFileName + toString(getpid()) + ".temp", tempTaxFile + toString(getpid()) + ".temp", filename);
exit(0);
- }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
//force parent to wait until all the processes are done
#endif
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "createProcesses");
+ m->errorOut(e, "ClassifySeqsCommand", "createProcesses");
exit(1);
}
}
output.close();
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "appendTaxFiles");
+ m->errorOut(e, "ClassifySeqsCommand", "appendTaxFiles");
exit(1);
}
}
delete candidateSeq;
if((i+1) % 100 == 0){
- mothurOut("Classifying sequence " + toString(i+1)); mothurOutEndLine();
+ m->mothurOut("Classifying sequence " + toString(i+1)); m->mothurOutEndLine();
}
}
return 1;
}
catch(exception& e) {
- errorOut(e, "ClassifySeqsCommand", "driver");
+ m->errorOut(e, "ClassifySeqsCommand", "driver");
exit(1);
}
}
class ClassifySeqsCommand : public Command {
public:
- ClassifySeqsCommand(string);
+ ClassifySeqsCommand(string);
~ClassifySeqsCommand();
int execute();
void help();
/***********************************************************************/
-Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string m) :
-rabund(rav), list(lv), dMatrix(dm), method(m)
+Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string f) :
+rabund(rav), list(lv), dMatrix(dm), method(f)
{
/*
cout << "sizeof(MatData): " << sizeof(MatData) << endl;
//save so you can modify as it changes in average neighbor
cutoff = c;
+ m = MothurOut::getInstance();
}
/***********************************************************************/
nColCells = colCells.size();
}
catch(exception& e) {
- errorOut(e, "Cluster", "getRowColCells");
+ m->errorOut(e, "Cluster", "getRowColCells");
exit(1);
}
// cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
}
catch(exception& e) {
- errorOut(e, "Cluster", "clusterBins");
+ m->errorOut(e, "Cluster", "clusterBins");
exit(1);
}
// cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
}
catch(exception& e) {
- errorOut(e, "Cluster", "clusterNames");
+ m->errorOut(e, "Cluster", "clusterNames");
exit(1);
}
}
//if not merged it you need it for warning
if ((!merged) && (method == "average")) {
- //mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
+ //m->mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine();
if (cutOFF > rowCells[i]->dist) {
cutOFF = rowCells[i]->dist;
- //mothurOut("changing cutoff to " + toString(cutOFF)); mothurOutEndLine();
+ //m->mothurOut("changing cutoff to " + toString(cutOFF)); m->mothurOutEndLine();
}
}
if (foundCol[i] == 0) {
if (method == "average") {
if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
- //mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
+ //m->mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine();
if (cutOFF > colCells[i]->dist) {
cutOFF = colCells[i]->dist;
- //mothurOut("changing cutoff to " + toString(cutOFF)); mothurOutEndLine();
+ //m->mothurOut("changing cutoff to " + toString(cutOFF)); m->mothurOutEndLine();
}
}
}
}
}
catch(exception& e) {
- errorOut(e, "Cluster", "update");
+ m->errorOut(e, "Cluster", "update");
exit(1);
}
}
/***********************************************************************/
-void Cluster::setMapWanted(bool m) {
+void Cluster::setMapWanted(bool f) {
try {
- mapWanted = m;
+ mapWanted = f;
//initialize map
for (int i = 0; i < list->getNumBins(); i++) {
}
catch(exception& e) {
- errorOut(e, "Cluster", "setMapWanted");
+ m->errorOut(e, "Cluster", "setMapWanted");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Cluster", "updateMap");
+ m->errorOut(e, "Cluster", "updateMap");
exit(1);
}
}
#include "mothur.h"
#include "sparsematrix.hpp"
+#include "mothurout.h"
class RAbundVector;
class ListVector;
MatVec colCells;
ull nRowCells;
ull nColCells;
+ MothurOut* m;
};
/***********************************************************************/
//**********************************************************************************************************************
//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-ClusterCommand::ClusterCommand(string option){
+ClusterCommand::ClusterCommand(string option) {
try{
globaldata = GlobalData::getInstance();
+
abort = false;
//allow user to run help
//error checking to make sure they read a distance file
if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
- mothurOut("Before you use the cluster command, you first need to read in a distance matrix."); mothurOutEndLine();
+ m->mothurOut("Before you use the cluster command, you first need to read in a distance matrix."); m->mothurOutEndLine();
abort = true;
}
if (method == "not found") { method = "furthest"; }
if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
- else { mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); mothurOutEndLine(); abort = true; }
+ else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
showabund = validParameter.validFile(parameters, "showabund", false);
if (showabund == "not found") { showabund = "T"; }
openOutputFile(fileroot+ tag + ".sabund", sabundFile);
openOutputFile(fileroot+ tag + ".rabund", rabundFile);
openOutputFile(fileroot+ tag + ".list", listFile);
+
+ outputNames.push_back(fileroot+ tag + ".sabund");
+ outputNames.push_back(fileroot+ tag + ".rabund");
+ outputNames.push_back(fileroot+ tag + ".list");
}
}
}
catch(exception& e) {
- errorOut(e, "ClusterCommand", "ClusterCommand");
+ m->errorOut(e, "ClusterCommand", "ClusterCommand");
exit(1);
}
}
void ClusterCommand::help(){
try {
- mothurOut("The cluster command can only be executed after a successful read.dist command.\n");
- mothurOut("The cluster command parameter options are method, cuttoff, precision, showabund and timing. No parameters are required.\n");
- mothurOut("The cluster command should be in the following format: \n");
- mothurOut("cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
- mothurOut("The acceptable cluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n");
+ m->mothurOut("The cluster command can only be executed after a successful read.dist command.\n");
+ m->mothurOut("The cluster command parameter options are method, cuttoff, precision, showabund and timing. No parameters are required.\n");
+ m->mothurOut("The cluster command should be in the following format: \n");
+ m->mothurOut("cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
+ m->mothurOut("The acceptable cluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n");
}
catch(exception& e) {
- errorOut(e, "ClusterCommand", "help");
+ m->errorOut(e, "ClusterCommand", "help");
exit(1);
}
}
while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){
if (print_start && isTrue(timing)) {
- mothurOut("Clustering (" + tag + ") dist " + toString(matrix->getSmallDist()) + "/"
+ m->mothurOut("Clustering (" + tag + ") dist " + toString(matrix->getSmallDist()) + "/"
+ toString(roundDist(matrix->getSmallDist(), precision))
+ "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
cout.flush();
}
if (print_start && isTrue(timing)) {
- mothurOut("Clustering (" + tag + ") for distance " + toString(previousDist) + "/" + toString(rndPreviousDist)
+ m->mothurOut("Clustering (" + tag + ") for distance " + toString(previousDist) + "/" + toString(rndPreviousDist)
+ "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
cout.flush();
print_start = false;
rabundFile.close();
listFile.close();
- if (saveCutoff != cutoff) { mothurOut("changed cutoff to " + toString(cutoff)); mothurOutEndLine(); }
+ if (saveCutoff != cutoff) { m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
//if (isTrue(timing)) {
- mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); mothurOutEndLine();
+ m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
//}
return 0;
}
catch(exception& e) {
- errorOut(e, "ClusterCommand", "execute");
+ m->errorOut(e, "ClusterCommand", "execute");
exit(1);
}
}
void ClusterCommand::printData(string label){
try {
if (isTrue(timing)) {
- mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
- + "\tclusters. Updates: " + toString(loops)); mothurOutEndLine();
+ m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
+ + "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
}
print_start = true;
loops = 0;
oldList.print(listFile);
}
catch(exception& e) {
- errorOut(e, "ClusterCommand", "printData");
+ m->errorOut(e, "ClusterCommand", "printData");
exit(1);
}
class ClusterCommand : public Command {
public:
- ClusterCommand(string);
+ ClusterCommand(string);
~ClusterCommand();
int execute();
void help();
unsigned long loops;
void printData(string label);
+ vector<string> outputNames;
};
#endif
delete ccd;
}
catch(exception& e) {
- errorOut(e, "Collect", "getCurve");
+ m->errorOut(e, "Collect", "getCurve");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Collect", "getSharedCurve");
+ m->errorOut(e, "Collect", "getSharedCurve");
exit(1);
}
}
#include "sharedordervector.h"
#include "datavector.hpp"
#include "globaldata.hpp"
+#include "mothurout.h"
/***********************************************************************/
public:
Collect(OrderVector* order, vector<Display*> disp) :
- numSeqs(order->getNumSeqs()), order(order), displays(disp), label(order->getLabel()) {};
+ numSeqs(order->getNumSeqs()), order(order), displays(disp), label(order->getLabel()) { m = MothurOut::getInstance(); };
Collect(SharedOrderVector* sharedorder, vector<Display*> disp) :
- numSeqs(sharedorder->getNumSeqs()), sharedorder(sharedorder), displays(disp), label(sharedorder->getLabel()) {};
+ numSeqs(sharedorder->getNumSeqs()), sharedorder(sharedorder), displays(disp), label(sharedorder->getLabel()) { m = MothurOut::getInstance(); }
~Collect(){ };
void getCurve(int);
void getGroupComb();
vector<string> groupComb;
bool validGroup(vector<string>, string);
+ MothurOut* m;
};
//**********************************************************************************************************************
-CollectCommand::CollectCommand(string option){
+CollectCommand::CollectCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
//make sure the user has already run the read.otu command
- if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund, rabund or shared file before you can use the collect.single command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund, rabund or shared file before you can use the collect.single command."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "CollectCommand", "CollectCommand");
+ m->errorOut(e, "CollectCommand", "CollectCommand");
exit(1);
}
}
void CollectCommand::help(){
try {
- mothurOut("The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. \n");
- mothurOut("The collect.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
- mothurOut("The collect.single command parameters are label, freq, calc and abund. No parameters are required. \n");
- mothurOut("The collect.single command should be in the following format: \n");
- mothurOut("collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
- mothurOut("Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n");
- mothurOut("The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n");
+ m->mothurOut("The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. \n");
+ m->mothurOut("The collect.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
+ m->mothurOut("The collect.single command parameters are label, freq, calc and abund. No parameters are required. \n");
+ m->mothurOut("The collect.single command should be in the following format: \n");
+ m->mothurOut("collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
+ m->mothurOut("Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n");
+ m->mothurOut("The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n");
validCalculator->printCalc("single", cout);
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
}
catch(exception& e) {
- errorOut(e, "CollectCommand", "help");
+ m->errorOut(e, "CollectCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
+ vector<string> outputNames;
+
if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName); }
else { inputFileNames = parseSharedFile(globaldata->getSharedFile()); globaldata->setFormat("rabund"); }
globaldata->inputFileName = inputFileNames[p];
if (inputFileNames.size() > 1) {
- mothurOutEndLine(); mothurOut("Processing group " + groups[p]); mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
}
validCalculator = new ValidCalculators();
if (validCalculator->isValidCalculator("single", Estimators[i]) == true) {
if (Estimators[i] == "sobs") {
cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
+ outputNames.push_back(fileNameRoot+"sobs");
}else if (Estimators[i] == "chao") {
cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
+ outputNames.push_back(fileNameRoot+"chao");
}else if (Estimators[i] == "nseqs") {
cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
+ outputNames.push_back(fileNameRoot+"nseqs");
}else if (Estimators[i] == "coverage") {
cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+"coverage")));
+ outputNames.push_back(fileNameRoot+"coverage");
}else if (Estimators[i] == "ace") {
cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
+ outputNames.push_back(fileNameRoot+"ace");
}else if (Estimators[i] == "jack") {
cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
+ outputNames.push_back(fileNameRoot+"jack");
}else if (Estimators[i] == "shannon") {
cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
+ outputNames.push_back(fileNameRoot+"shannon");
}else if (Estimators[i] == "npshannon") {
cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
+ outputNames.push_back(fileNameRoot+"np_shannon");
}else if (Estimators[i] == "simpson") {
cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
+ outputNames.push_back(fileNameRoot+"simpson");
}else if (Estimators[i] == "bootstrap") {
cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+ outputNames.push_back(fileNameRoot+"bootstrap");
}else if (Estimators[i] == "geometric") {
cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geometric")));
+ outputNames.push_back(fileNameRoot+"geometric");
}else if (Estimators[i] == "qstat") {
cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat")));
+ outputNames.push_back(fileNameRoot+"qstat");
}else if (Estimators[i] == "logseries") {
cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logseries")));
+ outputNames.push_back(fileNameRoot+"logseries");
}else if (Estimators[i] == "bergerparker") {
cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker")));
+ outputNames.push_back(fileNameRoot+"bergerparker");
}else if (Estimators[i] == "bstick") {
cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick")));
+ outputNames.push_back(fileNameRoot+"bstick");
}else if (Estimators[i] == "goodscoverage") {
cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage")));
+ outputNames.push_back(fileNameRoot+"goodscoverage");
}else if (Estimators[i] == "efron") {
cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron")));
+ outputNames.push_back(fileNameRoot+"efron");
}else if (Estimators[i] == "boneh") {
cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh")));
+ outputNames.push_back(fileNameRoot+"boneh");
}else if (Estimators[i] == "solow") {
cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
+ outputNames.push_back(fileNameRoot+"solow");
}else if (Estimators[i] == "shen") {
cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(fileNameRoot+"shen")));
+ outputNames.push_back(fileNameRoot+"shen");
}
}
}
cCurve->getCurve(freq);
delete cCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
cCurve->getCurve(freq);
delete cCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (order != NULL) { delete order; }
order = (input->getOrderVector(lastLabel));
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
cCurve = new Collect(order, cDisplays);
cCurve->getCurve(freq);
delete validCalculator;
}
-
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "CollectCommand", "execute");
+ m->errorOut(e, "CollectCommand", "execute");
exit(1);
}
}
return filenames;
}
catch(exception& e) {
- errorOut(e, "CollectCommand", "parseSharedFile");
+ m->errorOut(e, "CollectCommand", "parseSharedFile");
exit(1);
}
}
//**********************************************************************************************************************
-CollectSharedCommand::CollectSharedCommand(string option){
+CollectSharedCommand::CollectSharedCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); abort = true; }
- else if (globaldata->getGroupFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); abort = true; }
+ if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if (globaldata->getGroupFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
}
if (validCalculator->isValidCalculator("shared", Estimators[i]) == true) {
if (Estimators[i] == "sharedchao") {
cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
+ outputNames.push_back(fileNameRoot+"shared.chao");
}else if (Estimators[i] == "sharedsobs") {
cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
+ outputNames.push_back(fileNameRoot+"shared.sobs");
}else if (Estimators[i] == "sharedace") {
cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
+ outputNames.push_back(fileNameRoot+"shared.ace");
}else if (Estimators[i] == "jabund") {
cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(fileNameRoot+"jabund")));
+ outputNames.push_back(fileNameRoot+"jabund");
}else if (Estimators[i] == "sorabund") {
cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(fileNameRoot+"sorabund")));
+ outputNames.push_back(fileNameRoot+"sorabund");
}else if (Estimators[i] == "jclass") {
cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(fileNameRoot+"jclass")));
+ outputNames.push_back(fileNameRoot+"jclass");
}else if (Estimators[i] == "sorclass") {
cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(fileNameRoot+"sorclass")));
+ outputNames.push_back(fileNameRoot+"sorclass");
}else if (Estimators[i] == "jest") {
cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(fileNameRoot+"jest")));
+ outputNames.push_back(fileNameRoot+"jest");
}else if (Estimators[i] == "sorest") {
cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(fileNameRoot+"sorest")));
+ outputNames.push_back(fileNameRoot+"sorest");
}else if (Estimators[i] == "thetayc") {
cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(fileNameRoot+"thetayc")));
+ outputNames.push_back(fileNameRoot+"thetayc");
}else if (Estimators[i] == "thetan") {
cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(fileNameRoot+"thetan")));
+ outputNames.push_back(fileNameRoot+"thetan");
}else if (Estimators[i] == "kstest") {
cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(fileNameRoot+"kstest")));
+ outputNames.push_back(fileNameRoot+"kstest");
}else if (Estimators[i] == "whittaker") {
cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(fileNameRoot+"whittaker")));
+ outputNames.push_back(fileNameRoot+"whittaker");
}else if (Estimators[i] == "sharednseqs") {
cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+"shared.nseqs")));
+ outputNames.push_back(fileNameRoot+"shared.nseqs");
}else if (Estimators[i] == "ochiai") {
cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(fileNameRoot+"ochiai")));
+ outputNames.push_back(fileNameRoot+"ochiai");
}else if (Estimators[i] == "anderberg") {
cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+"anderberg")));
+ outputNames.push_back(fileNameRoot+"anderberg");
}else if (Estimators[i] == "skulczynski") {
cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+"kulczynski")));
+ outputNames.push_back(fileNameRoot+"kulczynski");
}else if (Estimators[i] == "kulczynskicody") {
cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(fileNameRoot+"kulczynskicody")));
+ outputNames.push_back(fileNameRoot+"kulczynskicody");
}else if (Estimators[i] == "lennon") {
cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(fileNameRoot+"lennon")));
+ outputNames.push_back(fileNameRoot+"lennon");
}else if (Estimators[i] == "morisitahorn") {
cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(fileNameRoot+"morisitahorn")));
+ outputNames.push_back(fileNameRoot+"morisitahorn");
}else if (Estimators[i] == "braycurtis") {
cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
+ outputNames.push_back(fileNameRoot+"braycurtis");
}
}
}
}
catch(exception& e) {
- errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
+ m->errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
exit(1);
}
}
void CollectSharedCommand::help(){
try {
- mothurOut("The collect.shared command can only be executed after a successful read.otu command.\n");
- mothurOut("The collect.shared command parameters are label, freq, calc and groups. No parameters are required \n");
- mothurOut("The collect.shared command should be in the following format: \n");
- mothurOut("collect.shared(label=yourLabel, freq=yourFreq, calc=yourEstimators, groups=yourGroups).\n");
- mothurOut("Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
- mothurOut("The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n");
- mothurOut("The default value for groups is all the groups in your groupfile.\n");
+ m->mothurOut("The collect.shared command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The collect.shared command parameters are label, freq, calc and groups. No parameters are required \n");
+ m->mothurOut("The collect.shared command should be in the following format: \n");
+ m->mothurOut("collect.shared(label=yourLabel, freq=yourFreq, calc=yourEstimators, groups=yourGroups).\n");
+ m->mothurOut("Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
+ m->mothurOut("The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
validCalculator->printCalc("shared", cout);
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
- mothurOut("If you use sharedchao and run into memory issues, set all to false. \n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
+ m->mothurOut("If you use sharedchao and run into memory issues, set all to false. \n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
}
catch(exception& e) {
- errorOut(e, "CollectSharedCommand", "help");
+ m->errorOut(e, "CollectSharedCommand", "help");
exit(1);
}
}
cCurve->getSharedCurve(freq);
delete cCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
}
cCurve->getSharedCurve(freq);
delete cCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
cCurve->getSharedCurve(freq);
delete cCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
delete order;
}
//reset groups parameter
globaldata->Groups.clear();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "CollectSharedCommand", "execute");
+ m->errorOut(e, "CollectSharedCommand", "execute");
exit(1);
}
}
bool abort, allLines, all;
set<string> labels; //holds labels to be used
string label, calc, groups, outputDir;
- vector<string> Estimators, Groups;
+ vector<string> Estimators, Groups, outputNames;
};
#include "mothur.h"
#include "optionparser.h"
#include "validparameter.h"
+#include "mothurout.h"
class Command {
public:
+ Command() { m = MothurOut::getInstance(); }
virtual int execute() = 0;
virtual void help() = 0;
virtual ~Command() { }
+ protected:
+ MothurOut* m;
};
#endif
/***********************************************************/
CommandFactory::CommandFactory(){
string s = "";
+ m = MothurOut::getInstance();
+
command = new NoCommand(s);
outputDir = ""; inputDir = "";
else { optionString += "inputdir=" + inputDir; }
}
- if(commandName == "read.dist") { command = new ReadDistCommand(optionString); }
- else if(commandName == "read.otu") { command = new ReadOtuCommand(optionString); }
- else if(commandName == "read.tree") { command = new ReadTreeCommand(optionString); }
- else if(commandName == "cluster") { command = new ClusterCommand(optionString); }
- else if(commandName == "unique.seqs") { command = new DeconvoluteCommand(optionString); }
- else if(commandName == "parsimony") { command = new ParsimonyCommand(optionString); }
- else if(commandName == "help") { command = new HelpCommand(optionString); }
- else if(commandName == "quit") { command = new QuitCommand(optionString); }
- else if(commandName == "collect.single") { command = new CollectCommand(optionString); }
- else if(commandName == "collect.shared") { command = new CollectSharedCommand(optionString); }
- else if(commandName == "rarefaction.single") { command = new RareFactCommand(optionString); }
- else if(commandName == "rarefaction.shared") { command = new RareFactSharedCommand(optionString); }
- else if(commandName == "summary.single") { command = new SummaryCommand(optionString); }
- else if(commandName == "summary.shared") { command = new SummarySharedCommand(optionString); }
- else if(commandName == "unifrac.weighted") { command = new UnifracWeightedCommand(optionString); }
- else if(commandName == "unifrac.unweighted") { command = new UnifracUnweightedCommand(optionString); }
- else if(commandName == "get.group") { command = new GetgroupCommand(optionString); }
- else if(commandName == "get.label") { command = new GetlabelCommand(optionString); }
- else if(commandName == "get.sabund") { command = new GetSAbundCommand(optionString); }
- else if(commandName == "get.rabund") { command = new GetRAbundCommand(optionString); }
- else if(commandName == "libshuff") { command = new LibShuffCommand(optionString); }
- else if(commandName == "heatmap.bin") { command = new HeatMapCommand(optionString); }
- else if(commandName == "heatmap.sim") { command = new HeatMapSimCommand(optionString); }
- else if(commandName == "filter.seqs") { command = new FilterSeqsCommand(optionString); }
- else if(commandName == "venn") { command = new VennCommand(optionString); }
- else if(commandName == "bin.seqs") { command = new BinSeqCommand(optionString); }
- else if(commandName == "get.oturep") { command = new GetOTURepCommand(optionString); }
- else if(commandName == "tree.shared") { command = new TreeGroupCommand(optionString); }
- else if(commandName == "dist.shared") { command = new MatrixOutputCommand(optionString); }
- else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(optionString); }
- //else if(commandName == "consensus") { command = new ConcensusCommand(optionString); }
- else if(commandName == "dist.seqs") { command = new DistanceCommand(optionString); }
- else if(commandName == "align.seqs") { command = new AlignCommand(optionString); }
- else if(commandName == "summary.seqs") { command = new SeqSummaryCommand(optionString); }
- else if(commandName == "screen.seqs") { command = new ScreenSeqsCommand(optionString); }
- else if(commandName == "reverse.seqs") { command = new ReverseSeqsCommand(optionString); }
- else if(commandName == "trim.seqs") { command = new TrimSeqsCommand(optionString); }
- else if(commandName == "chimera.seqs") { command = new ChimeraSeqsCommand(optionString); }
- else if(commandName == "list.seqs") { command = new ListSeqsCommand(optionString); }
- else if(commandName == "get.seqs") { command = new GetSeqsCommand(optionString); }
- else if(commandName == "remove.seqs") { command = new RemoveSeqsCommand(optionString); }
- else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); }
- else if(commandName == "system") { command = new SystemCommand(optionString); }
- else if(commandName == "align.check") { command = new AlignCheckCommand(optionString); }
- else if(commandName == "get.sharedseqs") { command = new GetSharedOTUCommand(optionString); }
- else if(commandName == "get.otulist") { command = new GetListCountCommand(optionString); }
- else if(commandName == "hcluster") { command = new HClusterCommand(optionString); }
- else if(commandName == "classify.seqs") { command = new ClassifySeqsCommand(optionString); }
- else if(commandName == "phylotype") { command = new PhylotypeCommand(optionString); }
- else if(commandName == "mgcluster") { command = new MGClusterCommand(optionString); }
- else if(commandName == "pre.cluster") { command = new PreClusterCommand(optionString); }
- else if(commandName == "pcoa") { command = new PCACommand(optionString); }
- else if(commandName == "otu.hierarchy") { command = new OtuHierarchyCommand(optionString); }
- else if(commandName == "set.dir") { command = new SetDirectoryCommand(optionString); }
- else if(commandName == "parse.list") { command = new ParseListCommand(optionString); }
- else { command = new NoCommand(optionString); }
+ if(commandName == "read.dist") { command = new ReadDistCommand(optionString); }
+ else if(commandName == "read.otu") { command = new ReadOtuCommand(optionString); }
+ else if(commandName == "read.tree") { command = new ReadTreeCommand(optionString); }
+ else if(commandName == "cluster") { command = new ClusterCommand(optionString); }
+ else if(commandName == "unique.seqs") { command = new DeconvoluteCommand(optionString); }
+ else if(commandName == "parsimony") { command = new ParsimonyCommand(optionString); }
+ else if(commandName == "help") { command = new HelpCommand(optionString); }
+ else if(commandName == "quit") { command = new QuitCommand(optionString); }
+ else if(commandName == "collect.single") { command = new CollectCommand(optionString); }
+ else if(commandName == "collect.shared") { command = new CollectSharedCommand(optionString); }
+ else if(commandName == "rarefaction.single") { command = new RareFactCommand(optionString); }
+ else if(commandName == "rarefaction.shared") { command = new RareFactSharedCommand(optionString); }
+ else if(commandName == "summary.single") { command = new SummaryCommand(optionString); }
+ else if(commandName == "summary.shared") { command = new SummarySharedCommand(optionString); }
+ else if(commandName == "unifrac.weighted") { command = new UnifracWeightedCommand(optionString); }
+ else if(commandName == "unifrac.unweighted") { command = new UnifracUnweightedCommand(optionString); }
+ else if(commandName == "get.group") { command = new GetgroupCommand(optionString); }
+ else if(commandName == "get.label") { command = new GetlabelCommand(optionString); }
+ else if(commandName == "get.sabund") { command = new GetSAbundCommand(optionString); }
+ else if(commandName == "get.rabund") { command = new GetRAbundCommand(optionString); }
+ else if(commandName == "libshuff") { command = new LibShuffCommand(optionString); }
+ else if(commandName == "heatmap.bin") { command = new HeatMapCommand(optionString); }
+ else if(commandName == "heatmap.sim") { command = new HeatMapSimCommand(optionString); }
+ else if(commandName == "filter.seqs") { command = new FilterSeqsCommand(optionString); }
+ else if(commandName == "venn") { command = new VennCommand(optionString); }
+ else if(commandName == "bin.seqs") { command = new BinSeqCommand(optionString); }
+ else if(commandName == "get.oturep") { command = new GetOTURepCommand(optionString); }
+ else if(commandName == "tree.shared") { command = new TreeGroupCommand(optionString); }
+ else if(commandName == "dist.shared") { command = new MatrixOutputCommand(optionString); }
+ else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(optionString); }
+ //else if(commandName == "consensus") { command = new ConcensusCommand(optionString); }
+ else if(commandName == "dist.seqs") { command = new DistanceCommand(optionString); }
+ else if(commandName == "align.seqs") { command = new AlignCommand(optionString); }
+ else if(commandName == "summary.seqs") { command = new SeqSummaryCommand(optionString); }
+ else if(commandName == "screen.seqs") { command = new ScreenSeqsCommand(optionString); }
+ else if(commandName == "reverse.seqs") { command = new ReverseSeqsCommand(optionString); }
+ else if(commandName == "trim.seqs") { command = new TrimSeqsCommand(optionString); }
+ else if(commandName == "chimera.seqs") { command = new ChimeraSeqsCommand(optionString); }
+ else if(commandName == "list.seqs") { command = new ListSeqsCommand(optionString); }
+ else if(commandName == "get.seqs") { command = new GetSeqsCommand(optionString); }
+ else if(commandName == "remove.seqs") { command = new RemoveSeqsCommand(optionString); }
+ else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); }
+ else if(commandName == "system") { command = new SystemCommand(optionString); }
+ else if(commandName == "align.check") { command = new AlignCheckCommand(optionString); }
+ else if(commandName == "get.sharedseqs") { command = new GetSharedOTUCommand(optionString); }
+ else if(commandName == "get.otulist") { command = new GetListCountCommand(optionString); }
+ else if(commandName == "hcluster") { command = new HClusterCommand(optionString); }
+ else if(commandName == "classify.seqs") { command = new ClassifySeqsCommand(optionString); }
+ else if(commandName == "phylotype") { command = new PhylotypeCommand(optionString); }
+ else if(commandName == "mgcluster") { command = new MGClusterCommand(optionString); }
+ else if(commandName == "pre.cluster") { command = new PreClusterCommand(optionString); }
+ else if(commandName == "pcoa") { command = new PCACommand(optionString); }
+ else if(commandName == "otu.hierarchy") { command = new OtuHierarchyCommand(optionString); }
+ else if(commandName == "set.dir") { command = new SetDirectoryCommand(optionString); }
+ else if(commandName == "parse.list") { command = new ParseListCommand(optionString); }
+ else { command = new NoCommand(optionString); }
return command;
}
catch(exception& e) {
- errorOut(e, "CommandFactory", "getCommand");
+ m->errorOut(e, "CommandFactory", "getCommand");
exit(1);
}
}
return command;
}
catch(exception& e) {
- errorOut(e, "CommandFactory", "getCommand");
+ m->errorOut(e, "CommandFactory", "getCommand");
exit(1);
}
}
if ((commands.find(command)) != (commands.end())) {
return true;
}else{
- mothurOut(command + " is not a valid command in Mothur. Valid commands are ");
+ m->mothurOut(command + " is not a valid command in Mothur. Valid commands are ");
for (it = commands.begin(); it != commands.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false;
}
}
catch(exception& e) {
- errorOut(e, "CommandFactory", "isValidCommand");
+ m->errorOut(e, "CommandFactory", "isValidCommand");
exit(1);
}
}
out << endl;
}
catch(exception& e) {
- errorOut(e, "CommandFactory", "printCommands");
+ m->errorOut(e, "CommandFactory", "printCommands");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h";
class Command;
private:
Command* command;
+ MothurOut* m;
map<string, string> commands;
map<string, string>::iterator it;
string outputDir, inputDir;
//This Function parses through the command line and pulls out the command then sends the options to the parseGlobalData
CommandOptionParser::CommandOptionParser(string input){
try {
+ m = MothurOut::getInstance();
+
int openParen = input.find_first_of('(');
int closeParen = input.find_last_of(')');
optionString = "";
commandString = input.substr(0, openParen); //commandString contains everything before "("
optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
}
- else if (openParen == -1) { mothurOut("You are missing ("); mothurOutEndLine(); }
- else if (closeParen == -1) { mothurOut("You are missing )"); mothurOutEndLine(); }
+ else if (openParen == -1) { m->mothurOut("You are missing ("); m->mothurOutEndLine(); }
+ else if (closeParen == -1) { m->mothurOut("You are missing )"); m->mothurOutEndLine(); }
//GlobalData* globaldata = GlobalData::getInstance();
//globaldata->parseGlobalData(commandString, optionString); //parser to separate and check options
}
catch(exception& e) {
- errorOut(e, "CommandOptionParser", "CommandOptionParser");
+ m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
exit(1);
}
}
#define COMMANDOPTIONPARSER_HPP
#include "mothur.h"
+#include "mothurout.h"
//**********************************************************************************************************************
private:
string commandString, optionString;
+ MothurOut* m;
};
//**********************************************************************************************************************
return(changed);
}
catch(exception& e) {
- errorOut(e, "CompleteLinkage", "updateDistance");
+ m->errorOut(e, "CompleteLinkage", "updateDistance");
exit(1);
}
}
//**********************************************************************************************************************
-ConcensusCommand::ConcensusCommand(string fileroot){
+ConcensusCommand::ConcensusCommand(string fileroot) {
try {
globaldata = GlobalData::getInstance();
abort = false;
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "ConcensusCommand");
+ m->errorOut(e, "ConcensusCommand", "ConcensusCommand");
exit(1);
}
}
void ConcensusCommand::help(){
try {
- mothurOut("The consensus command can only be executed after a successful read.tree command.\n");
- mothurOut("The consensus command has no parameters.\n");
- mothurOut("The consensus command should be in the following format: consensus().\n");
- mothurOut("The consensus command output two files: .consensus.tre and .consensuspairs.\n");
- mothurOut("The .consensus.tre file contains the consensus tree of the trees in your input file.\n");
- mothurOut("The branch lengths are the percentage of trees in your input file that had the given pair.\n");
- mothurOut("The .consensuspairs file contains a list of the internal nodes in your tree. For each node, the pair that was used in the consensus tree \n");
- mothurOut("is reported with its percentage, as well as the other pairs that were seen for that node but not used and their percentages.\n\n");
+ m->mothurOut("The consensus command can only be executed after a successful read.tree command.\n");
+ m->mothurOut("The consensus command has no parameters.\n");
+ m->mothurOut("The consensus command should be in the following format: consensus().\n");
+ m->mothurOut("The consensus command output two files: .consensus.tre and .consensuspairs.\n");
+ m->mothurOut("The .consensus.tre file contains the consensus tree of the trees in your input file.\n");
+ m->mothurOut("The branch lengths are the percentage of trees in your input file that had the given pair.\n");
+ m->mothurOut("The .consensuspairs file contains a list of the internal nodes in your tree. For each node, the pair that was used in the consensus tree \n");
+ m->mothurOut("is reported with its percentage, as well as the other pairs that were seen for that node but not used and their percentages.\n\n");
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "help");
+ m->errorOut(e, "ConcensusCommand", "help");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "execute");
+ m->errorOut(e, "ConcensusCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "buildConcensusTree");
+ m->errorOut(e, "ConcensusCommand", "buildConcensusTree");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "getSets");
+ m->errorOut(e, "ConcensusCommand", "getSets");
exit(1);
}
}
return smallest;
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "getSmallest");
+ m->errorOut(e, "ConcensusCommand", "getSmallest");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "getNextAvailableSet");
+ m->errorOut(e, "ConcensusCommand", "getNextAvailableSet");
exit(1);
}
}
return rate;
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "getSubgroupRating");
+ m->errorOut(e, "ConcensusCommand", "getSubgroupRating");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "getRestSet");
+ m->errorOut(e, "ConcensusCommand", "getRestSet");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "isSubset");
+ m->errorOut(e, "ConcensusCommand", "isSubset");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ConcensusCommand", "findSpot");
+ m->errorOut(e, "ConcensusCommand", "findSpot");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Coverage", "getValues");
+ m->errorOut(e, "Coverage", "getValues");
exit(1);
}
}
Database::Database(){
longest = 0;
numSeqs = 0;
+ m = MothurOut::getInstance();
}
/**************************************************************************************************/
protected:
+ MothurOut* m;
int numSeqs, longest;
float searchScore;
vector<int> results;
#include "mothur.h"
+#include "mothurout.h"
/* This class is parent to listvector, ordervector, rabundvector, sabundvector, sharedordervector, sharedrabundvector, sharedsabundvector.
The child classes all contain OTU information in different forms. */
class DataVector {
public:
- DataVector(){};// : maxRank(0), numBins(0), numSeqs(0){};
+ DataVector(){ m = MothurOut::getInstance(); }// : maxRank(0), numBins(0), numSeqs(0){};
DataVector(string l) : label(l) {};
DataVector(const DataVector& dv) : label(dv.label){};//, maxRank(dv.maxRank), numBins(dv.numBins), numSeqs(dv.numSeqs) {};
DataVector(ifstream&);
protected:
string label;
+ MothurOut* m;
// int maxRank;
// int numBins;
// int numSeqs;
//***************************************************************************************************************
-void DeCalculator::setMask(string m) {
+void DeCalculator::setMask(string ms) {
try {
- seqMask = m;
+ seqMask = ms;
int count = 0;
maskMap.clear();
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "setMask");
+ m->errorOut(e, "DeCalculator", "setMask");
exit(1);
}
}
seq->setUnaligned(tempQuery);
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "runMask");
+ m->errorOut(e, "DeCalculator", "runMask");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "trimSeqs");
+ m->errorOut(e, "DeCalculator", "trimSeqs");
exit(1);
}
}
if (size == 0) { if (cutoff > 1200) { size = 300; }
else{ size = (cutoff / 4); } }
else if (size > (cutoff / 4)) {
- mothurOut("You have selected too large a window size for sequence " + query->getName() + ". I will choose an appropriate window size."); mothurOutEndLine();
+ m->mothurOut("You have selected too large a window size for sequence " + query->getName() + ". I will choose an appropriate window size."); m->mothurOutEndLine();
size = (cutoff / 4);
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findWindows");
+ m->errorOut(e, "DeCalculator", "findWindows");
exit(1);
}
}
return temp;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "calcObserved");
+ m->errorOut(e, "DeCalculator", "calcObserved");
exit(1);
}
}
return dist;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "calcDist");
+ m->errorOut(e, "DeCalculator", "calcDist");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "calcExpected");
+ m->errorOut(e, "DeCalculator", "calcExpected");
exit(1);
}
}
return de;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "calcDE");
+ m->errorOut(e, "DeCalculator", "calcDE");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "calcFreq");
+ m->errorOut(e, "DeCalculator", "calcFreq");
exit(1);
}
}
return averages;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findQav");
+ m->errorOut(e, "DeCalculator", "findQav");
exit(1);
}
}
//for each sequence
for(int i = start; i < end; i++){
- mothurOut("Processing sequence " + toString(i)); mothurOutEndLine();
+ m->mothurOut("Processing sequence " + toString(i)); m->mothurOutEndLine();
Sequence* query = new Sequence(seqs[i]->getName(), seqs[i]->getAligned());
//compare to every other sequence in template
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "getQuantiles");
+ m->errorOut(e, "DeCalculator", "getQuantiles");
exit(1);
}
}
//while you still have guys to eliminate
while (contributions.size() > 0) {
- mothurOut("Removing scores contributed by sequence " + toString(largestContrib) + " in your template file."); mothurOutEndLine();
+ m->mothurOut("Removing scores contributed by sequence " + toString(largestContrib) + " in your template file."); m->mothurOutEndLine();
//remove from quantiles all scores that were made using this largestContrib
for (int i = 0; i < quantiles.size(); i++) {
for(int i = 0; i < marked.size(); i++) {
if (marked[i] > high) {
- mothurOut("Removing scores contributed by sequence " + toString(marked[i]) + " in your template file."); mothurOutEndLine();
+ m->mothurOut("Removing scores contributed by sequence " + toString(marked[i]) + " in your template file."); m->mothurOutEndLine();
for (int i = 0; i < quantiles.size(); i++) {
removeContrib(marked[i], quantiles[i]);
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "removeObviousOutliers");
+ m->errorOut(e, "DeCalculator", "removeObviousOutliers");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "sortContrib");
+ m->errorOut(e, "DeCalculator", "sortContrib");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findLargestContribs");
+ m->errorOut(e, "DeCalculator", "findLargestContribs");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "removeContrib");
+ m->errorOut(e, "DeCalculator", "removeContrib");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findAverage");
+ m->errorOut(e, "DeCalculator", "findAverage");
exit(1);
}
}
return coef;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "getCoef");
+ m->errorOut(e, "DeCalculator", "getCoef");
exit(1);
}
}
return seqsMatches;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findClosest");
+ m->errorOut(e, "DeCalculator", "findClosest");
exit(1);
}
}
return seqsMatch;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "findClosest");
+ m->errorOut(e, "DeCalculator", "findClosest");
exit(1);
}
}
if (pos < rearPos) { rearPos = pos; }
//check to make sure that is not whole seq
- if ((rearPos - frontPos - 1) <= 0) { mothurOut("Error, when I trim your sequences, the entire sequence is trimmed."); mothurOutEndLine(); exit(1); }
+ if ((rearPos - frontPos - 1) <= 0) { m->mothurOut("Error, when I trim your sequences, the entire sequence is trimmed."); m->mothurOutEndLine(); exit(1); }
//cout << query->getName() << " front = " << frontPos << " rear = " << rearPos << endl;
//trim query
string newAligned = query->getAligned();
return trimmedPos;
}
catch(exception& e) {
- errorOut(e, "DeCalculator", "trimSequences");
+ m->errorOut(e, "DeCalculator", "trimSequences");
exit(1);
}
public:
- DeCalculator() {};
+ DeCalculator() { m = MothurOut::getInstance(); }
~DeCalculator() {};
vector<Sequence*> findClosest(Sequence*, vector<Sequence*>, int&, vector<int>&); //takes querySeq, a reference db, numWanted and indexes
set<int> h;
int alignLength;
map<int, int> maskMap;
+ MothurOut* m;
};
#include "deconvolutecommand.h"
/**************************************************************************************/
-DeconvoluteCommand::DeconvoluteCommand(string option) {
+DeconvoluteCommand::DeconvoluteCommand(string option) {
try {
abort = false;
//check for required parameters
inFastaName = validParameter.validFile(parameters, "fasta", true);
if (inFastaName == "not open") { abort = true; }
- else if (inFastaName == "not found") { inFastaName = ""; mothurOut("fasta is a required parameter for the unique.seqs command."); mothurOutEndLine(); abort = true; }
+ else if (inFastaName == "not found") { inFastaName = ""; m->mothurOut("fasta is a required parameter for the unique.seqs command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
}
catch(exception& e) {
- errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
+ m->errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
exit(1);
}
}
void DeconvoluteCommand::help(){
try {
- mothurOut("The unique.seqs command reads a fastafile and creates a namesfile.\n");
- mothurOut("It creates a file where the first column is the groupname and the second column is a list of sequence names who have the same sequence. \n");
- mothurOut("If the sequence is unique the second column will just contain its name. \n");
- mothurOut("The unique.seqs command parameter is fasta and it is required.\n");
- mothurOut("The unique.seqs command should be in the following format: \n");
- mothurOut("unique.seqs(fasta=yourFastaFile) \n");
+ m->mothurOut("The unique.seqs command reads a fastafile and creates a namesfile.\n");
+ m->mothurOut("It creates a file where the first column is the groupname and the second column is a list of sequence names who have the same sequence. \n");
+ m->mothurOut("If the sequence is unique the second column will just contain its name. \n");
+ m->mothurOut("The unique.seqs command parameter is fasta and it is required.\n");
+ m->mothurOut("The unique.seqs command should be in the following format: \n");
+ m->mothurOut("unique.seqs(fasta=yourFastaFile) \n");
}
catch(exception& e) {
- errorOut(e, "DeconvoluteCommand", "help");
+ m->errorOut(e, "DeconvoluteCommand", "help");
exit(1);
}
}
fastamap.printCondensedFasta(outFastaFile);
fastamap.printNamesFile(outNameFile);
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(outFastaFile); m->mothurOutEndLine();
+ m->mothurOut(outNameFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "DeconvoluteCommand", "execute");
+ m->errorOut(e, "DeconvoluteCommand", "execute");
exit(1);
}
}
class DeconvoluteCommand : public Command {
public:
- DeconvoluteCommand(string);
+ DeconvoluteCommand(string);
~DeconvoluteCommand() { };
int execute();
void help();
virtual bool getAll() { bool a; return a; }
virtual string getName() { return ""; };
virtual ~Display() {}
+ Display() { m = MothurOut::getInstance(); }
-private:
+protected:
+ MothurOut* m;
};
class Dist {
public:
- Dist(){dist = 0;}
+ Dist(){dist = 0; m = MothurOut::getInstance(); }
virtual ~Dist() {}
virtual void calcDist(Sequence, Sequence) = 0;
double getDist() { return dist; }
protected:
double dist;
+ MothurOut* m;
};
/**************************************************************************************************/
//**********************************************************************************************************************
-DistanceCommand::DistanceCommand(string option){
+DistanceCommand::DistanceCommand(string option) {
try {
abort = false;
Estimators.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the dist.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the dist.seqs command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
else{
ifstream inFASTA;
output = validParameter.validFile(parameters, "output", false); if(output == "not found"){ output = "column"; }
- if ((output != "column") && (output != "lt") && (output != "square")) { mothurOut(output + " is not a valid output form. Options are column, lt and square. I will use column."); mothurOutEndLine(); output = "column"; }
+ if ((output != "column") && (output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are column, lt and square. I will use column."); m->mothurOutEndLine(); output = "column"; }
ValidCalculators validCalculator;
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "DistanceCommand");
+ m->errorOut(e, "DistanceCommand", "DistanceCommand");
exit(1);
}
}
void DistanceCommand::help(){
try {
- mothurOut("The dist.seqs command reads a file containing sequences and creates a distance file.\n");
- mothurOut("The dist.seqs command parameters are fasta, calc, countends, output, cutoff and processors. \n");
- mothurOut("The fasta parameter is required.\n");
- mothurOut("The calc parameter allows you to specify the method of calculating the distances. Your options are: nogaps, onegap or eachgap. The default is onegap.\n");
- mothurOut("The countends parameter allows you to specify whether to include terminal gaps in distance. Your options are: T or F. The default is T.\n");
- mothurOut("The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0.\n");
- mothurOut("The output parameter allows you to specify format of your distance matrix. Options are column, lt, and square. The default is column.\n");
- mothurOut("The processors parameter allows you to specify number of processors to use. The default is 1.\n");
- mothurOut("The dist.seqs command should be in the following format: \n");
- mothurOut("dist.seqs(fasta=yourFastaFile, calc=yourCalc, countends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) \n");
- mothurOut("Example dist.seqs(fasta=amazon.fasta, calc=eachgap, countends=F, cutoff= 2.0, processors=3).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc).\n\n");
+ m->mothurOut("The dist.seqs command reads a file containing sequences and creates a distance file.\n");
+ m->mothurOut("The dist.seqs command parameters are fasta, calc, countends, output, cutoff and processors. \n");
+ m->mothurOut("The fasta parameter is required.\n");
+ m->mothurOut("The calc parameter allows you to specify the method of calculating the distances. Your options are: nogaps, onegap or eachgap. The default is onegap.\n");
+ m->mothurOut("The countends parameter allows you to specify whether to include terminal gaps in distance. Your options are: T or F. The default is T.\n");
+ m->mothurOut("The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0.\n");
+ m->mothurOut("The output parameter allows you to specify format of your distance matrix. Options are column, lt, and square. The default is column.\n");
+ m->mothurOut("The processors parameter allows you to specify number of processors to use. The default is 1.\n");
+ m->mothurOut("The dist.seqs command should be in the following format: \n");
+ m->mothurOut("dist.seqs(fasta=yourFastaFile, calc=yourCalc, countends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) \n");
+ m->mothurOut("Example dist.seqs(fasta=amazon.fasta, calc=eachgap, countends=F, cutoff= 2.0, processors=3).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc).\n\n");
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "help");
+ m->errorOut(e, "DistanceCommand", "help");
exit(1);
}
}
delete distCalculator;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outputFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "execute");
+ m->errorOut(e, "DistanceCommand", "execute");
exit(1);
}
}
}else if (pid == 0){
driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", cutoff);
exit(0);
- }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
//force parent to wait until all the processes are done
#endif
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "createProcesses");
+ m->errorOut(e, "DistanceCommand", "createProcesses");
exit(1);
}
}
if (output == "lt") { outFile << endl; }
if(i % 100 == 0){
- mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); mothurOutEndLine();
+ m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
}
}
- mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); mothurOutEndLine();
+ m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
outFile.close();
return 1;
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "driver");
+ m->errorOut(e, "DistanceCommand", "driver");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "convertMatrix");
+ m->errorOut(e, "DistanceCommand", "convertMatrix");
exit(1);
}
}
output.close();
}
catch(exception& e) {
- errorOut(e, "DistanceCommand", "appendFiles");
+ m->errorOut(e, "DistanceCommand", "appendFiles");
exit(1);
}
}
class DistanceCommand : public Command {
public:
- DistanceCommand(string);
+ DistanceCommand(string);
~DistanceCommand();
int execute();
void help();
distCalculator = new eachGapDist();
}
catch(exception& e) {
- errorOut(e, "DistanceDB", "DistanceDB");
+ m->errorOut(e, "DistanceDB", "DistanceDB");
exit(1);
}
}
void DistanceDB::addSequence(Sequence seq) {
try {
//are the template sequences aligned
- if (!isAligned(seq.getAligned())) { templateAligned = false; mothurOut(seq.getName() + " is not aligned. Sequences must be aligned to use the distance method."); mothurOutEndLine(); }
+ if (!isAligned(seq.getAligned())) { templateAligned = false; m->mothurOut(seq.getName() + " is not aligned. Sequences must be aligned to use the distance method."); m->mothurOutEndLine(); }
if (templateSeqsLength == 0) { templateSeqsLength = seq.getAligned().length(); }
data.push_back(seq);
}
catch(exception& e) {
- errorOut(e, "DistanceDB", "addSequence");
+ m->errorOut(e, "DistanceDB", "addSequence");
exit(1);
}
}
string sequence = query->getAligned();
vector<seqDist> dists;
- if (numWanted > data.size()) { mothurOut("numwanted is larger than the number of template sequences, using 10."); mothurOutEndLine(); numWanted = 10; }
+ if (numWanted > data.size()) { m->mothurOut("numwanted is larger than the number of template sequences, using 10."); m->mothurOutEndLine(); numWanted = 10; }
if (sequence.length() != templateSeqsLength) { templateSameLength = false; }
}
}else{
- mothurOut("cannot find closest matches using distance method for " + query->getName() + " without aligned template sequences of the same length."); mothurOutEndLine();
+ m->mothurOut("cannot find closest matches using distance method for " + query->getName() + " without aligned template sequences of the same length."); m->mothurOutEndLine();
exit(1);
}
return topMatches;
}
catch(exception& e) {
- errorOut(e, "DistanceDB", "findClosestSequence");
+ m->errorOut(e, "DistanceDB", "findClosestSequence");
exit(1);
}
}
return aligned;
}
catch(exception& e) {
- errorOut(e, "DistanceDB", "isAligned");
+ m->errorOut(e, "DistanceDB", "isAligned");
exit(1);
}
}
data.resize(1,0);
double n = (double)rank->getNumSeqs();
- if(m > n || m == 0) { m = n; }
+ if(f > n || f == 0) { f = n; }
double sum = 0;
for(int i = 1; i < rank->size(); i++){
- sum += pow(-1., i+1) * pow(((double)m / n), i) * (double)(rank->get(i));
+ sum += pow(-1., i+1) * pow(((double)f / n), i) * (double)(rank->get(i));
}
data[0] = sum;
return data;
}
catch(exception& e) {
- errorOut(e, "Efron", "getValues");
+ m->errorOut(e, "Efron", "getValues");
exit(1);
}
}
class Efron : public Calculator {
public:
- Efron(int size) : m(size), Calculator("efron", 1, false) {};
+ Efron(int size) : f(size), Calculator("efron", 1, false) {};
EstOutput getValues(SAbundVector*);
EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
private:
- int m;
+ int f;
};
Engine::Engine(){
try {
cFactory = CommandFactory::getInstance();
+ mout = MothurOut::getInstance();
}
catch(exception& e) {
- errorOut(e, "Engine", "Engine");
+ mout->errorOut(e, "Engine", "Engine");
exit(1);
}
}
globaldata = GlobalData::getInstance();
globaldata->argv = path;
+
}
/***********************************************************************/
while(quitCommandCalled != 1){
- mothurOutEndLine();
+ mout->mothurOutEndLine();
- input = getCommand();
+ input = getCommand();
+ mout->mothurOutEndLine();
//allow user to omit the () on the quit command
if (input == "quit") { input = "quit()"; }
quitCommandCalled = command->execute();
}else {
- mothurOut("Your input contains errors. Please try again.");
- mothurOutEndLine();
+ mout->mothurOut("Your input contains errors. Please try again.");
+ mout->mothurOutEndLine();
}
}
return 1;
}
catch(exception& e) {
- errorOut(e, "InteractEngine", "getInput");
+ mout->errorOut(e, "InteractEngine", "getInput");
exit(1);
}
}
cout << nextCommand << endl;
}
- mothurOutJustToLog("mothur > " + toString(nextCommand));
+ mout->mothurOutJustToLog("mothur > " + toString(nextCommand));
return nextCommand;
#else
string nextCommand = "";
- mothurOut("mothur > ");
+ mout->mothurOut("mothur > ");
getline(cin, nextCommand);
- mothurOutJustToLog("mothur > " + toString(nextCommand));
+ mout->mothurOutJustToLog("mothur > " + toString(nextCommand));
return nextCommand;
#endif
#else
string nextCommand = "";
- mothurOut("mothur > ");
+ mout->mothurOut("mothur > ");
getline(cin, nextCommand);
- mothurOutJustToLog("mothur > " + toString(nextCommand));
+ mout->mothurOutJustToLog("mothur > " + toString(nextCommand));
return nextCommand;
#endif
- mothurOutEndLine();
+ mout->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "Engine", "getCommand");
+ mout->errorOut(e, "Engine", "getCommand");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "BatchEngine", "BatchEngine");
+ mout->errorOut(e, "BatchEngine", "BatchEngine");
exit(1);
}
}
try {
//check if this is a valid batchfile
if (openedBatch == 1) {
- mothurOut("unable to open batchfile");
- mothurOutEndLine();
+ mout->mothurOut("unable to open batchfile");
+ mout->mothurOutEndLine();
return 1;
}
if (input[0] != '#') {
- mothurOutEndLine();
- mothurOut("mothur > " + input);
- mothurOutEndLine();
+ mout->mothurOutEndLine();
+ mout->mothurOut("mothur > " + input);
+ mout->mothurOutEndLine();
//allow user to omit the () on the quit command
Command* command = cFactory->getCommand(commandName, options);
quitCommandCalled = command->execute();
}else {
- mothurOut("Invalid.");
- mothurOutEndLine();
+ mout->mothurOut("Invalid.");
+ mout->mothurOutEndLine();
}
}
return 1;
}
catch(exception& e) {
- errorOut(e, "BatchEngine", "getInput");
+ mout->errorOut(e, "BatchEngine", "getInput");
exit(1);
}
}
listOfCommands = commandString.substr(1, (commandString.length()-1));
globaldata->argv = path;
-
+
}
catch(exception& e) {
- errorOut(e, "ScriptEngine", "ScriptEngine");
+ mout->errorOut(e, "ScriptEngine", "ScriptEngine");
exit(1);
}
}
if (input == "") { input = "quit()"; }
- mothurOutEndLine();
- mothurOut("mothur > " + input);
- mothurOutEndLine();
+ mout->mothurOutEndLine();
+ mout->mothurOut("mothur > " + input);
+ mout->mothurOutEndLine();
//allow user to omit the () on the quit command
Command* command = cFactory->getCommand(commandName, options);
quitCommandCalled = command->execute();
}else {
- mothurOut("Invalid.");
- mothurOutEndLine();
+ mout->mothurOut("Invalid.");
+ mout->mothurOutEndLine();
}
}
return 1;
}
catch(exception& e) {
- errorOut(e, "ScriptEngine", "getInput");
+ mout->errorOut(e, "ScriptEngine", "getInput");
exit(1);
}
}
return nextcommand;
}
catch(exception& e) {
- errorOut(e, "ScriptEngine", "getNextCommand");
+ mout->errorOut(e, "ScriptEngine", "getNextCommand");
exit(1);
}
}
#include "commandoptionparser.hpp"
#include "command.hpp"
#include "commandfactory.hpp"
+#include "mothurout.h"
class GlobalData;
protected:
vector<string> options;
CommandFactory* cFactory;
+ MothurOut* mout;
};
in.close();
}
catch(exception& e) {
- errorOut(e, "FastaMap", "readFastaFile");
+ m->errorOut(e, "FastaMap", "readFastaFile");
exit(1);
}
}
outFile.close();
}
catch(exception& e) {
- errorOut(e, "FastaMap", "printNamesFile");
+ m->errorOut(e, "FastaMap", "printNamesFile");
exit(1);
}
}
out.close();
}
catch(exception& e) {
- errorOut(e, "FastaMap", "printCondensedFasta");
+ m->errorOut(e, "FastaMap", "printCondensedFasta");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
/* This class represents the fasta file. It reads a fasta file a populates the internal data structure "data".
class FastaMap {
public:
- FastaMap() {};
+ FastaMap() { m = MothurOut::getInstance(); }
~FastaMap() {};
string getGroupName(string); //pass a sequence name get its group
map<string, group> data; //sequence, groupinfo - condensed representation of file
map<string, string> seqmap; //name, sequence - uncondensed representation of file
+ MothurOut* m;
};
#endif
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- errorOut(e, "ThreeColumnFile", "initFile");
+ m->errorOut(e, "ThreeColumnFile", "initFile");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "ThreeColumnFile", "output");
+ m->errorOut(e, "ThreeColumnFile", "output");
exit(1);
}
}
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
- mothurOut("Unable to rename " + outName); mothurOutEndLine();
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
perror(" : ");
}
}
catch(exception& e) {
- errorOut(e, "ThreeColumnFile", "resetFile");
+ m->errorOut(e, "ThreeColumnFile", "resetFile");
exit(1);
}
}
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- errorOut(e, "ColumnFile", "initFile");
+ m->errorOut(e, "ColumnFile", "initFile");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ColumnFile", "output");
+ m->errorOut(e, "ColumnFile", "output");
exit(1);
}
}
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
- mothurOut("Unable to rename " + outName); mothurOutEndLine();
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
perror(" : ");
}
}
catch(exception& e) {
- errorOut(e, "ColumnFile", "resetFile");
+ m->errorOut(e, "ColumnFile", "resetFile");
exit(1);
}
}
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- errorOut(e, "SharedThreeColumnFile", "initFile");
+ m->errorOut(e, "SharedThreeColumnFile", "initFile");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedThreeColumnFile", "output");
+ m->errorOut(e, "SharedThreeColumnFile", "output");
exit(1);
}
}
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
- mothurOut("Unable to rename " + outName); mothurOutEndLine();
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
perror(" : ");
}
}
catch(exception& e) {
- errorOut(e, "SharedThreeColumnFile", "resetFile");
+ m->errorOut(e, "SharedThreeColumnFile", "resetFile");
exit(1);
}
}
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- errorOut(e, "OneColumnFile", "initFile");
+ m->errorOut(e, "OneColumnFile", "initFile");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "OneColumnFile", "output");
+ m->errorOut(e, "OneColumnFile", "output");
exit(1);
}
}
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
- mothurOut("Unable to rename " + outName); mothurOutEndLine();
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
perror(" : ");
}
}
catch(exception& e) {
- errorOut(e, "OneColumnFile", "resetFile");
+ m->errorOut(e, "OneColumnFile", "resetFile");
exit(1);
}
}
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- errorOut(e, "SharedOneColumnFile", "initFile");
+ m->errorOut(e, "SharedOneColumnFile", "initFile");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedOneColumnFile", "output");
+ m->errorOut(e, "SharedOneColumnFile", "output");
exit(1);
}
}
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
- mothurOut("Unable to rename " + outName); mothurOutEndLine();
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
perror(" : ");
}
}
catch(exception& e) {
- errorOut(e, "SharedOneColumnFile", "resetFile");
+ m->errorOut(e, "SharedOneColumnFile", "resetFile");
exit(1);
}
}
#define FILEOUTPUT_H
#include "mothur.h"
+#include "mothurout.h"
/***********************************************************************/
class FileOutput {
public:
- FileOutput(){};
+ FileOutput(){ m = MothurOut::getInstance(); }
virtual ~FileOutput(){};
virtual void initFile(string) = 0;
protected:
int renameOk;
+ MothurOut* m;
};
/**************************************************************************************/
-FilterSeqsCommand::FilterSeqsCommand(string option){
+FilterSeqsCommand::FilterSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the filter.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the filter.seqs command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
}
catch(exception& e) {
- errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
+ m->errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
exit(1);
}
}
void FilterSeqsCommand::help(){
try {
- mothurOut("The filter.seqs command reads a file containing sequences and creates a .filter and .filter.fasta file.\n");
- mothurOut("The filter.seqs command parameters are fasta, trump, soft, hard and vertical. \n");
- mothurOut("The fasta parameter is required.\n");
- mothurOut("The trump parameter .... The default is ...\n");
- mothurOut("The soft parameter .... The default is ....\n");
- mothurOut("The hard parameter .... The default is ....\n");
- mothurOut("The vertical parameter .... The default is T.\n");
- mothurOut("The filter.seqs command should be in the following format: \n");
- mothurOut("filter.seqs(fasta=yourFastaFile, trump=yourTrump, soft=yourSoft, hard=yourHard, vertical=yourVertical) \n");
- mothurOut("Example filter.seqs(fasta=abrecovery.fasta, trump=..., soft=..., hard=..., vertical=T).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The filter.seqs command reads a file containing sequences and creates a .filter and .filter.fasta file.\n");
+ m->mothurOut("The filter.seqs command parameters are fasta, trump, soft, hard and vertical. \n");
+ m->mothurOut("The fasta parameter is required.\n");
+ m->mothurOut("The trump parameter .... The default is ...\n");
+ m->mothurOut("The soft parameter .... The default is ....\n");
+ m->mothurOut("The hard parameter .... The default is ....\n");
+ m->mothurOut("The vertical parameter .... The default is T.\n");
+ m->mothurOut("The filter.seqs command should be in the following format: \n");
+ m->mothurOut("filter.seqs(fasta=yourFastaFile, trump=yourTrump, soft=yourSoft, hard=yourHard, vertical=yourVertical) \n");
+ m->mothurOut("Example filter.seqs(fasta=abrecovery.fasta, trump=..., soft=..., hard=..., vertical=T).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "FilterSeqsCommand", "help");
+ m->errorOut(e, "FilterSeqsCommand", "help");
exit(1);
}
}
if(filter[i] == '1'){ filteredLength++; }
}
- mothurOutEndLine();
- mothurOut("Length of filtered alignment: " + toString(filteredLength)); mothurOutEndLine();
- mothurOut("Number of columns removed: " + toString((alignmentLength-filteredLength))); mothurOutEndLine();
- mothurOut("Length of the original alignment: " + toString(alignmentLength)); mothurOutEndLine();
- mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Length of filtered alignment: " + toString(filteredLength)); m->mothurOutEndLine();
+ m->mothurOut("Number of columns removed: " + toString((alignmentLength-filteredLength))); m->mothurOutEndLine();
+ m->mothurOut("Length of the original alignment: " + toString(alignmentLength)); m->mothurOutEndLine();
+ m->mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); m->mothurOutEndLine();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(filterFile); m->mothurOutEndLine();
+ m->mothurOut(filteredFasta); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "FilterSeqsCommand", "execute");
+ m->errorOut(e, "FilterSeqsCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "FormatColumnMatrix", "read");
+ m->errorOut(e, "FormatColumnMatrix", "read");
exit(1);
}
}
class FormatMatrix {
public:
- FormatMatrix(){ }
+ FormatMatrix(){ m = MothurOut::getInstance(); }
virtual ~FormatMatrix() {}
virtual void read(NameAssignment*){};
float cutoff;
string distFile;
vector<int> rowPos;
+ MothurOut* m;
};
//**********************************************************************************************************************
}
catch(exception& e) {
- errorOut(e, "FormatPhylipMatrix", "read");
+ m->errorOut(e, "FormatPhylipMatrix", "read");
exit(1);
}
}
//This constructor reads a distance matrix file and stores the data in the matrix.
FullMatrix::FullMatrix(ifstream& filehandle) {
try{
+ m = MothurOut::getInstance();
globaldata = GlobalData::getInstance();
groupmap = globaldata->gGroupmap;
matrix[i].resize(numSeqs, 0.0);
}
group = groupmap->getGroup(name);
- if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
index.resize(numSeqs);
index[0].seqName = name;
index[0].groupName = group;
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "FullMatrix");
+ m->errorOut(e, "FullMatrix", "FullMatrix");
exit(1);
}
}
index[i].seqName = name;
index[i].groupName = group;
- if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
for(int j=0;j<numSeqs;j++){
filehandle >> matrix[i][j];
delete reading;
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "readSquareMatrix");
+ m->errorOut(e, "FullMatrix", "readSquareMatrix");
exit(1);
}
}
index[i].seqName = name;
index[i].groupName = group;
- if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
for(int j=0;j<i;j++){
filehandle >> distance;
delete reading;
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "readLTMatrix");
+ m->errorOut(e, "FullMatrix", "readLTMatrix");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "sortGroups");
+ m->errorOut(e, "FullMatrix", "sortGroups");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "swapRows");
+ m->errorOut(e, "FullMatrix", "swapRows");
exit(1);
}
}
for (int i = 0; i < numSeqs; i++) { out << i << '\t' << index[i].seqName << endl; }
}
catch(exception& e) {
- errorOut(e, "FullMatrix", "printMatrix");
+ m->errorOut(e, "FullMatrix", "printMatrix");
exit(1);
}
}
class FullMatrix {
public:
- FullMatrix(){};
+ FullMatrix(){ m = MothurOut::getInstance(); }
FullMatrix(ifstream&);
~FullMatrix(){};
int numGroups;
int numUserGroups;
GlobalData* globaldata;
+ MothurOut* m;
};
#endif
return data;
}
catch(exception& e) {
- errorOut(e, "Geom", "getValues");
+ m->errorOut(e, "Geom", "getValues");
exit(1);
}
}
#include "getgroupcommand.h"
//**********************************************************************************************************************
-GetgroupCommand::GetgroupCommand(string option){
+GetgroupCommand::GetgroupCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//if the user changes the output directory command factory will send this info to us in the output parameter
string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
- if ((globaldata->getSharedFile() == "")) { mothurOut("You must use the read.otu command to read a groupfile or a sharedfile before you can use the get.group command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "")) { m->mothurOut("You must use the read.otu command to read a groupfile or a sharedfile before you can use the get.group command."); m->mothurOutEndLine(); abort = true; }
if (abort == false) {
//open shared file
}
}
catch(exception& e) {
- errorOut(e, "GetgroupCommand", "GetgroupCommand");
+ m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
exit(1);
}
}
void GetgroupCommand::help(){
try {
- mothurOut("The get.group command can only be executed after a successful read.otu command.\n");
- //mothurOut("The get.group command outputs a .bootGroups file to you can use in addition to the tree file generated by the bootstrap.shared command to run the consensus command.\n");
- mothurOut("You may not use any parameters with the get.group command.\n");
- mothurOut("The get.group command should be in the following format: \n");
- mothurOut("get.group()\n");
- mothurOut("Example get.group().\n");
+ m->mothurOut("The get.group command can only be executed after a successful read.otu command.\n");
+ //m->mothurOut("The get.group command outputs a .bootGroups file to you can use in addition to the tree file generated by the bootstrap.shared command to run the consensus command.\n");
+ m->mothurOut("You may not use any parameters with the get.group command.\n");
+ m->mothurOut("The get.group command should be in the following format: \n");
+ m->mothurOut("get.group()\n");
+ m->mothurOut("Example get.group().\n");
}
catch(exception& e) {
- errorOut(e, "GetgroupCommand", "help");
+ m->errorOut(e, "GetgroupCommand", "help");
exit(1);
}
}
holdLabel = label;
//output first group
- mothurOut(groupN); mothurOutEndLine();
+ m->mothurOut(groupN); m->mothurOutEndLine();
out << groupN << '\t' << groupN << endl;
//get rest of line
count++;
//output next group
- mothurOut(groupN); mothurOutEndLine();
+ m->mothurOut(groupN); m->mothurOutEndLine();
out << groupN << '\t' << groupN << endl;
//fill vector.
in.close();
out.close();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outputFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetgroupCommand", "execute");
+ m->errorOut(e, "GetgroupCommand", "execute");
exit(1);
}
}
//**********************************************************************************************************************
-GetlabelCommand::GetlabelCommand(string option){
+GetlabelCommand::GetlabelCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
if(option == "help") { help(); abort = true; }
else {
- if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the get.label command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund or rabund before you can use the get.label command."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "GetlabelCommand", "GetlabelCommand");
+ m->errorOut(e, "GetlabelCommand", "GetlabelCommand");
exit(1);
}
}
void GetlabelCommand::help(){
try {
- mothurOut("The get.label command can only be executed after a successful read.otu command.\n");
- mothurOut("You may not use any parameters with the get.label command.\n");
- mothurOut("The get.label command should be in the following format: \n");
- mothurOut("get.label()\n");
- mothurOut("Example get.label().\n");
+ m->mothurOut("The get.label command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("You may not use any parameters with the get.label command.\n");
+ m->mothurOut("The get.label command should be in the following format: \n");
+ m->mothurOut("get.label()\n");
+ m->mothurOut("Example get.label().\n");
}
catch(exception& e) {
- errorOut(e, "GetlabelCommand", "help");
+ m->errorOut(e, "GetlabelCommand", "help");
exit(1);
}
}
if(count > numBins)
count = 0;
if(count == 0) {
- mothurOut(label); mothurOutEndLine();
+ m->mothurOut(label); m->mothurOutEndLine();
in >> numBins;
}
in >> label;
}
catch(exception& e) {
- errorOut(e, "GetlabelCommand", "execute");
+ m->errorOut(e, "GetlabelCommand", "execute");
exit(1);
}
}
#include "getlistcountcommand.h"
//**********************************************************************************************************************
-GetListCountCommand::GetListCountCommand(string option){
+GetListCountCommand::GetListCountCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
allLines = 1;
labels.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//check for required parameters
listfile = validParameter.validFile(parameters, "list", true);
- if ((listfile == "not found") && (globaldata->getListFile() == "")) { mothurOut("You must read a listfile before running the get.listcount command."); mothurOutEndLine(); abort = true; }
+ if ((listfile == "not found") && (globaldata->getListFile() == "")) { m->mothurOut("You must read a listfile before running the get.listcount command."); m->mothurOutEndLine(); abort = true; }
else if ((listfile == "not found") && (globaldata->getListFile() != "")) { listfile = globaldata->getListFile(); }
else if (listfile == "not open") { abort = true; }
else { globaldata->setListFile(listfile); }
}
}
catch(exception& e) {
- errorOut(e, "GetListCountCommand", "GetListCountCommand");
+ m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
exit(1);
}
}
void GetListCountCommand::help(){
try {
- mothurOut("The get.listcount command can only be executed after a successful read.otu command of a listfile or providing a list file using the list parameter.\n");
- mothurOut("The get.listcount command parameters are list and label. No parameters are required.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n");
- mothurOut("The get.listcount command should be in the following format: get.listcount(list=yourlistFile, label=yourLabels).\n");
- mothurOut("Example get.listcount(list=amazon.fn.list, label=0.10).\n");
- mothurOut("The default value for label is all lines in your inputfile.\n");
- mothurOut("The get.listcount command outputs a .otu file for each distance you specify listing the bin number and the names of the sequences in that bin.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n\n");
+ m->mothurOut("The get.listcount command can only be executed after a successful read.otu command of a listfile or providing a list file using the list parameter.\n");
+ m->mothurOut("The get.listcount command parameters are list and label. No parameters are required.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n");
+ m->mothurOut("The get.listcount command should be in the following format: get.listcount(list=yourlistFile, label=yourLabels).\n");
+ m->mothurOut("Example get.listcount(list=amazon.fn.list, label=0.10).\n");
+ m->mothurOut("The default value for label is all lines in your inputfile.\n");
+ m->mothurOut("The get.listcount command outputs a .otu file for each distance you specify listing the bin number and the names of the sequences in that bin.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetListCountCommand", "help");
+ m->errorOut(e, "GetListCountCommand", "help");
exit(1);
}
}
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
delete read;
globaldata->gListVector = NULL;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetListCountCommand", "execute");
+ m->errorOut(e, "GetListCountCommand", "execute");
exit(1);
}
}
if (outputDir == "") { outputDir += hasPath(listfile); }
string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + list->getLabel() + ".otu";
openOutputFile(outputFileName, out);
+ outputNames.push_back(outputFileName);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
//for each bin in the list vector
for (int i = 0; i < list->getNumBins(); i++) {
out.close();
}
catch(exception& e) {
- errorOut(e, "GetListCountCommand", "process");
+ m->errorOut(e, "GetListCountCommand", "process");
exit(1);
}
}
set<string> labels; //holds labels to be used
string label, listfile, outputDir;
ofstream out;
+ vector<string> outputNames;
void process(ListVector*);
};
return (left.group < right.group);
}
//**********************************************************************************************************************
-GetOTURepCommand::GetOTURepCommand(string option){
+GetOTURepCommand::GetOTURepCommand(string option) {
try{
globaldata = GlobalData::getInstance();
abort = false;
allLines = 1;
labels.clear();
-
+
//allow user to run help
if (option == "help") {
help(); abort = true;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the get.oturep command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the get.oturep command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
listfile = validParameter.validFile(parameters, "list", true);
- if (listfile == "not found") { mothurOut("list is a required parameter for the get.oturep command."); mothurOutEndLine(); abort = true; }
+ if (listfile == "not found") { m->mothurOut("list is a required parameter for the get.oturep command."); m->mothurOutEndLine(); abort = true; }
else if (listfile == "not open") { abort = true; }
phylipfile = validParameter.validFile(parameters, "phylip", true);
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
- if ((phylipfile == "") && (columnfile == "")) { mothurOut("When executing a get.oturep command you must enter a phylip or a column."); mothurOutEndLine(); abort = true; }
- else if ((phylipfile != "") && (columnfile != "")) { mothurOut("When executing a get.oturep command you must enter ONLY ONE of the following: phylip or column."); mothurOutEndLine(); abort = true; }
+ if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a get.oturep command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a get.oturep command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
if (columnfile != "") { if (namefile == "") { cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; } }
sorted = validParameter.validFile(parameters, "sorted", false); if (sorted == "not found"){ sorted = ""; }
if ((sorted != "") && (sorted != "name") && (sorted != "bin") && (sorted != "size") && (sorted != "group")) {
- mothurOut(sorted + " is not a valid option for the sorted parameter. The only options are: name, bin, size and group. I will not sort."); mothurOutEndLine();
+ m->mothurOut(sorted + " is not a valid option for the sorted parameter. The only options are: name, bin, size and group. I will not sort."); m->mothurOutEndLine();
sorted = "";
}
if ((sorted == "group") && (groupfile == "")) {
- mothurOut("You must provide a groupfile to sort by group. I will not sort."); mothurOutEndLine();
+ m->mothurOut("You must provide a groupfile to sort by group. I will not sort."); m->mothurOutEndLine();
sorted = "";
}
}
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
+ m->errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
exit(1);
}
}
void GetOTURepCommand::help(){
try {
- mothurOut("The get.oturep command parameters are phylip, column, list, fasta, name, group, large, cutoff, precision, sorted and label. The fasta and list parameters are required, as well as phylip or column and name.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and is separated by dashes.\n");
- mothurOut("The phylip or column parameter is required, but only one may be used. If you use a column file the name filename is required. \n");
- mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
- mothurOut("The get.oturep command should be in the following format: get.oturep(phylip=yourDistanceMatrix, fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n");
- mothurOut("Example get.oturep(phylip=amazon.dist, fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups).\n");
- mothurOut("The default value for label is all labels in your inputfile.\n");
- mothurOut("The sorted parameter allows you to indicate you want the output sorted. You can sort by sequence name, bin number, bin size or group. The default is no sorting, but your options are name, number, size, or group.\n");
- mothurOut("The large parameter allows you to indicate that your distance matrix is too large to fit in RAM. The default value is false.\n");
- mothurOut("The get.oturep command outputs a .fastarep and .rep.names file for each distance you specify, selecting one OTU representative for each bin.\n");
- mothurOut("If you provide a groupfile, then it also appends the names of the groups present in that bin.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
+ m->mothurOut("The get.oturep command parameters are phylip, column, list, fasta, name, group, large, cutoff, precision, sorted and label. The fasta and list parameters are required, as well as phylip or column and name.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like a output files created for, and is separated by dashes.\n");
+ m->mothurOut("The phylip or column parameter is required, but only one may be used. If you use a column file the name filename is required. \n");
+ m->mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
+ m->mothurOut("The get.oturep command should be in the following format: get.oturep(phylip=yourDistanceMatrix, fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n");
+ m->mothurOut("Example get.oturep(phylip=amazon.dist, fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups).\n");
+ m->mothurOut("The default value for label is all labels in your inputfile.\n");
+ m->mothurOut("The sorted parameter allows you to indicate you want the output sorted. You can sort by sequence name, bin number, bin size or group. The default is no sorting, but your options are name, number, size, or group.\n");
+ m->mothurOut("The large parameter allows you to indicate that your distance matrix is too large to fit in RAM. The default value is false.\n");
+ m->mothurOut("The get.oturep command outputs a .fastarep and .rep.names file for each distance you specify, selecting one OTU representative for each bin.\n");
+ m->mothurOut("If you provide a groupfile, then it also appends the names of the groups present in that bin.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "help");
+ m->errorOut(e, "GetOTURepCommand", "help");
exit(1);
}
}
//read distance files
if (format == "column") { readMatrix = new ReadColumnMatrix(distFile); }
else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(distFile); }
- else { mothurOut("File format error."); mothurOutEndLine(); return 0; }
+ else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0; }
readMatrix->setCutoff(cutoff);
//process file and set up indexes
if (format == "column") { formatMatrix = new FormatColumnMatrix(distFile); }
else if (format == "phylip") { formatMatrix = new FormatPhylipMatrix(distFile); }
- else { mothurOut("File format error."); mothurOutEndLine(); return 0; }
+ else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0; }
formatMatrix->setCutoff(cutoff);
nameToIndex[names[j]] = i;
}
}
- } else { mothurOut("error, no listvector."); mothurOutEndLine(); }
+ } else { m->mothurOut("error, no listvector."); m->mothurOutEndLine(); }
fasta = new FastaMap();
while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if (allLines == 1 || labels.count(list->getLabel()) == 1){
- mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine();
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
error = process(list);
if (error == 1) { return 0; } //there is an error in hte input files, abort command
delete list;
list = input->getListVector(lastLabel);
- mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine();
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
error = process(list);
if (error == 1) { return 0; } //there is an error in hte input files, abort command
//output error messages about any remaining user labels
bool needToRun = false;
for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(list->getLabel()) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (needToRun == true) {
if (list != NULL) { delete list; }
list = input->getListVector(lastLabel);
- mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine();
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
error = process(list);
delete list;
if (error == 1) { return 0; } //there is an error in hte input files, abort command
delete groupMap; globaldata->gGroupmap = NULL;
}
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "execute");
+ m->errorOut(e, "GetOTURepCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "readNamesFile");
+ m->errorOut(e, "GetOTURepCommand", "readNamesFile");
exit(1);
}
}
for (size_t i = 0; i < names.size(); i++) {
string groupName = groupMap->getGroup(names[i]);
if (groupName == "not found") {
- mothurOut(names[i] + " is missing from your group file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(names[i] + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
groupError = true;
} else {
groups[groupName] = groupName;
}
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "FindRep");
+ m->errorOut(e, "GetOTURepCommand", "FindRep");
exit(1);
}
}
string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + processList->getLabel() + ".rep.fasta";
openOutputFile(outputFileName, out);
vector<repStruct> reps;
+ outputNames.push_back(outputFileName);
ofstream newNamesOutput;
string outputNamesFile = outputDir + getRootName(getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
openOutputFile(outputNamesFile, newNamesOutput);
+ outputNames.push_back(outputNamesFile);
//for each bin in the list vector
for (int i = 0; i < processList->size(); i++) {
reps.push_back(newRep);
}
}else {
- mothurOut(nameRep + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine();
+ m->mothurOut(nameRep + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
remove(outputFileName.c_str());
remove(outputNamesFile.c_str());
return 1;
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "process");
+ m->errorOut(e, "GetOTURepCommand", "process");
exit(1);
}
}
return rowMap;
}
catch(exception& e) {
- errorOut(e, "GetOTURepCommand", "getMap");
+ m->errorOut(e, "GetOTURepCommand", "getMap");
exit(1);
}
}
bool abort, allLines, groupError, large;
set<string> labels; //holds labels to be used
map<string, int> nameToIndex; //maps sequence name to index in sparsematrix
+ vector<string> outputNames;
float cutoff;
int precision;
vector<SeqMap> seqVec; // contains maps with sequence index and distance
//**********************************************************************************************************************
-GetRAbundCommand::GetRAbundCommand(string option){
+GetRAbundCommand::GetRAbundCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
}
//make sure the user has already run the read.otu command
- if (globaldata->getListFile() == "") { mothurOut("You must read a listfile before you can use the get.rabund command."); mothurOutEndLine(); abort = true; }
+ if (globaldata->getListFile() == "") { m->mothurOut("You must read a listfile before you can use the get.rabund command."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
+ m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
exit(1);
}
}
void GetRAbundCommand::help(){
try {
- mothurOut("The get.rabund command can only be executed after a successful read.otu of a listfile.\n");
- mothurOut("The get.rabund command parameters are label and sorted. No parameters are required.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like included in your .rabund file, and are separated by dashes.\n");
- mothurOut("The sorted parameters allows you to print the rabund results sorted by abundance or not. The default is sorted.\n");
- mothurOut("The get.rabund command should be in the following format: get.rabund(label=yourLabels, sorted=yourSorted).\n");
- mothurOut("Example get.rabund(sorted=F).\n");
- mothurOut("The default value for label is all labels in your inputfile.\n");
- mothurOut("The get.rabund command outputs a .rabund file containing the lines you selected.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n\n");
+ m->mothurOut("The get.rabund command can only be executed after a successful read.otu of a listfile.\n");
+ m->mothurOut("The get.rabund command parameters are label and sorted. No parameters are required.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like included in your .rabund file, and are separated by dashes.\n");
+ m->mothurOut("The sorted parameters allows you to print the rabund results sorted by abundance or not. The default is sorted.\n");
+ m->mothurOut("The get.rabund command should be in the following format: get.rabund(label=yourLabels, sorted=yourSorted).\n");
+ m->mothurOut("Example get.rabund(sorted=F).\n");
+ m->mothurOut("The default value for label is all labels in your inputfile.\n");
+ m->mothurOut("The get.rabund command outputs a .rabund file containing the lines you selected.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetRAbundCommand", "help");
+ m->errorOut(e, "GetRAbundCommand", "help");
exit(1);
}
}
while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(list->getLabel()) == 1){
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
rabund = new RAbundVector();
*rabund = (list->getRAbundVector());
delete list;
list = input->getListVector(lastLabel);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
rabund = new RAbundVector();
*rabund = (list->getRAbundVector());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (list != NULL) { delete list; }
list = input->getListVector(lastLabel);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
rabund = new RAbundVector();
*rabund = (list->getRAbundVector());
delete rabund;
delete list;
}
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(filename); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
out.close();
return 0;
}
catch(exception& e) {
- errorOut(e, "GetRAbundCommand", "execute");
+ m->errorOut(e, "GetRAbundCommand", "execute");
exit(1);
}
}
//**********************************************************************************************************************
-GetSAbundCommand::GetSAbundCommand(string option){
+GetSAbundCommand::GetSAbundCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
}
//make sure the user has already run the read.otu command
- if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "")) { mothurOut("You must read a list or rabund before you can use the get.sabund command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "")) { m->mothurOut("You must read a list or rabund before you can use the get.sabund command."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
+ m->errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
exit(1);
}
}
void GetSAbundCommand::help(){
try {
- mothurOut("The get.sabund command can only be executed after a successful read.otu of a listfile or rabundfile.\n");
- mothurOut("The get.sabund command parameters is label. No parameters are required.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like included in your .sabund file, and are separated by dashes.\n");
- mothurOut("The get.sabund command should be in the following format: get.sabund(label=yourLabels).\n");
- mothurOut("Example get.sabund().\n");
- mothurOut("The default value for label is all labels in your inputfile.\n");
- mothurOut("The get.sabund command outputs a .sabund file containing the labels you selected.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
+ m->mothurOut("The get.sabund command can only be executed after a successful read.otu of a listfile or rabundfile.\n");
+ m->mothurOut("The get.sabund command parameters is label. No parameters are required.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like included in your .sabund file, and are separated by dashes.\n");
+ m->mothurOut("The get.sabund command should be in the following format: get.sabund(label=yourLabels).\n");
+ m->mothurOut("Example get.sabund().\n");
+ m->mothurOut("The default value for label is all labels in your inputfile.\n");
+ m->mothurOut("The get.sabund command outputs a .sabund file containing the labels you selected.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetSAbundCommand", "help");
+ m->errorOut(e, "GetSAbundCommand", "help");
exit(1);
}
}
while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(order->getLabel()) == 1){
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
sabund = new SAbundVector();
*sabund = (order->getSAbundVector());
sabund->print(out);
delete order;
order = (input->getOrderVector(lastLabel));
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
sabund = new SAbundVector();
*sabund = (order->getSAbundVector());
sabund->print(out);
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (order != NULL) { delete order; }
order = (input->getOrderVector(lastLabel));
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
sabund = new SAbundVector();
*sabund = (order->getSAbundVector());
sabund->print(out);
globaldata->gorder = NULL;
out.close();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(filename); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetSAbundCommand", "execute");
+ m->errorOut(e, "GetSAbundCommand", "execute");
exit(1);
}
}
//**********************************************************************************************************************
-GetSeqsCommand::GetSeqsCommand(string option){
+GetSeqsCommand::GetSeqsCommand(string option) {
try {
abort = false;
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//check for required parameters
accnosfile = validParameter.validFile(parameters, "accnos", true);
if (accnosfile == "not open") { abort = true; }
- else if (accnosfile == "not found") { accnosfile = ""; mothurOut("You must provide an accnos file."); mothurOutEndLine(); abort = true; }
+ else if (accnosfile == "not found") { accnosfile = ""; m->mothurOut("You must provide an accnos file."); m->mothurOutEndLine(); abort = true; }
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
if (listfile == "not open") { abort = true; }
else if (listfile == "not found") { listfile = ""; }
- if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "")) { mothurOut("You must provide one of the following: fasta, name, group, alignreport or listfile."); mothurOutEndLine(); abort = true; }
+ if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport or listfile."); m->mothurOutEndLine(); abort = true; }
int okay = 2;
if (outputDir != "") { okay++; }
- if (parameters.size() > okay) { mothurOut("You may only enter one of the following: fasta, name, group, alignreport or listfile."); mothurOutEndLine(); abort = true; }
+ if (parameters.size() > okay) { m->mothurOut("You may only enter one of the following: fasta, name, group, alignreport or listfile."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "GetSeqsCommand");
+ m->errorOut(e, "GetSeqsCommand", "GetSeqsCommand");
exit(1);
}
}
void GetSeqsCommand::help(){
try {
- mothurOut("The get.seqs command reads an .accnos file and one of the following file types: fasta, name, group, list or alignreport file.\n");
- mothurOut("It outputs a file containing only the sequences in the .accnos file.\n");
- mothurOut("The get.seqs command parameters are accnos, fasta, name, group, list and alignreport. You must provide accnos and one of the other parameters.\n");
- mothurOut("The get.seqs command should be in the following format: get.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
- mothurOut("Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The get.seqs command reads an .accnos file and one of the following file types: fasta, name, group, list or alignreport file.\n");
+ m->mothurOut("It outputs a file containing only the sequences in the .accnos file.\n");
+ m->mothurOut("The get.seqs command parameters are accnos, fasta, name, group, list and alignreport. You must provide accnos and one of the other parameters.\n");
+ m->mothurOut("The get.seqs command should be in the following format: get.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
+ m->mothurOut("Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "help");
+ m->errorOut(e, "GetSeqsCommand", "help");
exit(1);
}
}
else if (alignfile != "") { readAlign(); }
else if (listfile != "") { readList(); }
+ if (outputNames.size() != 0) {
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+ }
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "execute");
+ m->errorOut(e, "GetSeqsCommand", "execute");
exit(1);
}
}
ofstream out;
openOutputFile(outputFileName, out);
+
ifstream in;
openInputFile(fastafile, in);
string name;
out.close();
if (wroteSomething == false) {
- mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readFasta");
+ m->errorOut(e, "GetSeqsCommand", "readFasta");
exit(1);
}
}
out.close();
if (wroteSomething == false) {
- mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readList");
+ m->errorOut(e, "GetSeqsCommand", "readList");
exit(1);
}
}
string outputFileName = outputDir + getRootName(getSimpleName(namefile)) + "pick" + getExtension(namefile);
ofstream out;
openOutputFile(outputFileName, out);
+
ifstream in;
openInputFile(namefile, in);
out.close();
if (wroteSomething == false) {
- mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readName");
+ m->errorOut(e, "GetSeqsCommand", "readName");
exit(1);
}
}
string outputFileName = outputDir + getRootName(getSimpleName(groupfile)) + "pick" + getExtension(groupfile);
ofstream out;
openOutputFile(outputFileName, out);
+
ifstream in;
openInputFile(groupfile, in);
out.close();
if (wroteSomething == false) {
- mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readGroup");
+ m->errorOut(e, "GetSeqsCommand", "readGroup");
exit(1);
}
}
string outputFileName = outputDir + getRootName(getSimpleName(alignfile)) + "pick.align.report";
ofstream out;
openOutputFile(outputFileName, out);
+
ifstream in;
openInputFile(alignfile, in);
out.close();
if (wroteSomething == false) {
- mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readAlign");
+ m->errorOut(e, "GetSeqsCommand", "readAlign");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "GetSeqsCommand", "readAccnos");
+ m->errorOut(e, "GetSeqsCommand", "readAccnos");
exit(1);
}
}
public:
- GetSeqsCommand(string);
+ GetSeqsCommand(string);
~GetSeqsCommand(){};
int execute();
void help();
private:
set<string> names;
+ vector<string> outputNames;
string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, outputDir;
bool abort;
//**********************************************************************************************************************
-GetSharedOTUCommand::GetSharedOTUCommand(string option){
+GetSharedOTUCommand::GetSharedOTUCommand(string option) {
try {
globaldata = GlobalData::getInstance();
if (groupfile == "not open") { abort = true; }
else if (groupfile == "not found") { groupfile = ""; }
- if ((listfile == "") || (groupfile == "")) { mothurOut("The list and group parameters are required."); mothurOutEndLine(); abort = true; }
+ if ((listfile == "") || (groupfile == "")) { m->mothurOut("The list and group parameters are required."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
+ m->errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
exit(1);
}
}
void GetSharedOTUCommand::help(){
try {
- mothurOut("The get.sharedseqs command parameters are list, group, label, unique, shared, output and fasta. The list and group parameters are required.\n");
- mothurOut("The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n");
- mothurOut("The unique and shared parameters allow you to select groups you would like to know the shared info for, and are separated by dashes.\n");
- mothurOut("If you enter your groups under the unique parameter mothur will return the otus that contain ONLY sequences from those groups.\n");
- mothurOut("If you enter your groups under the shared parameter mothur will return the otus that contain sequences from those groups and may also contain sequences from other groups.\n");
- mothurOut("If you do not enter any groups then the get.sharedseqs command will return sequences that are unique to all groups in your group file.\n");
- mothurOut("The fasta parameter allows you to input a fasta file and outputs a fasta file for each distance level containing only the sequences that are in OTUs shared by the groups specified.\n");
- mothurOut("The output parameter allows you to output the list of names without the group and bin number added. \n");
- mothurOut("With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n");
- mothurOut("The get.sharedseqs command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n");
- mothurOut("The get.sharedseqs command should be in the following format: get.sabund(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
- mothurOut("Example get.sharedseqs(list=amazon.fn.list, label=unique-0.01, group=forest-pasture, fasta=amazon.fasta, output=accnos).\n");
- mothurOut("The output to the screen is the distance and the number of otus at that distance for the groups you specified.\n");
- mothurOut("The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
+ m->mothurOut("The get.sharedseqs command parameters are list, group, label, unique, shared, output and fasta. The list and group parameters are required.\n");
+ m->mothurOut("The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n");
+ m->mothurOut("The unique and shared parameters allow you to select groups you would like to know the shared info for, and are separated by dashes.\n");
+ m->mothurOut("If you enter your groups under the unique parameter mothur will return the otus that contain ONLY sequences from those groups.\n");
+ m->mothurOut("If you enter your groups under the shared parameter mothur will return the otus that contain sequences from those groups and may also contain sequences from other groups.\n");
+ m->mothurOut("If you do not enter any groups then the get.sharedseqs command will return sequences that are unique to all groups in your group file.\n");
+ m->mothurOut("The fasta parameter allows you to input a fasta file and outputs a fasta file for each distance level containing only the sequences that are in OTUs shared by the groups specified.\n");
+ m->mothurOut("The output parameter allows you to output the list of names without the group and bin number added. \n");
+ m->mothurOut("With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n");
+ m->mothurOut("The get.sharedseqs command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n");
+ m->mothurOut("The get.sharedseqs command should be in the following format: get.sabund(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
+ m->mothurOut("Example get.sharedseqs(list=amazon.fn.list, label=unique-0.01, group=forest-pasture, fasta=amazon.fasta, output=accnos).\n");
+ m->mothurOut("The output to the screen is the distance and the number of otus at that distance for the groups you specified.\n");
+ m->mothurOut("The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
}
catch(exception& e) {
- errorOut(e, "GetSharedOTUCommand", "help");
+ m->errorOut(e, "GetSharedOTUCommand", "help");
exit(1);
}
}
list = new ListVector(in);
if(allLines == 1 || labels.count(list->getLabel()) == 1){
- mothurOut(list->getLabel());
+ m->mothurOut(list->getLabel());
process(list);
processedLabels.insert(list->getLabel());
if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
- mothurOut(lastlist->getLabel());
+ m->mothurOut(lastlist->getLabel());
process(lastlist);
processedLabels.insert(lastlist->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
//run last label if you need to
if (needToRun == true) {
- mothurOut(lastlist->getLabel());
+ m->mothurOut(lastlist->getLabel());
process(lastlist);
processedLabels.insert(lastlist->getLabel());
globaldata->Groups.clear();
if (lastlist != NULL) { delete lastlist; }
+
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "GetSharedOTUCommand", "execute");
+ m->errorOut(e, "GetSharedOTUCommand", "execute");
exit(1);
}
}
bool uniqueOTU = true;
map<string, int> atLeastOne;
- for (int m = 0; m < Groups.size(); m++) {
- atLeastOne[Groups[m]] = 0;
+ for (int f = 0; f < Groups.size(); f++) {
+ atLeastOne[Groups[f]] = 0;
}
vector<string> namesOfSeqsInThisBin;
namesOfSeqsInThisBin.push_back((name + "\t" + seqGroup + "\t" + toString(i+1)));
}else { namesOfSeqsInThisBin.push_back(name); }
- if (seqGroup == "not found") { mothurOut(name + " is not in your groupfile. Please correct."); mothurOutEndLine(); exit(1); }
+ if (seqGroup == "not found") { m->mothurOut(name + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1); }
//is this seq in one of hte groups we care about
it = groupFinder.find(seqGroup);
namesOfSeqsInThisBin.push_back((names + "\t" + seqGroup + "\t" + toString(i+1)));
}else { namesOfSeqsInThisBin.push_back(names); }
- if (seqGroup == "not found") { mothurOut(names + " is not in your groupfile. Please correct."); mothurOutEndLine(); exit(1); }
+ if (seqGroup == "not found") { m->mothurOut(names + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1); }
//is this seq in one of hte groups we care about
it = groupFinder.find(seqGroup);
}
outputString += groupString + ".";
- mothurOut(outputString); mothurOutEndLine();
- }else { mothurOut("\t" + toString(num)); mothurOutEndLine(); }
+ m->mothurOut(outputString); m->mothurOutEndLine();
+ }else {
+ m->mothurOut("\t" + toString(num)); m->mothurOutEndLine();
+ outputNames.push_back(outputFileNames);
+ }
//if fasta file provided output new fasta file
if ((fastafile != "") && wroteSomething) {
string outputFileFasta = outputDir + getRootName(getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta";
ofstream outFasta;
openOutputFile(outputFileFasta, outFasta);
+ outputNames.push_back(outputFileFasta);
for (int k = 0; k < seqs.size(); k++) {
//if this is a sequence we want, output it
}
catch(exception& e) {
- errorOut(e, "GetSharedOTUCommand", "process");
+ m->errorOut(e, "GetSharedOTUCommand", "process");
exit(1);
}
}
map<string, string> groupFinder;
map<string, string>::iterator it;
vector<Sequence> seqs;
+ vector<string> outputNames;
void process(ListVector*);
/******************************************************/
GlobalData::GlobalData() {
+ m = MothurOut::getInstance();
//option definitions should go here...
clear();
gListVector = NULL;
names.clear();
}
catch(exception& e) {
- errorOut(e, "GlobalData", "newRead");
+ m->errorOut(e, "GlobalData", "newRead");
exit(1);
}
}
if (nameMap != NULL) { delete nameMap; nameMap = NULL; }
}
catch(exception& e) {
- errorOut(e, "GlobalData", "~GlobalData");
+ m->errorOut(e, "GlobalData", "~GlobalData");
exit(1);
}
}
void newRead();
private:
-
+ MothurOut* m;
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, treefile, sharedfile, format, distfile;
static GlobalData* _uniqueInstance;
return data;
}
catch(exception& e) {
- errorOut(e, "GoodsCoverage", "getValues");
+ m->errorOut(e, "GoodsCoverage", "getValues");
exit(1);
}
}
/**************************************************************************************************/
-GotohOverlap::GotohOverlap(float gO, float gE, float m, float mm, int r) :
- gapOpen(gO), gapExtend(gE), match(m), mismatch(mm), Alignment(r) {
+GotohOverlap::GotohOverlap(float gO, float gE, float f, float mm, int r) :
+ gapOpen(gO), gapExtend(gE), match(f), mismatch(mm), Alignment(r) {
try {
for(int i=1;i<nCols;i++){ // we initialize the dynamic programming matrix by setting the pointers in
}
catch(exception& e) {
- errorOut(e, "GotohOverlap", "GotohOverlap");
+ m->errorOut(e, "GotohOverlap", "GotohOverlap");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "GotohOverlap", "align");
+ m->errorOut(e, "GotohOverlap", "align");
exit(1);
}
}
/************************************************************/
GroupMap::GroupMap(string filename) {
+ m = MothurOut::getInstance();
groupFileName = filename;
openInputFile(filename, fileHandle);
index = 0;
it = groupmap.find(seqName);
- if (it != groupmap.end()) { error = 1; mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); mothurOutEndLine(); }
+ if (it != groupmap.end()) { error = 1; m->mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); }
else {
groupmap[seqName] = seqGroup; //store data in map
seqsPerGroup[seqGroup]++; //increment number of seqs in that group
return false;
}
catch(exception& e) {
- errorOut(e, "GroupMap", "isValidGroup");
+ m->errorOut(e, "GroupMap", "isValidGroup");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "GroupMap", "getNumSeqs");
+ m->errorOut(e, "GroupMap", "getNumSeqs");
exit(1);
}
}
return names;
}
catch(exception& e) {
- errorOut(e, "GroupMap", "getNamesSeqs");
+ m->errorOut(e, "GroupMap", "getNamesSeqs");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
/* This class is a representation of the groupfile. It is used by all the shared commands to determine what group a
certain sequence belongs to. */
int getNumSeqs(string); //return the number of seqs in a given group
private:
+ MothurOut* m;
ifstream fileHandle;
string groupFileName;
int index;
#include "sparsematrix.hpp"
/***********************************************************************/
-HCluster::HCluster(RAbundVector* rav, ListVector* lv, string m, string d, NameAssignment* n, float c) : rabund(rav), list(lv), method(m), distfile(d), nameMap(n), cutoff(c) {
+HCluster::HCluster(RAbundVector* rav, ListVector* lv, string ms, string d, NameAssignment* n, float c) : rabund(rav), list(lv), method(ms), distfile(d), nameMap(n), cutoff(c) {
try {
+ m = MothurOut::getInstance();
mapWanted = false;
exitedBreak = false;
numSeqs = list->getNumSeqs();
}
}
catch(exception& e) {
- errorOut(e, "HCluster", "HCluster");
+ m->errorOut(e, "HCluster", "HCluster");
exit(1);
}
}
//cout << '\t' << rabund->get(clusterArray[smallRow].smallChild) << '\t' << rabund->get(clusterArray[smallCol].smallChild) << endl;
}
catch(exception& e) {
- errorOut(e, "HCluster", "clusterBins");
+ m->errorOut(e, "HCluster", "clusterBins");
exit(1);
}
}
catch(exception& e) {
- errorOut(e, "HCluster", "clusterNames");
+ m->errorOut(e, "HCluster", "clusterNames");
exit(1);
}
return node;
}
catch(exception& e) {
- errorOut(e, "HCluster", "getUpmostParent");
+ m->errorOut(e, "HCluster", "getUpmostParent");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "HCluster", "getUpmostParent");
+ m->errorOut(e, "HCluster", "getUpmostParent");
exit(1);
}
}
return linkValue;
}
catch(exception& e) {
- errorOut(e, "HCluster", "makeActive");
+ m->errorOut(e, "HCluster", "makeActive");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "HCluster", "updateArrayandLinkTable");
+ m->errorOut(e, "HCluster", "updateArrayandLinkTable");
exit(1);
}
}
//printInfo();
}
catch(exception& e) {
- errorOut(e, "HCluster", "update");
+ m->errorOut(e, "HCluster", "update");
exit(1);
}
}
/***********************************************************************/
-void HCluster::setMapWanted(bool m) {
+void HCluster::setMapWanted(bool ms) {
try {
- mapWanted = m;
+ mapWanted = ms;
//initialize map
for (int i = 0; i < list->getNumBins(); i++) {
}
catch(exception& e) {
- errorOut(e, "HCluster", "setMapWanted");
+ m->errorOut(e, "HCluster", "setMapWanted");
exit(1);
}
}
seq2Bin[names] = clusterArray[smallCol].smallChild;
}
catch(exception& e) {
- errorOut(e, "HCluster", "updateMap");
+ m->errorOut(e, "HCluster", "updateMap");
exit(1);
}
}
return sameSeqs;
}
catch(exception& e) {
- errorOut(e, "HCluster", "getSeqs");
+ m->errorOut(e, "HCluster", "getSeqs");
exit(1);
}
}
return sameSeqs;
}
catch(exception& e) {
- errorOut(e, "HCluster", "getSeqsFNNN");
+ m->errorOut(e, "HCluster", "getSeqsFNNN");
exit(1);
}
}
return temp;
}
catch(exception& e) {
- errorOut(e, "HCluster", "getSeqsAN");
+ m->errorOut(e, "HCluster", "getSeqsAN");
exit(1);
}
}
sort(mergedMin.begin(), mergedMin.end(), compareSequenceDistance);
}
catch(exception& e) {
- errorOut(e, "HCluster", "combineFile");
+ m->errorOut(e, "HCluster", "combineFile");
exit(1);
}
}
return next;
}
catch(exception& e) {
- errorOut(e, "HCluster", "getNextDist");
+ m->errorOut(e, "HCluster", "getNextDist");
exit(1);
}
}
rename(outTemp.c_str(), distfile.c_str());
}
catch(exception& e) {
- errorOut(e, "HCluster", "processFile");
+ m->errorOut(e, "HCluster", "processFile");
exit(1);
}
}
vector<seqDist> mergedMin;
string partialDist;
+ MothurOut* m;
};
//**********************************************************************************************************************
//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-HClusterCommand::HClusterCommand(string option){
+HClusterCommand::HClusterCommand(string option) {
try{
globaldata = GlobalData::getInstance();
abort = false;
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
- if ((phylipfile == "") && (columnfile == "")) { mothurOut("When executing a hcluster command you must enter a phylip or a column."); mothurOutEndLine(); abort = true; }
- else if ((phylipfile != "") && (columnfile != "")) { mothurOut("When executing a hcluster command you must enter ONLY ONE of the following: phylip or column."); mothurOutEndLine(); abort = true; }
+ if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a hcluster command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a hcluster command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
if (columnfile != "") {
if (namefile == "") { cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
if (method == "not found") { method = "furthest"; }
if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
- else { mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); mothurOutEndLine(); abort = true; }
+ else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
showabund = validParameter.validFile(parameters, "showabund", false);
if (showabund == "not found") { showabund = "T"; }
openOutputFile(fileroot+ tag + ".sabund", sabundFile);
openOutputFile(fileroot+ tag + ".rabund", rabundFile);
openOutputFile(fileroot+ tag + ".list", listFile);
+
+ outputNames.push_back(fileroot+ tag + ".sabund");
+ outputNames.push_back(fileroot+ tag + ".rabund");
+ outputNames.push_back(fileroot+ tag + ".list");
}
}
}
catch(exception& e) {
- errorOut(e, "HClusterCommand", "HClusterCommand");
+ m->errorOut(e, "HClusterCommand", "HClusterCommand");
exit(1);
}
}
void HClusterCommand::help(){
try {
- mothurOut("The hcluster command parameter options are cutoff, precision, method, phylip, column, name, showabund, timing and sorted. Phylip or column and name are required.\n");
- mothurOut("The phylip and column parameter allow you to enter your distance file, and sorted indicates whether your column distance file is already sorted. \n");
- mothurOut("The name parameter allows you to enter your name file and is required if your distance file is in column format. \n");
- mothurOut("The hcluster command should be in the following format: \n");
- mothurOut("hcluster(column=youDistanceFile, name=yourNameFile, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
- mothurOut("The acceptable hcluster methods are furthest and nearest, but we hope to add average in the future.\n\n");
+ m->mothurOut("The hcluster command parameter options are cutoff, precision, method, phylip, column, name, showabund, timing and sorted. Phylip or column and name are required.\n");
+ m->mothurOut("The phylip and column parameter allow you to enter your distance file, and sorted indicates whether your column distance file is already sorted. \n");
+ m->mothurOut("The name parameter allows you to enter your name file and is required if your distance file is in column format. \n");
+ m->mothurOut("The hcluster command should be in the following format: \n");
+ m->mothurOut("hcluster(column=youDistanceFile, name=yourNameFile, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
+ m->mothurOut("The acceptable hcluster methods are furthest and nearest, but we hope to add average in the future.\n\n");
}
catch(exception& e) {
- errorOut(e, "HClusterCommand", "help");
+ m->errorOut(e, "HClusterCommand", "help");
exit(1);
}
}
list = new ListVector(globaldata->nameMap->getListVector());
}
- mothurOut("It took " + toString(time(NULL) - estart) + " seconds to sort. "); mothurOutEndLine();
+ m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to sort. "); m->mothurOutEndLine();
estart = time(NULL);
//list vector made by read contains all sequence names
if(list != NULL){
rabund = new RAbundVector(list->getRAbundVector());
}else{
- mothurOut("Error: no list vector!"); mothurOutEndLine(); return 0;
+ m->mothurOut("Error: no list vector!"); m->mothurOutEndLine(); return 0;
}
float previousDist = 0.00000;
rabundFile.close();
listFile.close();
delete cluster;
-
- mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster. "); mothurOutEndLine();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+ m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster. "); m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "HClusterCommand", "execute");
+ m->errorOut(e, "HClusterCommand", "execute");
exit(1);
}
}
void HClusterCommand::printData(string label){
try {
if (isTrue(timing)) {
- mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
- + "\tclusters. Updates: " + toString(loops)); mothurOutEndLine();
+ m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
+ + "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
}
print_start = true;
loops = 0;
oldList.print(listFile);
}
catch(exception& e) {
- errorOut(e, "HClusterCommand", "printData");
+ m->errorOut(e, "HClusterCommand", "printData");
exit(1);
}
ofstream sabundFile, rabundFile, listFile;
time_t start;
unsigned long loops;
+ vector<string> outputNames;
void printData(string label);
};
HeatMap::HeatMap(string sort, string scale, string dir){
try {
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
// format = globaldata->getFormat();
sorted = sort;
scaler = scale;
outputDir = dir;
}
catch(exception& e) {
- errorOut(e, "HeatMap", "HeatMap");
+ m->errorOut(e, "HeatMap", "HeatMap");
exit(1);
}
}
//**********************************************************************************************************************
-void HeatMap::getPic(RAbundVector* rabund) {
+string HeatMap::getPic(RAbundVector* rabund) {
try {
outsvg << "</g>\n</svg>\n";
outsvg.close();
-
+ return filenamesvg;
}
catch(exception& e) {
- errorOut(e, "HeatMap", "getPic");
+ m->errorOut(e, "HeatMap", "getPic");
exit(1);
}
}
//**********************************************************************************************************************
-void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
+string HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
try {
//sort lookup so shared bins are on top
if (isTrue(sorted) == true) { sortSharedVectors(lookup); }
outsvg << "</g>\n</svg>\n";
outsvg.close();
+
+ return filenamesvg;
}
catch(exception& e) {
- errorOut(e, "HeatMap", "getPic");
+ m->errorOut(e, "HeatMap", "getPic");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "HeatMap", "sortSharedVectors");
+ m->errorOut(e, "HeatMap", "sortSharedVectors");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "HeatMap", "printLegend");
+ m->errorOut(e, "HeatMap", "printLegend");
exit(1);
}
}
HeatMap(string, string, string);
~HeatMap(){};
- void getPic(RAbundVector*);
- void getPic(vector<SharedRAbundVector*>);
+ string getPic(RAbundVector*);
+ string getPic(vector<SharedRAbundVector*>);
private:
void sortSharedVectors(vector<SharedRAbundVector*>& );
GlobalData* globaldata;
string format, sorted, groupComb, scaler, outputDir;
ofstream outsvg;
+ MothurOut* m;
};
//**********************************************************************************************************************
-HeatMapCommand::HeatMapCommand(string option){
+HeatMapCommand::HeatMapCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "") && (globaldata->getSharedFile() == "")) {
- mothurOut("You must read a list, rabund, sabund, or a list and a group, or a shared before you can use the heatmap.bin command."); mothurOutEndLine(); abort = true;
+ m->mothurOut("You must read a list, rabund, sabund, or a list and a group, or a shared before you can use the heatmap.bin command."); m->mothurOutEndLine(); abort = true;
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "HeatMapCommand", "HeatMapCommand");
+ m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
exit(1);
}
}
void HeatMapCommand::help(){
try {
- mothurOut("The heatmap.bin command can only be executed after a successful read.otu command.\n");
- mothurOut("The heatmap.bin command parameters are groups, sorted, scale label. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n");
- mothurOut("The sorted parameter allows you to choose to see the file with the shared otus at the top or the otus in the order they appear in your input file. \n");
- mothurOut("The scale parameter allows you to choose the range of color your bin information will be displayed with.\n");
- mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and are also separated by dashes.\n");
- mothurOut("The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, label=yourLabels).\n");
- mothurOut("Example heatmap.bin(groups=A-B-C, sorted=F, scale=log10).\n");
- mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
- mothurOut("The default value for sorted is T meaning you want the shared otus on top, you may change it to F meaning the exact representation of your input file.\n");
- mothurOut("The default value for scale is log10; your other options are log2 and linear.\n");
- mothurOut("The heatmap.bin command outputs a .svg file for each label you specify.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The heatmap.bin command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The heatmap.bin command parameters are groups, sorted, scale label. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n");
+ m->mothurOut("The sorted parameter allows you to choose to see the file with the shared otus at the top or the otus in the order they appear in your input file. \n");
+ m->mothurOut("The scale parameter allows you to choose the range of color your bin information will be displayed with.\n");
+ m->mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and are also separated by dashes.\n");
+ m->mothurOut("The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, label=yourLabels).\n");
+ m->mothurOut("Example heatmap.bin(groups=A-B-C, sorted=F, scale=log10).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
+ m->mothurOut("The default value for sorted is T meaning you want the shared otus on top, you may change it to F meaning the exact representation of your input file.\n");
+ m->mothurOut("The default value for scale is log10; your other options are log2 and linear.\n");
+ m->mothurOut("The heatmap.bin command outputs a .svg file for each label you specify.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "HeatMapCommand", "help");
+ m->errorOut(e, "HeatMapCommand", "help");
exit(1);
}
}
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
- heatmap->getPic(lookup);
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ outputNames.push_back(heatmap->getPic(lookup));
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
- heatmap->getPic(lookup);
+ outputNames.push_back(heatmap->getPic(lookup));
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
- heatmap->getPic(lookup);
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ outputNames.push_back(heatmap->getPic(lookup));
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
if(allLines == 1 || labels.count(rabund->getLabel()) == 1){
- mothurOut(rabund->getLabel()); mothurOutEndLine();
- heatmap->getPic(rabund);
+ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
+ outputNames.push_back(heatmap->getPic(rabund));
processedLabels.insert(rabund->getLabel());
userLabels.erase(rabund->getLabel());
delete rabund;
rabund = input->getRAbundVector(lastLabel);
- mothurOut(rabund->getLabel()); mothurOutEndLine();
+ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
- heatmap->getPic(rabund);
+ outputNames.push_back(heatmap->getPic(rabund));
processedLabels.insert(rabund->getLabel());
userLabels.erase(rabund->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (rabund != NULL) { delete rabund; }
rabund = input->getRAbundVector(lastLabel);
- mothurOut(rabund->getLabel()); mothurOutEndLine();
+ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
- heatmap->getPic(rabund);
+ outputNames.push_back(heatmap->getPic(rabund));
delete rabund; globaldata->rabund = NULL;
}
globaldata->rabund = NULL;
delete input; globaldata->ginput = NULL;
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "HeatMapCommand", "execute");
+ m->errorOut(e, "HeatMapCommand", "execute");
exit(1);
}
}
bool abort, allLines;
set<string> labels; //holds labels to be used
string format, groups, sorted, scale, label, outputDir;
- vector<string> Groups;
+ vector<string> Groups, outputNames;
};
//**********************************************************************************************************************
HeatMapSim::HeatMapSim(string dir) : outputDir(dir) {
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
}
//**********************************************************************************************************************
-void HeatMapSim::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> calcs) {
+vector<string> HeatMapSim::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> calcs) {
try {
EstOutput data;
vector<double> sims;
+ vector<string> outputNames;
//make file for each calculator selected
for (int m = 0; m < calcs.size(); m++) {
string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + calcs[m]->getName() + ".heatmap.sim.svg";
openOutputFile(filenamesvg, outsvg);
+ outputNames.push_back(filenamesvg);
//svg image
outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString((lookup.size() * 150) + 160) + " " + toString((lookup.size() * 150) + 160) + "\">\n";
}
-
+ return outputNames;
}
catch(exception& e) {
- errorOut(e, "HeatMapSim", "getPic");
+ m->errorOut(e, "HeatMapSim", "getPic");
exit(1);
}
}
//**********************************************************************************************************************
-void HeatMapSim::getPic(vector< vector<double> > dists, vector<string> groups) {
+string HeatMapSim::getPic(vector< vector<double> > dists, vector<string> groups) {
try {
vector<double> sims;
outsvg << "</g>\n</svg>\n";
outsvg.close();
+ return filenamesvg;
+
}
catch(exception& e) {
- errorOut(e, "HeatMapSim", "getPic");
+ m->errorOut(e, "HeatMapSim", "getPic");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "HeatMapSim", "printLegend");
+ m->errorOut(e, "HeatMapSim", "printLegend");
exit(1);
}
}
HeatMapSim(string);
~HeatMapSim(){};
- void getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
- void getPic(vector< vector<double> >, vector<string>);
+ vector<string> getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
+ string getPic(vector< vector<double> >, vector<string>);
private:
void printLegend(int, float);
GlobalData* globaldata;
string format, groupComb, outputDir;
ofstream outsvg;
+ MothurOut* m;
};
//**********************************************************************************************************************
-HeatMapSimCommand::HeatMapSimCommand(string option){
+HeatMapSimCommand::HeatMapSimCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
labels.clear();
Groups.clear();
Estimators.clear();
-
+
//allow user to run help
if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
//error checking on files
- if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == ""))) { mothurOut("You must run the read.otu command or provide a distance file before running the heatmap.sim command."); mothurOutEndLine(); abort = true; }
- else if ((phylipfile != "") && (columnfile != "")) { mothurOut("When running the heatmap.sim command with a distance file you may not use both the column and the phylip parameters."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == ""))) { m->mothurOut("You must run the read.otu command or provide a distance file before running the heatmap.sim command."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the heatmap.sim command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
if (columnfile != "") {
- if (namefile == "") { mothurOut("You need to provide a namefile if you are going to use the column format."); mothurOutEndLine(); abort = true; }
+ if (namefile == "") { m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); abort = true; }
}
if (format == "") { format = "shared"; }
}
catch(exception& e) {
- errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
+ m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
exit(1);
}
}
void HeatMapSimCommand::help(){
try {
- mothurOut("The heatmap.sim command can only be executed after a successful read.otu command, or by providing a distance file.\n");
- mothurOut("The heatmap.sim command parameters are phylip, column, name, groups, calc and label. No parameters are required.\n");
- mothurOut("There are two ways to use the heatmap.sim command. The first is with the read.otu command. \n");
- mothurOut("With the read.otu command you may use the groups, label and calc parameters. \n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n");
- mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and is also separated by dashes.\n");
- mothurOut("The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, label=yourLabels).\n");
- mothurOut("Example heatmap.sim(groups=A-B-C, calc=jabund).\n");
- mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
+ m->mothurOut("The heatmap.sim command can only be executed after a successful read.otu command, or by providing a distance file.\n");
+ m->mothurOut("The heatmap.sim command parameters are phylip, column, name, groups, calc and label. No parameters are required.\n");
+ m->mothurOut("There are two ways to use the heatmap.sim command. The first is with the read.otu command. \n");
+ m->mothurOut("With the read.otu command you may use the groups, label and calc parameters. \n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n");
+ m->mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and is also separated by dashes.\n");
+ m->mothurOut("The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, label=yourLabels).\n");
+ m->mothurOut("Example heatmap.sim(groups=A-B-C, calc=jabund).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
validCalculator->printCalc("heat", cout);
- mothurOut("The default value for calc is jclass-thetayc.\n");
- mothurOut("The heatmap.sim command outputs a .svg file for each calculator you choose at each label you specify.\n");
- mothurOut("The second way to use the heatmap.sim command is with a distance file representing the distance bewteen your groups. \n");
- mothurOut("Using the command this way, the phylip or column parameter are required, and only one may be used. If you use a column file the name filename is required. \n");
- mothurOut("The heatmap.sim command should be in the following format: heatmap.sim(phylip=yourDistanceFile).\n");
- mothurOut("Example heatmap.sim(phylip=amazonGroups.dist).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The default value for calc is jclass-thetayc.\n");
+ m->mothurOut("The heatmap.sim command outputs a .svg file for each calculator you choose at each label you specify.\n");
+ m->mothurOut("The second way to use the heatmap.sim command is with a distance file representing the distance bewteen your groups. \n");
+ m->mothurOut("Using the command this way, the phylip or column parameter are required, and only one may be used. If you use a column file the name filename is required. \n");
+ m->mothurOut("The heatmap.sim command should be in the following format: heatmap.sim(phylip=yourDistanceFile).\n");
+ m->mothurOut("Example heatmap.sim(phylip=amazonGroups.dist).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "HeatMapSimCommand", "help");
+ m->errorOut(e, "HeatMapSimCommand", "help");
exit(1);
}
}
delete heatmap;
delete validCalculator;
-
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "HeatMapSimCommand", "execute");
+ m->errorOut(e, "HeatMapSimCommand", "execute");
exit(1);
}
}
int HeatMapSimCommand::runCommandShared() {
try {
//if the users entered no valid calculators don't execute command
- if (heatCalculators.size() == 0) { mothurOut("No valid calculators."); mothurOutEndLine(); return 0; }
+ if (heatCalculators.size() == 0) { m->mothurOut("No valid calculators."); m->mothurOutEndLine(); return 0; }
//you have groups
read = new ReadOTUFile(globaldata->inputFileName);
lookup = input->getSharedRAbundVectors();
string lastLabel = lookup[0]->getLabel();
- if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups. I cannot run the command."); mothurOutEndLine(); return 0;}
+ if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); return 0;}
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
set<string> processedLabels;
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
- heatmap->getPic(lookup, heatCalculators);
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
- heatmap->getPic(lookup, heatCalculators);
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
- heatmap->getPic(lookup, heatCalculators);
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
return 0;
}
catch(exception& e) {
- errorOut(e, "HeatMapSimCommand", "runCommandShared");
+ m->errorOut(e, "HeatMapSimCommand", "runCommandShared");
exit(1);
}
}
}
- heatmap->getPic(matrix, names); //vector<vector<double>>, vector<string>
+ outputNames.push_back(heatmap->getPic(matrix, names)); //vector<vector<double>>, vector<string>
return 0;
}
catch(exception& e) {
- errorOut(e, "HeatMapSimCommand", "runCommandDist");
+ m->errorOut(e, "HeatMapSimCommand", "runCommandDist");
exit(1);
}
}
bool abort, allLines;
set<string> labels; //holds labels to be used
string format, groups, label, calc, phylipfile, columnfile, namefile, outputDir;
- vector<string> Estimators, Groups;
+ vector<string> Estimators, Groups, outputNames;
int runCommandShared();
int runCommandDist();
//**********************************************************************************************************************
-HelpCommand::HelpCommand(string option){
+HelpCommand::HelpCommand(string option) {
validCommands = CommandFactory::getInstance();
}
int HelpCommand::execute(){
validCommands->printCommands(cout);
- mothurOut("For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'"); mothurOutEndLine();
+ m->mothurOut("For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'"); m->mothurOutEndLine();
- mothurOutEndLine(); mothurOut("For further assistance please refer to the Mothur manual on our wiki at http://www.mothur.org/wiki, or contact Pat Schloss at mothur.bugs@gmail.com.\n");
+ m->mothurOutEndLine(); m->mothurOut("For further assistance please refer to the Mothur manual on our wiki at http://www.mothur.org/wiki, or contact Pat Schloss at mothur.bugs@gmail.com.\n");
return 0;
}
/***********************************************************************/
InputData::InputData(string fName, string f) : format(f){
-
+ m = MothurOut::getInstance();
openInputFile(fName, fileHandle);
filename = fName;
InputData::InputData(string fName, string orderFileName, string f) : format(f){
try {
-
+ m = MothurOut::getInstance();
ifstream ofHandle;
openInputFile(orderFileName, ofHandle);
string name;
openInputFile(fName, fileHandle);
}
catch(exception& e) {
- errorOut(e, "InputData", "InputData");
+ m->errorOut(e, "InputData", "InputData");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getListVector");
+ m->errorOut(e, "InputData", "getListVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getListVector");
+ m->errorOut(e, "InputData", "getListVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedListVector");
+ m->errorOut(e, "InputData", "getSharedListVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedListVector");
+ m->errorOut(e, "InputData", "getSharedListVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedOrderVector");
+ m->errorOut(e, "InputData", "getSharedOrderVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedOrderVector");
+ m->errorOut(e, "InputData", "getSharedOrderVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getOrderVector");
+ m->errorOut(e, "InputData", "getOrderVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getOrderVector");
+ m->errorOut(e, "InputData", "getOrderVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedRAbundVectors");
+ m->errorOut(e, "InputData", "getSharedRAbundVectors");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSharedRAbundVectors");
+ m->errorOut(e, "InputData", "getSharedRAbundVectors");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSAbundVector");
+ m->errorOut(e, "InputData", "getSAbundVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getSAbundVector");
+ m->errorOut(e, "InputData", "getSAbundVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getRAbundVector");
+ m->errorOut(e, "InputData", "getRAbundVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "InputData", "getRAbundVector");
+ m->errorOut(e, "InputData", "getRAbundVector");
exit(1);
}
}
RAbundVector* rabund;
map<string,int> orderMap;
string filename;
+ MothurOut* m;
};
}
}
catch(exception& e) {
- errorOut(e, "Jackknife", "getAMatrix");
+ m->errorOut(e, "Jackknife", "getAMatrix");
exit(1);
}
}
return n;
}
catch(exception& e) {
- errorOut(e, "Jackknife", "CN");
+ m->errorOut(e, "Jackknife", "CN");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Jackknife", "getValues");
+ m->errorOut(e, "Jackknife", "getValues");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "KmerDB", "KmerDB");
+ m->errorOut(e, "KmerDB", "KmerDB");
exit(1);
}
return topMatches;
}
catch(exception& e) {
- errorOut(e, "KmerDB", "findClosestSequences");
+ m->errorOut(e, "KmerDB", "findClosestSequences");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "KmerDB", "generateDB");
+ m->errorOut(e, "KmerDB", "generateDB");
exit(1);
}
count++;
}
catch(exception& e) {
- errorOut(e, "KmerDB", "addSequence");
+ m->errorOut(e, "KmerDB", "addSequence");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "KmerDB", "readKmerDB");
+ m->errorOut(e, "KmerDB", "readKmerDB");
exit(1);
}
}
else { return kmerLocations[kmer].size(); } // kmer is in vector range
}
catch(exception& e) {
- errorOut(e, "KmerDB", "getCount");
+ m->errorOut(e, "KmerDB", "getCount");
exit(1);
}
}
return seqs;
}
catch(exception& e) {
- errorOut(e, "KmerDB", "getSequencesWithKmer");
+ m->errorOut(e, "KmerDB", "getSequencesWithKmer");
exit(1);
}
}
//is this sequence in the taxonomy file
if (it == taxonomy.end()) { //error not in file
- mothurOut("Error: sequence " + names[closest[i]] + " is not in the taxonomy file. It will be eliminated as a match to sequence " + seq->getName() + "."); mothurOutEndLine();
+ m->mothurOut("Error: sequence " + names[closest[i]] + " is not in the taxonomy file. It will be eliminated as a match to sequence " + seq->getName() + "."); m->mothurOutEndLine();
}else{ closestNames.push_back(it->first); }
}
if (closestNames.size() == 0) {
- mothurOut("Error: All the matches for sequence " + seq->getName() + " have been eliminated. " + seq->getName() + " will be disregarded."); mothurOutEndLine();
+ m->mothurOut("Error: All the matches for sequence " + seq->getName() + " have been eliminated. " + seq->getName() + " will be disregarded."); m->mothurOutEndLine();
tax = "bad seq";
}else{
tax = findCommonTaxonomy(closestNames);
- if (tax == "") { mothurOut("There are no common levels for sequence " + seq->getName() + ". " + seq->getName() + " will be disregarded."); mothurOutEndLine(); tax = "bad seq"; }
+ if (tax == "") { m->mothurOut("There are no common levels for sequence " + seq->getName() + ". " + seq->getName() + " will be disregarded."); m->mothurOutEndLine(); tax = "bad seq"; }
}
simpleTax = tax;
return tax;
}
catch(exception& e) {
- errorOut(e, "Knn", "getTaxonomy");
+ m->errorOut(e, "Knn", "getTaxonomy");
exit(1);
}
}
return common;
}
catch(exception& e) {
- errorOut(e, "Knn", "findCommonTaxonomy");
+ m->errorOut(e, "Knn", "findCommonTaxonomy");
exit(1);
}
}
Libshuff::Libshuff(FullMatrix* D, int it, float step, float co) : matrix(D), iters(it), stepSize(step), cutOff(co){
try{
+ m = MothurOut::getInstance();
groupNames = matrix->getGroups();
groupSizes = matrix->getSizes();
numGroups = matrix->getNumGroups();
initializeGroups(matrix);
}
catch(exception& e) {
- errorOut(e, "Libshuff", "Libshuff");
+ m->errorOut(e, "Libshuff", "Libshuff");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Libshuff", "initializeGroups");
+ m->errorOut(e, "Libshuff", "initializeGroups");
exit(1);
}
}
return minX;
}
catch(exception& e) {
- errorOut(e, "Libshuff", "getMinX");
+ m->errorOut(e, "Libshuff", "getMinX");
exit(1);
}
}
return minXY;
}
catch(exception& e) {
- errorOut(e, "Libshuff", "getMinXY");
+ m->errorOut(e, "Libshuff", "getMinXY");
exit(1);
}
}
for(int k=0;k<groupSizes[y];k++) { groups[y][k]=v[index++]; }
}
catch(exception& e) {
- errorOut(e, "Libshuff", "randomizeGroups");
+ m->errorOut(e, "Libshuff", "randomizeGroups");
exit(1);
}
}
float stepSize;
int numGroups;
+ MothurOut* m;
};
#endif
//**********************************************************************************************************************
-LibShuffCommand::LibShuffCommand(string option){
+LibShuffCommand::LibShuffCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
Groups.clear();
-
//allow user to run help
if(option == "help") { help(); abort = true; }
//make sure the user has already run the read.dist command
if ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL)) {
- mothurOut("You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. "); mothurOutEndLine(); abort = true;;
+ m->mothurOut("You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. "); m->mothurOutEndLine(); abort = true;;
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "LibShuffCommand");
+ m->errorOut(e, "LibShuffCommand", "LibShuffCommand");
exit(1);
}
}
void LibShuffCommand::help(){
try {
- mothurOut("The libshuff command can only be executed after a successful read.dist command including a groupfile.\n");
- mothurOut("The libshuff command parameters are groups, iters, step, form and cutoff. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
- mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random matrices you would like compared to your matrix.\n");
- mothurOut("The step parameter allows you to specify change in distance you would like between each output if you are using the discrete form.\n");
- mothurOut("The form parameter allows you to specify if you would like to analyze your matrix using the discrete or integral form. Your options are integral or discrete.\n");
- mothurOut("The libshuff command should be in the following format: libshuff(groups=yourGroups, iters=yourIters, cutOff=yourCutOff, form=yourForm, step=yourStep).\n");
- mothurOut("Example libshuff(groups=A-B-C, iters=500, form=discrete, step=0.01, cutOff=2.0).\n");
- mothurOut("The default value for groups is all the groups in your groupfile, iters is 10000, cutoff is 1.0, form is integral and step is 0.01.\n");
- mothurOut("The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters).\n\n");
+ m->mothurOut("The libshuff command can only be executed after a successful read.dist command including a groupfile.\n");
+ m->mothurOut("The libshuff command parameters are groups, iters, step, form and cutoff. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
+ m->mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random matrices you would like compared to your matrix.\n");
+ m->mothurOut("The step parameter allows you to specify change in distance you would like between each output if you are using the discrete form.\n");
+ m->mothurOut("The form parameter allows you to specify if you would like to analyze your matrix using the discrete or integral form. Your options are integral or discrete.\n");
+ m->mothurOut("The libshuff command should be in the following format: libshuff(groups=yourGroups, iters=yourIters, cutOff=yourCutOff, form=yourForm, step=yourStep).\n");
+ m->mothurOut("Example libshuff(groups=A-B-C, iters=500, form=discrete, step=0.01, cutOff=2.0).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, iters is 10000, cutoff is 1.0, form is integral and step is 0.01.\n");
+ m->mothurOut("The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters).\n\n");
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "help");
+ m->errorOut(e, "LibShuffCommand", "help");
exit(1);
}
}
reading->finish();
delete reading;
- mothurOutEndLine();
+ m->mothurOutEndLine();
printSummaryFile();
printCoverageFile();
//delete globaldata's copy of the gmatrix to free up memory
delete globaldata->gMatrix; globaldata->gMatrix = NULL;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "execute");
+ m->errorOut(e, "LibShuffCommand", "execute");
exit(1);
}
}
ofstream outCov;
summaryFile = outputDir + getRootName(getSimpleName(globaldata->getPhylipFile())) + "libshuff.coverage";
openOutputFile(summaryFile, outCov);
+ outputNames.push_back(summaryFile);
outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
//cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
outCov.close();
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "printCoverageFile");
+ m->errorOut(e, "LibShuffCommand", "printCoverageFile");
exit(1);
}
}
ofstream outSum;
summaryFile = outputDir + getRootName(getSimpleName(globaldata->getPhylipFile())) + "libshuff.summary";
openOutputFile(summaryFile, outSum);
+ outputNames.push_back(summaryFile);
outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
cout << setw(20) << left << "Comparison" << '\t' << setprecision(8) << "dCXYScore" << '\t' << "Significance" << endl;
- mothurOutJustToLog("Comparison\tdCXYScore\tSignificance"); mothurOutEndLine();
+ m->mothurOutJustToLog("Comparison\tdCXYScore\tSignificance"); m->mothurOutEndLine();
outSum << setw(20) << left << "Comparison" << '\t' << setprecision(8) << "dCXYScore" << '\t' << "Significance" << endl;
int precision = (int)log10(iters);
if(pValueCounts[i][j]){
cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
- mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((pValueCounts[i][j]/(float)iters))); mothurOutEndLine();
+ m->mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((pValueCounts[i][j]/(float)iters))); m->mothurOutEndLine();
outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
}
else{
cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
- mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((1/(float)iters))); mothurOutEndLine();
+ m->mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((1/(float)iters))); m->mothurOutEndLine();
outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
}
if(pValueCounts[j][i]){
cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
- mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((pValueCounts[j][i]/(float)iters))); mothurOutEndLine();
+ m->mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((pValueCounts[j][i]/(float)iters))); m->mothurOutEndLine();
outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
}
else{
cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
- mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((1/(float)iters))); mothurOutEndLine();
+ m->mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((1/(float)iters))); m->mothurOutEndLine();
outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
}
}
outSum.close();
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "printSummaryFile");
+ m->errorOut(e, "LibShuffCommand", "printSummaryFile");
exit(1);
}
}
//check that groups are valid
for (int i = 0; i < globaldata->Groups.size(); i++) {
if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
- mothurOut(globaldata->Groups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
+ m->mothurOut(globaldata->Groups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
// erase the invalid group from globaldata->Groups
globaldata->Groups.erase(globaldata->Groups.begin()+i);
}
for (int i=0; i < numGroups; i++) {
globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
}
- mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
} else { numGroups = globaldata->Groups.size(); }
} else { //users wants all groups
numGroups = globaldata->gGroupmap->getNumGroups();
}
catch(exception& e) {
- errorOut(e, "LibShuffCommand", "setGroups");
+ m->errorOut(e, "LibShuffCommand", "setGroups");
exit(1);
}
}
bool abort;
string outputFile, groups, userform, savegroups, outputDir;
- vector<string> Groups; //holds groups to be used
+ vector<string> Groups, outputNames; //holds groups to be used
};
#endif
//**********************************************************************************************************************
-ListSeqsCommand::ListSeqsCommand(string option){
+ListSeqsCommand::ListSeqsCommand(string option) {
try {
abort = false;
else if (listfile == "not found") { listfile = ""; }
- if ((fastafile == "") && (namefile == "") && (listfile == "") && (groupfile == "") && (alignfile == "")) { mothurOut("You must provide a file."); mothurOutEndLine(); abort = true; }
+ if ((fastafile == "") && (namefile == "") && (listfile == "") && (groupfile == "") && (alignfile == "")) { m->mothurOut("You must provide a file."); m->mothurOutEndLine(); abort = true; }
int okay = 1;
if (outputDir != "") { okay++; }
- if (parameters.size() > okay) { mothurOut("You may only enter one file."); mothurOutEndLine(); abort = true; }
+ if (parameters.size() > okay) { m->mothurOut("You may only enter one file."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "ListSeqsCommand");
+ m->errorOut(e, "ListSeqsCommand", "ListSeqsCommand");
exit(1);
}
}
void ListSeqsCommand::help(){
try {
- mothurOut("The list.seqs command reads a fasta, name, group, list or alignreport file and outputs a .accnos file containing sequence names.\n");
- mothurOut("The list.seqs command parameters are fasta, name, group and alignreport. You must provide one of these parameters.\n");
- mothurOut("The list.seqs command should be in the following format: list.seqs(fasta=yourFasta).\n");
- mothurOut("Example list.seqs(fasta=amazon.fasta).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The list.seqs command reads a fasta, name, group, list or alignreport file and outputs a .accnos file containing sequence names.\n");
+ m->mothurOut("The list.seqs command parameters are fasta, name, group and alignreport. You must provide one of these parameters.\n");
+ m->mothurOut("The list.seqs command should be in the following format: list.seqs(fasta=yourFasta).\n");
+ m->mothurOut("Example list.seqs(fasta=amazon.fasta).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "help");
+ m->errorOut(e, "ListSeqsCommand", "help");
exit(1);
}
}
}
out.close();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "execute");
+ m->errorOut(e, "ListSeqsCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "readFasta");
+ m->errorOut(e, "ListSeqsCommand", "readFasta");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "readList");
+ m->errorOut(e, "ListSeqsCommand", "readList");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "readName");
+ m->errorOut(e, "ListSeqsCommand", "readName");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "readGroup");
+ m->errorOut(e, "ListSeqsCommand", "readGroup");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ListSeqsCommand", "readAlign");
+ m->errorOut(e, "ListSeqsCommand", "readAlign");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "ListVector", "ListVector");
+ m->errorOut(e, "ListVector", "ListVector");
exit(1);
}
}
gobble(f);
}
catch(exception& e) {
- errorOut(e, "ListVector", "ListVector");
+ m->errorOut(e, "ListVector", "ListVector");
exit(1);
}
}
numSeqs += (nNames_new - nNames_old);
}
catch(exception& e) {
- errorOut(e, "ListVector", "set");
+ m->errorOut(e, "ListVector", "set");
exit(1);
}
}
numSeqs += nNames;
}
catch(exception& e) {
- errorOut(e, "ListVector", "push_back");
+ m->errorOut(e, "ListVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "ListVector", "print");
+ m->errorOut(e, "ListVector", "print");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "ListVector", "getRAbundVector");
+ m->errorOut(e, "ListVector", "getRAbundVector");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "ListVector", "getSAbundVector");
+ m->errorOut(e, "ListVector", "getSAbundVector");
exit(1);
}
}
}
else{
if(orderMap->count(seqName) == 0){
- mothurOut(seqName + " not found, check *.names file\n");
+ m->mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
}
if(orderMap->count(seqName) == 0){
- mothurOut(seqName + " not found, check *.names file\n");
+ m->mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
ov.set((*orderMap)[seqName], i);
}
}
catch(exception& e) {
- errorOut(e, "ListVector", "getOrderVector");
+ m->errorOut(e, "ListVector", "getOrderVector");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "LogSD", "getValues");
+ m->errorOut(e, "LogSD", "getValues");
exit(1);
}
}
/***********************************************************************/
Maligner::Maligner(vector<Sequence*> temp, int num, int match, int misMatch, float div, int ms, int minCov, string mode, Database* dataLeft, Database* dataRight) :
- db(temp), numWanted(num), matchScore(match), misMatchPenalty(misMatch), minDivR(div), minSimilarity(ms), minCoverage(minCov), searchMethod(mode), databaseLeft(dataLeft), databaseRight(dataRight) {}
+ db(temp), numWanted(num), matchScore(match), misMatchPenalty(misMatch), minDivR(div), minSimilarity(ms), minCoverage(minCov), searchMethod(mode), databaseLeft(dataLeft), databaseRight(dataRight) { m = MothurOut::getInstance(); }
/***********************************************************************/
string Maligner::getResults(Sequence* q, DeCalculator* decalc) {
try {
refSeqs = getBlastSeqs(query, numWanted); //fills indexes
}else if (searchMethod == "kmer") {
refSeqs = getKmerSeqs(query, numWanted); //fills indexes
- }else { mothurOut("not valid search."); exit(1); } //should never get here
+ }else { m->mothurOut("not valid search."); exit(1); } //should never get here
refSeqs = minCoverageFilter(refSeqs);
return chimera;
}
catch(exception& e) {
- errorOut(e, "Maligner", "getResults");
+ m->errorOut(e, "Maligner", "getResults");
exit(1);
}
}
return chimera;
}
catch(exception& e) {
- errorOut(e, "Maligner", "chimeraMaligner");
+ m->errorOut(e, "Maligner", "chimeraMaligner");
exit(1);
}
}
return newRefs;
}
catch(exception& e) {
- errorOut(e, "Maligner", "minCoverageFilter");
+ m->errorOut(e, "Maligner", "minCoverageFilter");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Maligner", "computeChimeraPenalty");
+ m->errorOut(e, "Maligner", "computeChimeraPenalty");
exit(1);
}
}
spotMap = newMap;
}
catch(exception& e) {
- errorOut(e, "Maligner", "verticalFilter");
+ m->errorOut(e, "Maligner", "verticalFilter");
exit(1);
}
}
return m;
}
catch(exception& e) {
- errorOut(e, "Maligner", "buildScoreMatrix");
+ m->errorOut(e, "Maligner", "buildScoreMatrix");
exit(1);
}
}
//***************************************************************************************************************
-void Maligner::fillScoreMatrix(vector<vector<score_struct> >& m, vector<Sequence*> seqs, int penalty) {
+void Maligner::fillScoreMatrix(vector<vector<score_struct> >& ms, vector<Sequence*> seqs, int penalty) {
try{
//get matrix dimensions
//are you both gaps?
if ((!isalpha(queryAligned[0])) && (!isalpha(subjectAligned[0]))) {
- m[i][0].score = 0;
+ ms[i][0].score = 0;
}else if (queryAligned[0] == subjectAligned[0]) {
- m[i][0].score = matchScore;
+ ms[i][0].score = matchScore;
}else{
- m[i][0].score = 0;
+ ms[i][0].score = 0;
}
}
//compute score based on previous columns scores
for (int prevIndex = 0; prevIndex < numRows; prevIndex++) { //iterate through rows
- int sumScore = matchMisMatchScore + m[prevIndex][j-1].score;
+ int sumScore = matchMisMatchScore + ms[prevIndex][j-1].score;
//you are not at yourself
if (prevIndex != i) { sumScore += penalty; }
if (sumScore < 0) { sumScore = 0; }
- if (sumScore > m[i][j].score) {
- m[i][j].score = sumScore;
- m[i][j].prev = prevIndex;
+ if (sumScore > ms[i][j].score) {
+ ms[i][j].score = sumScore;
+ ms[i][j].prev = prevIndex;
}
}
}
}
catch(exception& e) {
- errorOut(e, "Maligner", "fillScoreMatrix");
+ m->errorOut(e, "Maligner", "fillScoreMatrix");
exit(1);
}
}
//***************************************************************************************************************
-vector<score_struct> Maligner::extractHighestPath(vector<vector<score_struct> > m) {
+vector<score_struct> Maligner::extractHighestPath(vector<vector<score_struct> > ms) {
try {
//get matrix dimensions
int numCols = query->getAligned().length();
- int numRows = m.size();
+ int numRows = ms.size();
//find highest score scoring matrix
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numCols; j++) {
- if (m[i][j].score > highestScore) {
- highestScore = m[i][j].score;
- highestStruct = m[i][j];
+ if (ms[i][j].score > highestScore) {
+ highestScore = ms[i][j].score;
+ highestStruct = ms[i][j];
}
}
}
int score = highestStruct.score;
while (pos >= 0 && score > 0) {
- score_struct temp = m[rowIndex][pos];
+ score_struct temp = ms[rowIndex][pos];
score = temp.score;
if (score > 0) { path.push_back(temp); }
}
catch(exception& e) {
- errorOut(e, "Maligner", "extractHighestPath");
+ m->errorOut(e, "Maligner", "extractHighestPath");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Maligner", "mapTraceRegionsToAlignment");
+ m->errorOut(e, "Maligner", "mapTraceRegionsToAlignment");
exit(1);
}
}
return chimera;
}
catch(exception& e) {
- errorOut(e, "Maligner", "constructChimericSeq");
+ m->errorOut(e, "Maligner", "constructChimericSeq");
exit(1);
}
}
try {
if (queryAlign.length() != chimera.length()) {
- mothurOut("Error, alignment strings are of different lengths: "); mothurOutEndLine();
- mothurOut(toString(queryAlign.length())); mothurOutEndLine(); mothurOutEndLine(); mothurOutEndLine(); mothurOutEndLine();
- mothurOut(toString(chimera.length())); mothurOutEndLine();
+ m->mothurOut("Error, alignment strings are of different lengths: "); m->mothurOutEndLine();
+ m->mothurOut(toString(queryAlign.length())); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOutEndLine();
+ m->mothurOut(toString(chimera.length())); m->mothurOutEndLine();
return -1.0;
}
}
catch(exception& e) {
- errorOut(e, "Maligner", "computePercentID");
+ m->errorOut(e, "Maligner", "computePercentID");
exit(1);
}
}
vector<int> tempIndexesRight = database->findClosestMegaBlast(queryRight, num+1);
vector<int> tempIndexesLeft = database->findClosestMegaBlast(queryLeft, num+1);
- //if ((tempIndexesRight.size() != (num+1)) || (tempIndexesLeft.size() != (num+1))) { mothurOut("megablast returned " + toString(tempIndexesRight.size()) + " results for the right end, and " + toString(tempIndexesLeft.size()) + " for the left end. Needed " + toString(num+1) + ". Unable to porcess sequence " + q->getName()); mothurOutEndLine(); return refResults; }
+ //if ((tempIndexesRight.size() != (num+1)) || (tempIndexesLeft.size() != (num+1))) { m->mothurOut("megablast returned " + toString(tempIndexesRight.size()) + " results for the right end, and " + toString(tempIndexesLeft.size()) + " for the left end. Needed " + toString(num+1) + ". Unable to porcess sequence " + q->getName()); m->mothurOutEndLine(); return refResults; }
vector<int> smaller;
vector<int> larger;
return refResults;
}
catch(exception& e) {
- errorOut(e, "Maligner", "getBlastSeqs");
+ m->errorOut(e, "Maligner", "getBlastSeqs");
exit(1);
}
}
return refResults;
}
catch(exception& e) {
- errorOut(e, "Maligner", "getBlastSeqs");
+ m->errorOut(e, "Maligner", "getBlastSeqs");
exit(1);
}
}
string chimeraMaligner(int, DeCalculator*);
vector<Sequence*> getBlastSeqs(Sequence*, int);
vector<Sequence*> getKmerSeqs(Sequence*, int);
+ MothurOut* m;
};
//**********************************************************************************************************************
-MatrixOutputCommand::MatrixOutputCommand(string option){
+MatrixOutputCommand::MatrixOutputCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the dist.shared command."); mothurOutEndLine(); abort = true; }
- else if (globaldata->getGroupFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the dist.shared command."); mothurOutEndLine(); abort = true; }
+ if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the dist.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if (globaldata->getGroupFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the dist.shared command."); m->mothurOutEndLine(); abort = true; }
}
//check for optional parameter and set defaults
}
output = validParameter.validFile(parameters, "output", false); if(output == "not found"){ output = "lt"; }
- if ((output != "lt") && (output != "square")) { mothurOut(output + " is not a valid output form. Options are lt and square. I will use lt."); mothurOutEndLine(); output = "lt"; }
+ if ((output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are lt and square. I will use lt."); m->mothurOutEndLine(); output = "lt"; }
//if the user has not specified any labels use the ones from read.otu
if (label == "") {
}
catch(exception& e) {
- errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
+ m->errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
exit(1);
}
}
void MatrixOutputCommand::help(){
try {
- mothurOut("The dist.shared command can only be executed after a successful read.otu command.\n");
- mothurOut("The dist.shared command parameters are groups, calc, output and label. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
- mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like distance matrices created for, and is also separated by dashes.\n");
- mothurOut("The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n");
- mothurOut("The output parameter allows you to specify format of your distance matrix. Options are lt, and square. The default is lt.\n");
- mothurOut("Example dist.shared(groups=A-B-C, calc=jabund-sorabund).\n");
- mothurOut("The default value for groups is all the groups in your groupfile.\n");
- mothurOut("The default value for calc is jclass and thetayc.\n");
+ m->mothurOut("The dist.shared command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The dist.shared command parameters are groups, calc, output and label. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
+ m->mothurOut("The group names are separated by dashes. The label parameter allows you to select what distance levels you would like distance matrices created for, and is also separated by dashes.\n");
+ m->mothurOut("The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n");
+ m->mothurOut("The output parameter allows you to specify format of your distance matrix. Options are lt, and square. The default is lt.\n");
+ m->mothurOut("Example dist.shared(groups=A-B-C, calc=jabund-sorabund).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+ m->mothurOut("The default value for calc is jclass and thetayc.\n");
validCalculator->printCalc("matrix", cout);
- mothurOut("The dist.shared command outputs a .dist file for each calculator you specify at each distance you choose.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The dist.shared command outputs a .dist file for each calculator you specify at each distance you choose.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "MatrixOutputCommand", "help");
+ m->errorOut(e, "MatrixOutputCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
//if the users entered no valid calculators don't execute command
- if (matrixCalculators.size() == 0) { mothurOut("No valid calculators."); mothurOutEndLine(); return 0; }
+ if (matrixCalculators.size() == 0) { m->mothurOut("No valid calculators."); m->mothurOutEndLine(); return 0; }
//you have groups
read = new ReadOTUFile(globaldata->inputFileName);
set<string> processedLabels;
set<string> userLabels = labels;
- if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups. I cannot run the command."); mothurOutEndLine(); return 0;}
+ if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); return 0;}
numGroups = lookup.size();
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
//reset groups parameter
globaldata->Groups.clear();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "MatrixOutputCommand", "execute");
+ m->errorOut(e, "MatrixOutputCommand", "execute");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "MatrixOutputCommand", "printSims");
+ m->errorOut(e, "MatrixOutputCommand", "printSims");
exit(1);
}
}
exportFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist";
openOutputFile(exportFileName, out);
+ outputNames.push_back(exportFileName);
+
printSims(out);
out.close();
}
catch(exception& e) {
- errorOut(e, "MatrixOutputCommand", "process");
+ m->errorOut(e, "MatrixOutputCommand", "process");
exit(1);
}
}
bool abort, allLines;
set<string> labels; //holds labels to be used
string outputFile, calc, groups, label, outputDir;
- vector<string> Estimators, Groups; //holds estimators to be used
+ vector<string> Estimators, Groups, outputNames; //holds estimators to be used
};
//**********************************************************************************************************************
-MergeFileCommand::MergeFileCommand(string option){
+MergeFileCommand::MergeFileCommand(string option) {
try {
abort = false;
if (inputDir == "not found"){ inputDir = ""; }
string fileList = validParameter.validFile(parameters, "input", false);
- if(fileList == "not found") { mothurOut("you must enter two or more file names"); mothurOutEndLine(); abort=true; }
+ if(fileList == "not found") { m->mothurOut("you must enter two or more file names"); m->mothurOutEndLine(); abort=true; }
else{ splitAtDash(fileList, fileNames); }
//if the user changes the output directory command factory will send this info to us in the output parameter
numInputFiles = fileNames.size();
ifstream testFile;
if(numInputFiles == 0){
- mothurOut("you must enter two or more file names and you entered " + toString(fileNames.size()) + " file names"); mothurOutEndLine();
+ m->mothurOut("you must enter two or more file names and you entered " + toString(fileNames.size()) + " file names"); m->mothurOutEndLine();
abort=true;
}
else{
}
outputFileName = validParameter.validFile(parameters, "output", false);
- if (outputFileName == "not found") { mothurOut("you must enter an output file name"); mothurOutEndLine(); abort=true; }
+ if (outputFileName == "not found") { m->mothurOut("you must enter an output file name"); m->mothurOutEndLine(); abort=true; }
else if (outputDir != "") { outputFileName = outputDir + getSimpleName(outputFileName); }
}
}
catch(exception& e) {
- errorOut(e, "MergeFileCommand", "MergeFileCommand");
+ m->errorOut(e, "MergeFileCommand", "MergeFileCommand");
exit(1);
}
}
}
outputFile.close();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "MergeFileCommand", "execute");
+ m->errorOut(e, "MergeFileCommand", "execute");
exit(1);
}
}
void MergeFileCommand::help(){
try {
- mothurOut("The merge.file command..."); mothurOutEndLine();
+ m->mothurOut("The merge.file command..."); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "MergeFileCommand", "help");
+ m->errorOut(e, "MergeFileCommand", "help");
exit(1);
}
}
#include "mgclustercommand.h"
//**********************************************************************************************************************
-MGClusterCommand::MGClusterCommand(string option){
+MGClusterCommand::MGClusterCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
- if ((blastfile == "")) { mothurOut("When executing a mgcluster command you must provide a blastfile."); mothurOutEndLine(); abort = true; }
+ if ((blastfile == "")) { m->mothurOut("When executing a mgcluster command you must provide a blastfile."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
string temp;
if (method == "not found") { method = "furthest"; }
if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
- else { mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); mothurOutEndLine(); abort = true; }
+ else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
temp = validParameter.validFile(parameters, "length", false); if (temp == "not found") { temp = "5"; }
convert(temp, length);
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "MGClusterCommand");
+ m->errorOut(e, "MGClusterCommand", "MGClusterCommand");
exit(1);
}
}
void MGClusterCommand::help(){
try {
- mothurOut("The mgcluster command parameter options are blast, name, cutoff, precision, method, merge, min, length, penalty and hcluster. The blast parameter is required.\n");
- mothurOut("The mgcluster command reads a blast and name file and clusters the sequences into OPF units similiar to the OTUs.\n");
- mothurOut("This command outputs a .list, .rabund and .sabund file that can be used with mothur other commands to estimate richness.\n");
- mothurOut("The cutoff parameter is used to specify the maximum distance you would like to cluster to. The default is 0.70.\n");
- mothurOut("The precision parameter's default value is 100. \n");
- mothurOut("The acceptable mgcluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n");
- mothurOut("The min parameter allows you to specify is you want the minimum or maximum blast score ratio used in calculating the distance. The default is true, meaning you want the minimum.\n");
- mothurOut("The length parameter is used to specify the minimum overlap required. The default is 5.\n");
- mothurOut("The penalty parameter is used to adjust the error rate. The default is 0.10.\n");
- mothurOut("The merge parameter allows you to shut off merging based on overlaps and just cluster. By default merge is true, meaning you want to merge.\n");
- mothurOut("The hcluster parameter allows you to use the hcluster algorithm when clustering. This may be neccessary if your file is too large to fit into RAM. The default is false.\n");
- mothurOut("The mgcluster command should be in the following format: \n");
- mothurOut("mgcluster(blast=yourBlastfile, name=yourNameFile, cutoff=yourCutOff).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. balst), '=' and parameters (i.e.yourBlastfile).\n\n");
+ m->mothurOut("The mgcluster command parameter options are blast, name, cutoff, precision, method, merge, min, length, penalty and hcluster. The blast parameter is required.\n");
+ m->mothurOut("The mgcluster command reads a blast and name file and clusters the sequences into OPF units similiar to the OTUs.\n");
+ m->mothurOut("This command outputs a .list, .rabund and .sabund file that can be used with mothur other commands to estimate richness.\n");
+ m->mothurOut("The cutoff parameter is used to specify the maximum distance you would like to cluster to. The default is 0.70.\n");
+ m->mothurOut("The precision parameter's default value is 100. \n");
+ m->mothurOut("The acceptable mgcluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n");
+ m->mothurOut("The min parameter allows you to specify is you want the minimum or maximum blast score ratio used in calculating the distance. The default is true, meaning you want the minimum.\n");
+ m->mothurOut("The length parameter is used to specify the minimum overlap required. The default is 5.\n");
+ m->mothurOut("The penalty parameter is used to adjust the error rate. The default is 0.10.\n");
+ m->mothurOut("The merge parameter allows you to shut off merging based on overlaps and just cluster. By default merge is true, meaning you want to merge.\n");
+ m->mothurOut("The hcluster parameter allows you to use the hcluster algorithm when clustering. This may be neccessary if your file is too large to fit into RAM. The default is false.\n");
+ m->mothurOut("The mgcluster command should be in the following format: \n");
+ m->mothurOut("mgcluster(blast=yourBlastfile, name=yourNameFile, cutoff=yourCutOff).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. balst), '=' and parameters (i.e.yourBlastfile).\n\n");
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "help");
+ m->errorOut(e, "MGClusterCommand", "help");
exit(1);
}
}
globaldata->setListFile(fileroot+ tag + ".list");
globaldata->setFormat("list");
-
- mothurOut("It took " + toString(time(NULL) - start) + " seconds to cluster."); mothurOutEndLine();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(fileroot+ tag + ".list"); m->mothurOutEndLine();
+ m->mothurOut(fileroot+ tag + ".rabund"); m->mothurOutEndLine();
+ m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
+ m->mothurOut("It took " + toString(time(NULL) - start) + " seconds to cluster."); m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "execute");
+ m->errorOut(e, "MGClusterCommand", "execute");
exit(1);
}
}
sabund.print(sabundFile);
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "printData");
+ m->errorOut(e, "MGClusterCommand", "printData");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "mergeOPFs");
+ m->errorOut(e, "MGClusterCommand", "mergeOPFs");
exit(1);
}
}
overlapFile = sortedOverlapFile;
}
catch(exception& e) {
- errorOut(e, "MGClusterCommand", "sortHclusterFiles");
+ m->errorOut(e, "MGClusterCommand", "sortHclusterFiles");
exit(1);
}
}
#include "mothur.h"
#include "engine.hpp"
#include "globaldata.hpp"
+#include "mothurout.h"
/**************************************************************************************************/
GlobalData* GlobalData::_uniqueInstance = 0;
CommandFactory* CommandFactory::_uniqueInstance = 0;
+MothurOut* MothurOut::_uniqueInstance = 0;
int main(int argc, char *argv[]){
+ MothurOut* m = MothurOut::getInstance();
try {
- string log = "mothur.logFile";
- remove(log.c_str());
+ //string log = "mothur.logFile";
+ //remove(log.c_str());
time_t ltime = time(NULL); /* calendar time */
string logFileName = "mothur." + toString(ltime) + ".logfile";
+ m->setFileName(logFileName);
+
//version
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
system("clear");
#if defined (__APPLE__) || (__MACH__)
- mothurOutJustToLog("Mac version");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Mac version");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
#else
- mothurOutJustToLog("Linux version");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Linux version");
+ >m->mothurOutEndLine(); m->mothurOutEndLine();
#endif
#else
system("CLS");
- mothurOutJustToLog("Windows version");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Windows version");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
#endif
#ifdef USE_READLINE
- mothurOutJustToLog("Using ReadLine");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Using ReadLine");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
#endif
//header
- mothurOut("mothur v.1.8");
- mothurOutEndLine();
- mothurOut("Last updated: 2/02/2010");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("by");
- mothurOutEndLine();
- mothurOut("Patrick D. Schloss");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Department of Microbiology & Immunology");
- mothurOutEndLine();
- mothurOut("University of Michigan");
- mothurOutEndLine();
- mothurOut("pschloss@umich.edu");
- mothurOutEndLine();
- mothurOut("http://www.mothur.org");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("When using, please cite:");
- mothurOutEndLine();
- mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41.");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Distributed under the GNU General Public License");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Type 'help()' for information on the commands that are available");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Type 'quit()' to exit program");
- mothurOutEndLine();
+ m->mothurOut("mothur v.1.8");
+ m->mothurOutEndLine();
+ m->mothurOut("Last updated: 2/02/2010");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("by");
+ m->mothurOutEndLine();
+ m->mothurOut("Patrick D. Schloss");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Department of Microbiology & Immunology");
+ m->mothurOutEndLine();
+ m->mothurOut("University of Michigan");
+ m->mothurOutEndLine();
+ m->mothurOut("pschloss@umich.edu");
+ m->mothurOutEndLine();
+ m->mothurOut("http://www.mothur.org");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("When using, please cite:");
+ m->mothurOutEndLine();
+ m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41.");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Distributed under the GNU General Public License");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Type 'help()' for information on the commands that are available");
+ m->mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("Type 'quit()' to exit program");
+ m->mothurOutEndLine();
//srand(54321);
input = argv[1];
if (input[0] == '#') {
- mothurOutJustToLog("Script Mode");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Script Mode");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
mothur = new ScriptEngine(argv[0], argv[1]);
}else{
- mothurOutJustToLog("Batch Mode");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Batch Mode");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
mothur = new BatchEngine(argv[0], argv[1]);
}
}
else{
- mothurOutJustToLog("Interactive Mode");
- mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutJustToLog("Interactive Mode");
+ m->mothurOutEndLine(); m->mothurOutEndLine();
mothur = new InteractEngine(argv[0]);
}
while(bail == 0) { bail = mothur->getInput(); }
string outputDir = mothur->getOutputDir();
- logFileName = outputDir + logFileName;
+ string newlogFileName = outputDir + logFileName;
- //need this because mothur.h makes the logfile, but doesn't know where to put it
- rename(log.c_str(), logFileName.c_str()); //logfile with timestamp
+ //need this because m->mothurOut makes the logfile, but doesn't know where to put it
+ rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
delete mothur;
return 0;
}
catch(exception& e) {
- errorOut(e, "mothur", "main");
+ m->errorOut(e, "mothur", "main");
exit(1);
}
}
fileHandle.open(fileName.c_str(), ios::app);
if(!fileHandle) {
- cout << "Error: Could not open " << fileName << endl;
+ cout << "Error: Could not open " << fileName << endl;
return 1;
}
else {
}
}
-/**************************************************************************************************/
-
-inline void mothurOut(string message) {
- try{
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- cout << message;
- out << message;
-
- out.close();
- }
- catch(exception& e) {
- cout << "Error in mothur class mothurOut" << endl;
- exit(1);
- }
-}
-/**************************************************************************************************/
-
-inline void mothurOut(string message, string precision) {
- try{
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- cout << precision << message;
- out << precision << message;
-
- out.close();
- }
- catch(exception& e) {
- cout << "Error in mothur class mothurOut" << endl;
- exit(1);
- }
-}
-
-/**************************************************************************************************/
-
-inline void mothurOutEndLine() {
- try {
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- cout << endl;
- out << endl;
-
- out.close();
- }
- catch(exception& e) {
- cout << "error in mothur mothurOutEndLine" << endl;
- exit(1);
- }
-}
-
-
-/**************************************************************************************************/
-
-inline void errorOut(exception& e, string object, string function) {
-
- mothurOut("Error: ");
- mothurOut(toString(e.what()));
- mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");
- mothurOutEndLine();
-
-}
-
/***********************************************************************/
inline bool isTrue(string f){
ifstream fileHandle;
fileHandle.open(fileName.c_str());
if(!fileHandle) {
- mothurOut("Error: Could not open " + fileName); mothurOutEndLine();
+ cout << "Error: Could not open " << fileName << endl;
return false;
}else {
//check for blank file
inline string getFullPathName(string fileName){
try{
+
string path = hasPath(fileName);
string newFileName;
int pos;
}else if (path[(pos-1)] == '/') { //you want the current working dir ./
path = path.substr(0, pos);
}else if (pos == 1) { break;
- }else { mothurOut("cannot resolve path for " + fileName); mothurOutEndLine(); return fileName; }
+ }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
}
for (int i = index; i >= 0; i--) {
}else if (path[(pos-1)] == '\\') { //you want the current working dir ./
path = path.substr(0, pos);
}else if (pos == 1) { break;
- }else { mothurOut("cannot resolve path for " + fileName); mothurOutEndLine(); return fileName; }
+ }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
}
for (int i = index; i >= 0; i--) {
}
}
catch(exception& e) {
- errorOut(e, "getFullPathName", "getFullPathName");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function getFullPathName. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
-
-
+ }
}
/***********************************************************************/
/***********************************************************************/
inline int openInputFile(string fileName, ifstream& fileHandle){
+
//get full path name
string completeFileName = getFullPathName(fileName);
fileHandle.open(completeFileName.c_str());
if(!fileHandle) {
- mothurOut("Error: Could not open " + completeFileName); mothurOutEndLine();
+ cout << "Error: Could not open " << completeFileName << endl;
return 1;
}
else {
//check for blank file
gobble(fileHandle);
- if (fileHandle.eof()) { mothurOut(completeFileName + " is blank. Please correct."); mothurOutEndLine(); return 1; }
+ if (fileHandle.eof()) { cout << completeFileName << " is blank. Please correct." << endl; return 1; }
return 0;
}
/***********************************************************************/
inline int openOutputFile(string fileName, ofstream& fileHandle){
-
+
string completeFileName = getFullPathName(fileName);
fileHandle.open(completeFileName.c_str(), ios::trunc);
if(!fileHandle) {
- mothurOut("Error: Could not open " + completeFileName); mothurOutEndLine();
+ cout << "Error: Could not open " << completeFileName << endl;
return 1;
}
else {
container.push_back(estim);
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtDash");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/***********************************************************************/
container.insert(estim);
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtDash");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/***********************************************************************/
//This function parses the line options and puts them in a set
container.insert(lineNum);
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtDash");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/***********************************************************************/
//This function parses the a string and puts peices in a vector
container.push_back(estim);
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtComma");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/***********************************************************************/
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtComma");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/***********************************************************************/
}
}
catch(exception& e) {
- errorOut(e, "mothur", "splitAtEquals");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtEquals. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/**************************************************************************************************/
return false;
}
catch(exception& e) {
- errorOut(e, "mothur", "inUsersGroups");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/**************************************************************************************************/
//returns true if any of the strings in first vector are in second vector
return false;
}
catch(exception& e) {
- errorOut(e, "mothur", "inUsersGroups");
- exit(1);
- }
-}
-
-/**************************************************************************************************/
-
-inline void mothurOutJustToLog(string message) {
- try {
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- out << message;
-
- out.close();
- }
- catch(exception& e) {
- errorOut(e, "mothur", "mothurOutJustToLog");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
-}
-
-
-/**************************************************************************************************/
-
-inline void mothurOut(float num) {
- try {
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- cout << num;
- out << num;
-
- out.close();
- }
- catch(exception& e) {
- cout << "Error in mothur class mothurOut float" << endl;
- exit(1);
- }
-}
-/***********************************************************************/
-inline void mothurOut(double value) {
- try {
- ofstream out;
- string logFileName = "mothur.logFile";
- openOutputFileAppend(logFileName, out);
-
- cout << value;
- out << value;
-
- out.close();
- }
- catch(exception& e) {
- cout << "Error in mothur class mothurOut double" << endl;
- exit(1);
- }
+ }
}
-
/***********************************************************************/
//this function determines if the user has given us labels that are smaller than the given label.
//if so then it returns true so that the calling function can run the previous valid distance.
//it's a "smart" distance function. It also checks for invalid labels.
inline bool anyLabelsToProcess(string label, set<string>& userLabels, string errorOff) {
try {
+
set<string>::iterator it;
vector<float> orderFloat;
map<string, float> userMap; //the conversion process removes trailing 0's which we need to put back
orderFloat.push_back(-1.0);
userMap["unique"] = -1.0;
}else {
- if (errorOff == "") { mothurOut(*it + " is not a valid label."); mothurOutEndLine(); }
+ if (errorOff == "") { cout << *it << " is not a valid label." << endl; }
userLabels.erase(*it);
it--;
}
if (orderFloat[i] < labelFloat) {
smaller = true;
if (orderFloat[i] == -1) {
- if (errorOff == "") { mothurOut("Your file does not include the label unique."); mothurOutEndLine(); }
+ if (errorOff == "") { cout << "Your file does not include the label unique." << endl; }
userLabels.erase("unique");
}
else {
- if (errorOff == "") { mothurOut("Your file does not include the label "); mothurOutEndLine(); }
+ if (errorOff == "") { cout << "Your file does not include the label " << endl; }
string s = "";
for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {
if (it2->second == orderFloat[i]) {
break;
}
}
- if (errorOff == "") { mothurOut(s + ". I will use the next smallest distance. "); mothurOutEndLine(); }
+ if (errorOff == "") {cout << s << ". I will use the next smallest distance. " << endl; }
}
//since they are sorted once you find a bigger one stop looking
}else { break; }
}
catch(exception& e) {
- errorOut(e, "mothur", "anyLabelsToProcess");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function anyLabelsToProcess. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/**************************************************************************************************/
output.close();
}
catch(exception& e) {
- errorOut(e, "mothur", "appendFiles");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function appendFiles. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/**************************************************************************************************/
return outfile;
}
catch(exception& e) {
- errorOut(e, "mothur", "sortFile");
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function sortfile. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
exit(1);
- }
+ }
}
/**************************************************************************************************/
#endif
//**********************************************************************************************************************
NameAssignment::NameAssignment(string nameMapFile){
-
+ m = MothurOut::getInstance();
openInputFile(nameMapFile, fileHandle);
}
}
catch(exception& e) {
- errorOut(e, "NameAssignment", "readMap");
+ m->errorOut(e, "NameAssignment", "readMap");
exit(1);
}
}
list.push_back(name);
}
catch(exception& e) {
- errorOut(e, "NameAssignment", "push_back");
+ m->errorOut(e, "NameAssignment", "push_back");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "NameAssignment", "print");
+ m->errorOut(e, "NameAssignment", "print");
exit(1);
}
}
ifstream fileHandle;
ListVector list;
map<int, string> reverse;
+ MothurOut* m;
};
Nast::Nast(Alignment* method, Sequence* cand, Sequence* temp) : alignment(method), candidateSeq(cand), templateSeq(temp) {
try {
+ m = MothurOut::getInstance();
maxInsertLength = 0;
pairwiseAlignSeqs(); // This is part A in Fig. 2 of DeSantis et al.
regapSequences(); // This is parts B-F in Fig. 2 of DeSantis et al.
}
catch(exception& e) {
- errorOut(e, "Nast", "Nast");
+ m->errorOut(e, "Nast", "Nast");
exit(1);
}
}
templateSeq->setPairwise(tempAln); // the candidate and template sequences
}
catch(exception& e) {
- errorOut(e, "Nast", "pairwiseAlignSeqs");
+ m->errorOut(e, "Nast", "pairwiseAlignSeqs");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Nast", "removeExtraGaps");
+ m->errorOut(e, "Nast", "removeExtraGaps");
exit(1);
}
}
// would skip the gaps and not progress through full alignment sequence
// not tested yet
- mothurOut("We're into D " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); mothurOutEndLine();
+ m->mothurOut("We're into D " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); m->mothurOutEndLine();
pairwiseAlignIndex++;
}
else{
// everything has a gap - not possible
// not tested yet
- mothurOut("We're into F " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); mothurOutEndLine();
+ m->mothurOut("We're into F " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); m->mothurOutEndLine();
pairwiseAlignIndex++;
fullAlignIndex++;
}
candidateSeq->setAligned(candAln);
}
catch(exception& e) {
- errorOut(e, "Nast", "regapSequences");
+ m->errorOut(e, "Nast", "regapSequences");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Nast", "getSimilarityScore");
+ m->errorOut(e, "Nast", "getSimilarityScore");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
class Alignment;
class Sequence;
Sequence* templateSeq;
int maxInsertLength;
+ MothurOut* m;
};
/**************************************************************************************************/
/**************************************************************************************************/
-NeedlemanOverlap::NeedlemanOverlap(float gO, float m, float mm, int r) :// note that we don't have a gap extend
-gap(gO), match(m), mismatch(mm), Alignment(r) { // the gap openning penalty is assessed for
+NeedlemanOverlap::NeedlemanOverlap(float gO, float f, float mm, int r) :// note that we don't have a gap extend
+gap(gO), match(f), mismatch(mm), Alignment(r) { // the gap openning penalty is assessed for
try { // every gapped position
for(int i=1;i<nCols;i++){
alignment[0][i].prevCell = 'l'; // initialize first row by pointing all poiters to the left
}
catch(exception& e) {
- errorOut(e, "NeedlemanOverlap", "NeedlemanOverlap");
+ m->errorOut(e, "NeedlemanOverlap", "NeedlemanOverlap");
exit(1);
}
}
seqA = ' ' + A; lA = seqA.length(); // algorithm requires a dummy space at the beginning of each string
seqB = ' ' + B; lB = seqB.length(); // algorithm requires a dummy space at the beginning of each string
- if (lA > nRows) { mothurOut("One of your candidate sequences is longer than you longest template sequence. Your longest template sequence is " + toString(nRows) + ". Your candidate is " + toString(lA) + "."); mothurOutEndLine(); }
+ if (lA > nRows) { m->mothurOut("One of your candidate sequences is longer than you longest template sequence. Your longest template sequence is " + toString(nRows) + ". Your candidate is " + toString(lA) + "."); m->mothurOutEndLine(); }
for(int i=1;i<lB;i++){ // This code was largely translated from Perl code provided in Ex 3.1
for(int j=1;j<lA;j++){ // of the O'Reilly BLAST book. I found that the example output had a
}
catch(exception& e) {
- errorOut(e, "NeedlemanOverlap", "align");
+ m->errorOut(e, "NeedlemanOverlap", "align");
exit(1);
}
//**********************************************************************************************************************
-NoCommand::NoCommand(string option){}
+NoCommand::NoCommand(string option) {}
//**********************************************************************************************************************
int NoCommand::execute(){
//Could choose to give more help here?fdsah
- mothurOut("Invalid command.\n");
+ cout << "Invalid command.\n";
CommandFactory* valid = CommandFactory::getInstance();
valid->printCommands(cout);
return data;
}
catch(exception& e) {
- errorOut(e, "NPShannon", "getValues");
+ m->errorOut(e, "NPShannon", "getValues");
exit(1);
}
}
OptionParser::OptionParser(string option) {
try {
-
+ m = MothurOut::getInstance();
if (option != "") {
string key, value;
}
}
catch(exception& e) {
- errorOut(e, "OptionParser", "parse");
+ m->errorOut(e, "OptionParser", "parse");
exit(1);
}
}
#include "mothur.h"
+#include "mothurout.h"
/***********************************************************************/
map<string, string> getParameters();
private:
map<string, string> parameters;
+ MothurOut* m;
};
/***********************************************************************/
updateStats();
}
catch(exception& e) {
- errorOut(e, "OrderVector", "OrderVector");
+ m->errorOut(e, "OrderVector", "OrderVector");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "OrderVector", "print");
+ m->errorOut(e, "OrderVector", "print");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "OrderVector", "print");
+ m->errorOut(e, "OrderVector", "print");
exit(1);
}
}
/***********************************************************************/
void OrderVector::resize(int){
- mothurOut("resize() did nothing in class OrderVector");
+ m->mothurOut("resize() did nothing in class OrderVector");
}
/***********************************************************************/
return rav;
}
catch(exception& e) {
- errorOut(e, "OrderVector", "getRAbundVector");
+ m->errorOut(e, "OrderVector", "getRAbundVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "OrderVector", "updateStats");
+ m->errorOut(e, "OrderVector", "updateStats");
exit(1);
}
}
#include "otuhierarchycommand.h"
//**********************************************************************************************************************
-OtuHierarchyCommand::OtuHierarchyCommand(string option){
+OtuHierarchyCommand::OtuHierarchyCommand(string option) {
try {
abort = false;
+
//allow user to run help
if(option == "help") { help(); abort = true; }
}
listFile = validParameter.validFile(parameters, "list", true);
- if (listFile == "not found") { mothurOut("list is a required parameter for the otu.hierarchy command."); mothurOutEndLine(); abort = true; }
+ if (listFile == "not found") { m->mothurOut("list is a required parameter for the otu.hierarchy command."); m->mothurOutEndLine(); abort = true; }
else if (listFile == "not open") { abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
label = validParameter.validFile(parameters, "label", false);
- if (label == "not found") { mothurOut("label is a required parameter for the otu.hierarchy command."); mothurOutEndLine(); abort = true; }
+ if (label == "not found") { m->mothurOut("label is a required parameter for the otu.hierarchy command."); m->mothurOutEndLine(); abort = true; }
else {
splitAtDash(label, labels);
- if (labels.size() != 2) { mothurOut("You must provide 2 labels."); mothurOutEndLine(); abort = true; }
+ if (labels.size() != 2) { m->mothurOut("You must provide 2 labels."); m->mothurOutEndLine(); abort = true; }
}
output = validParameter.validFile(parameters, "output", false); if (output == "not found") { output = "name"; }
- if ((output != "name") && (output != "number")) { mothurOut("output options are name and number. I will use name."); mothurOutEndLine(); output = "name"; }
+ if ((output != "name") && (output != "number")) { m->mothurOut("output options are name and number. I will use name."); m->mothurOutEndLine(); output = "name"; }
}
}
catch(exception& e) {
- errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
+ m->errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
exit(1);
}
}
void OtuHierarchyCommand::help(){
try {
- mothurOut("The otu.hierarchy command is used to see how otus relate at two distances. \n");
- mothurOut("The otu.hierarchy command parameters are list, label and output. list and label parameters are required. \n");
- mothurOut("The output parameter allows you to output the names of the sequence in the OTUs or the OTU numbers. Options are name and number, default is name. \n");
- mothurOut("The otu.hierarchy command should be in the following format: \n");
- mothurOut("otu.hierarchy(list=yourListFile, label=yourLabels).\n");
- mothurOut("Example otu.hierarchy(list=amazon.fn.list, label=0.01-0.03).\n");
- mothurOut("The otu.hierarchy command outputs a .otu.hierarchy file which is described on the wiki.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n\n");
+ m->mothurOut("The otu.hierarchy command is used to see how otus relate at two distances. \n");
+ m->mothurOut("The otu.hierarchy command parameters are list, label and output. list and label parameters are required. \n");
+ m->mothurOut("The output parameter allows you to output the names of the sequence in the OTUs or the OTU numbers. Options are name and number, default is name. \n");
+ m->mothurOut("The otu.hierarchy command should be in the following format: \n");
+ m->mothurOut("otu.hierarchy(list=yourListFile, label=yourLabels).\n");
+ m->mothurOut("Example otu.hierarchy(list=amazon.fn.list, label=0.01-0.03).\n");
+ m->mothurOut("The otu.hierarchy command outputs a .otu.hierarchy file which is described on the wiki.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "OtuHierarchyCommand", "help");
+ m->errorOut(e, "OtuHierarchyCommand", "help");
exit(1);
}
}
reverse(lists.begin(), lists.end());
}
}else{
- mothurOut("error getting listvectors, unable to read 2 different vectors, check your label inputs."); mothurOutEndLine(); return 0;
+ m->mothurOut("error getting listvectors, unable to read 2 different vectors, check your label inputs."); m->mothurOutEndLine(); return 0;
}
//map sequences to bin number in the "little" otu
out.close();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "OtuHierarchyCommand", "execute");
+ m->errorOut(e, "OtuHierarchyCommand", "execute");
exit(1);
}
}
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
return lists;
}
catch(exception& e) {
- errorOut(e, "OtuHierarchyCommand", "getListVectors");
+ m->errorOut(e, "OtuHierarchyCommand", "getListVectors");
exit(1);
}
}
try {
abort = false;
allLines = 1;
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
}
//do you have all files needed
- if ((listfile == "") || (groupfile == "")) { mothurOut("You must enter both a listfile and groupfile for the parse.list command. "); mothurOutEndLine(); abort = true; }
+ if ((listfile == "") || (groupfile == "")) { m->mothurOut("You must enter both a listfile and groupfile for the parse.list command. "); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "ParseListCommand", "ParseListCommand");
+ m->errorOut(e, "ParseListCommand", "ParseListCommand");
exit(1);
}
}
//**********************************************************************************************************************
void ParseListCommand::help(){
try {
- mothurOut("The parse.list command reads a list and group file and generates a list file for each group in the groupfile \n");
- mothurOut("The parse.list command parameters are list, group and label.\n");
- mothurOut("The list and group parameters are required.\n");
- mothurOut("The label parameter is used to read specific labels in your input you want to use.\n");
- mothurOut("The parse.list command should be used in the following format: parse.list(list=yourListFile, group=yourGroupFile, label=yourLabels).\n");
- mothurOut("Example: parse.list(list=abrecovery.fn.list, group=abrecovery.groups, label=0.03).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
+ m->mothurOut("The parse.list command reads a list and group file and generates a list file for each group in the groupfile \n");
+ m->mothurOut("The parse.list command parameters are list, group and label.\n");
+ m->mothurOut("The list and group parameters are required.\n");
+ m->mothurOut("The label parameter is used to read specific labels in your input you want to use.\n");
+ m->mothurOut("The parse.list command should be used in the following format: parse.list(list=yourListFile, group=yourGroupFile, label=yourLabels).\n");
+ m->mothurOut("Example: parse.list(list=abrecovery.fn.list, group=abrecovery.groups, label=0.03).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ParseListCommand", "help");
+ m->errorOut(e, "ParseListCommand", "help");
exit(1);
}
}
//set fileroot
string fileroot = outputDir + getRootName(getSimpleName(listfile));
+ vector<string> outputNames;
//fill filehandles with neccessary ofstreams
int i;
filehandles[groupMap->namesOfGroups[i]] = temp;
string filename = fileroot + groupMap->namesOfGroups[i] + ".list";
+ outputNames.push_back(filename);
openOutputFile(filename, *temp);
}
if(allLines == 1 || labels.count(list->getLabel()) == 1){
parse(list);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
processedLabels.insert(list->getLabel());
userLabels.erase(list->getLabel());
list = input->getListVector(lastLabel); //get new list vector to process
parse(list);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
processedLabels.insert(list->getLabel());
userLabels.erase(list->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
list = input->getListVector(lastLabel); //get new list vector to process
parse(list);
- mothurOut(list->getLabel()); mothurOutEndLine();
+ m->mothurOut(list->getLabel()); m->mothurOutEndLine();
delete list;
}
delete groupMap;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "ParseListCommand", "execute");
+ m->errorOut(e, "ParseListCommand", "execute");
exit(1);
}
}
for (int j = 0; j < names.size(); j++) {
string group = groupMap->getGroup(names[j]);
- if (group == "not found") { mothurOut(names[j] + " is not in your groupfile. please correct."); mothurOutEndLine(); exit(1); }
+ if (group == "not found") { m->mothurOut(names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); exit(1); }
itGroup = groupBins.find(group);
if(itGroup == groupBins.end()) {
}
catch(exception& e) {
- errorOut(e, "ParseListCommand", "parse");
+ m->errorOut(e, "ParseListCommand", "parse");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Parsimony", "getValues");
+ m->errorOut(e, "Parsimony", "getValues");
exit(1);
}
}
#include "parsimonycommand.h"
/***********************************************************/
-ParsimonyCommand::ParsimonyCommand(string option) {
+ParsimonyCommand::ParsimonyCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
Groups.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//are you trying to use parsimony without reading a tree or saying you want random distribution
if (randomtree == "") {
if (globaldata->gTree.size() == 0) {
- mothurOut("You must read a treefile and a groupfile or set the randomtree parameter to the output filename you wish, before you may execute the parsimony command."); mothurOutEndLine(); abort = true; }
+ m->mothurOut("You must read a treefile and a groupfile or set the randomtree parameter to the output filename you wish, before you may execute the parsimony command."); m->mothurOutEndLine(); abort = true; }
}
//if the user changes the output directory command factory will send this info to us in the output parameter
if(outputDir == "") { outputDir += hasPath(globaldata->getTreeFile()); }
output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + ".parsimony", itersString);
+ outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + ".parsimony");
sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".psummary";
openOutputFile(sumFile, outSum);
+ outputNames.push_back(sumFile);
}else { //user wants random distribution
savetmap = globaldata->gTreemap;
getUserInput();
if(outputDir == "") { outputDir += hasPath(randomtree); }
output = new ColumnFile(outputDir+ getSimpleName(randomtree), itersString);
+ outputNames.push_back(outputDir+ getSimpleName(randomtree));
}
//set users groups to analyze
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
+ m->errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
exit(1);
}
}
void ParsimonyCommand::help(){
try {
- mothurOut("The parsimony command can only be executed after a successful read.tree command, unless you use the random parameter.\n");
- mothurOut("The parsimony command parameters are random, groups and iters. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 1 valid group.\n");
- mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
- mothurOut("The parsimony command should be in the following format: parsimony(random=yourOutputFilename, groups=yourGroups, iters=yourIters).\n");
- mothurOut("Example parsimony(random=out, iters=500).\n");
- mothurOut("The default value for random is "" (meaning you want to use the trees in your inputfile, randomtree=out means you just want the random distribution of trees outputted to out.rd_parsimony),\n");
- mothurOut("and iters is 1000. The parsimony command output two files: .parsimony and .psummary their descriptions are in the manual.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. random), '=' and parameters (i.e.yourOutputFilename).\n\n");
+ m->mothurOut("The parsimony command can only be executed after a successful read.tree command, unless you use the random parameter.\n");
+ m->mothurOut("The parsimony command parameters are random, groups and iters. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 1 valid group.\n");
+ m->mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
+ m->mothurOut("The parsimony command should be in the following format: parsimony(random=yourOutputFilename, groups=yourGroups, iters=yourIters).\n");
+ m->mothurOut("Example parsimony(random=out, iters=500).\n");
+ m->mothurOut("The default value for random is "" (meaning you want to use the trees in your inputfile, randomtree=out means you just want the random distribution of trees outputted to out.rd_parsimony),\n");
+ m->mothurOut("and iters is 1000. The parsimony command output two files: .parsimony and .psummary their descriptions are in the manual.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. random), '=' and parameters (i.e.yourOutputFilename).\n\n");
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "help");
+ m->errorOut(e, "ParsimonyCommand", "help");
exit(1);
}
}
//reset groups parameter
globaldata->Groups.clear();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "execute");
+ m->errorOut(e, "ParsimonyCommand", "execute");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "printParsimonyFile");
+ m->errorOut(e, "ParsimonyCommand", "printParsimonyFile");
exit(1);
}
}
try {
//column headers
outSum << "Tree#" << '\t' << "Groups" << '\t' << "ParsScore" << '\t' << "ParsSig" << endl;
- mothurOut("Tree#\tGroups\tParsScore\tParsSig"); mothurOutEndLine();
+ m->mothurOut("Tree#\tGroups\tParsScore\tParsSig"); m->mothurOutEndLine();
//format output
outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
if (UScoreSig[a][i] > (1/(float)iters)) {
outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << UScoreSig[a][i] << endl;
cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << UScoreSig[a][i] << endl;
- mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString(UScoreSig[a][i])); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString(UScoreSig[a][i])); m->mothurOutEndLine();
}else {
outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << "<" << (1/float(iters)) << endl;
cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << "<" << (1/float(iters)) << endl;
- mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString((1/float(iters)))); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString((1/float(iters)))); m->mothurOutEndLine();
}
}
}
outSum.close();
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "printUSummaryFile");
+ m->errorOut(e, "ParsimonyCommand", "printUSummaryFile");
exit(1);
}
}
//create treemap
tmap = new TreeMap();
- mothurOut("Please enter the number of groups you would like to analyze: ");
+ m->mothurOut("Please enter the number of groups you would like to analyze: ");
cin >> numGroups;
- mothurOutJustToLog(toString(numGroups)); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(numGroups)); m->mothurOutEndLine();
int num, count;
count = 1;
numEachGroup.resize(numGroups, 0);
for (int i = 1; i <= numGroups; i++) {
- mothurOut("Please enter the number of sequences in group " + toString(i) + ": ");
+ m->mothurOut("Please enter the number of sequences in group " + toString(i) + ": ");
cin >> num;
- mothurOutJustToLog(toString(num)); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(num)); m->mothurOutEndLine();
//set tmaps seqsPerGroup
tmap->seqsPerGroup[toString(i)] = num;
}
catch(exception& e) {
- errorOut(e, "ParsimonyCommand", "getUserInput");
+ m->errorOut(e, "ParsimonyCommand", "getUserInput");
exit(1);
}
}
bool abort;
string groups, itersString;
- vector<string> Groups; //holds groups to be used
+ vector<string> Groups, outputNames; //holds groups to be used
void printParsimonyFile();
void printUSummaryFile();
//**********************************************************************************************************************
-PCACommand::PCACommand(string option){
+PCACommand::PCACommand(string option) {
try {
abort = false;
}
//error checking on files
- if (phylipfile == "") { mothurOut("You must provide a distance file before running the pca command."); mothurOutEndLine(); abort = true; }
+ if (phylipfile == "") { m->mothurOut("You must provide a distance file before running the pca command."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "PCACommand");
+ m->errorOut(e, "PCACommand", "PCACommand");
exit(1);
}
}
void PCACommand::help(){
try {
- mothurOut("The pca command..."); mothurOutEndLine();
+ m->mothurOut("The pca command..."); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "PCACommand", "help");
+ m->errorOut(e, "PCACommand", "help");
exit(1);
}
}
output(fbase, names, G, d);
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "PCACommand", "execute");
+ m->errorOut(e, "PCACommand", "execute");
exit(1);
}
}
d = f.peek();
}
catch(exception& e) {
- errorOut(e, "PCACommand", "get_comment");
+ m->errorOut(e, "PCACommand", "get_comment");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "read_phylip");
+ m->errorOut(e, "PCACommand", "read_phylip");
exit(1);
}
read_phylip(f, m, names, D);
}
catch(exception& e) {
- errorOut(e, "PCACommand", "read");
+ m->errorOut(e, "PCACommand", "read");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "matrix_mult");
+ m->errorOut(e, "PCACommand", "matrix_mult");
exit(1);
}
matrix_mult(A,C,G);
}
catch(exception& e) {
- errorOut(e, "PCACommand", "recenter");
+ m->errorOut(e, "PCACommand", "recenter");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "tred2");
+ m->errorOut(e, "PCACommand", "tred2");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "qtli");
+ m->errorOut(e, "PCACommand", "qtli");
exit(1);
}
}
ofstream pcaData((fnameRoot+"pca").c_str(), ios::trunc);
pcaData.setf(ios::fixed, ios::floatfield);
pcaData.setf(ios::showpoint);
+ outputNames.push_back(fnameRoot+"pca");
ofstream pcaLoadings((fnameRoot+"pca.loadings").c_str(), ios::trunc);
pcaLoadings.setf(ios::fixed, ios::floatfield);
- pcaLoadings.setf(ios::showpoint);
+ pcaLoadings.setf(ios::showpoint);
+ outputNames.push_back(fnameRoot+"pca.loadings");
pcaLoadings << "axis\tloading\n";
for(int i=0;i<rank;i++){
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "output");
+ m->errorOut(e, "PCACommand", "output");
exit(1);
}
}
bool abort;
string phylipfile, columnfile, namefile, format, filename, fbase, outputDir;
float cutoff, precision;
+ vector<string> outputNames;
void get_comment(istream&, char, char);
void read_phylip(istream&, int, vector<string>&, vector<vector<double> >&);
PhyloTree::PhyloTree(){
try {
+ m = MothurOut::getInstance();
numNodes = 1;
numSeqs = 0;
tree.push_back(TaxNode("Root"));
maxLevel = 0;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "PhyloTree");
+ m->errorOut(e, "PhyloTree", "PhyloTree");
exit(1);
}
}
assignHeirarchyIDs(0);
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "PhyloTree");
+ m->errorOut(e, "PhyloTree", "PhyloTree");
exit(1);
}
}
return currentLevel;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getNextTaxon");
+ m->errorOut(e, "PhyloTree", "getNextTaxon");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "addSeqToTree");
+ m->errorOut(e, "PhyloTree", "addSeqToTree");
exit(1);
}
}
return genusIndex;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getGenusNodes");
+ m->errorOut(e, "PhyloTree", "getGenusNodes");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "assignHeirarchyIDs");
+ m->errorOut(e, "PhyloTree", "assignHeirarchyIDs");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "binUnclassified");
+ m->errorOut(e, "PhyloTree", "binUnclassified");
exit(1);
}
}
return tax;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getFullTaxonomy");
+ m->errorOut(e, "PhyloTree", "getFullTaxonomy");
exit(1);
}
}
print(0, out);
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "print");
+ m->errorOut(e, "PhyloTree", "print");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "print");
+ m->errorOut(e, "PhyloTree", "print");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
/**************************************************************************************************/
int numNodes;
int numSeqs;
int maxLevel;
+ MothurOut* m;
};
/**************************************************************************************************/
#include "sabundvector.hpp"
/**********************************************************************************************************************/
-PhylotypeCommand::PhylotypeCommand(string option){
+PhylotypeCommand::PhylotypeCommand(string option) {
try {
abort = false;
taxonomyFileName = validParameter.validFile(parameters, "taxonomy", true);
if (taxonomyFileName == "not found") {
- mothurOut("taxonomy is a required parameter for the phylotype command.");
- mothurOutEndLine();
+ m->mothurOut("taxonomy is a required parameter for the phylotype command.");
+ m->mothurOutEndLine();
abort = true;
}else if (taxonomyFileName == "not open") { abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "PhylotypeCommand", "PhylotypeCommand");
+ m->errorOut(e, "PhylotypeCommand", "PhylotypeCommand");
exit(1);
}
}
void PhylotypeCommand::help(){
try {
- mothurOut("The phylotype command reads a taxonomy file and outputs a .list, .rabund and .sabund file. \n");
- mothurOut("The phylotype command parameter options are taxonomy, cutoff and label. The taxonomy parameter is required.\n");
- mothurOut("The cutoff parameter allows you to specify the level you want to stop at. The default is the highest level in your taxonomy file. \n");
- mothurOut("For example: taxonomy = Bacteria;Bacteroidetes-Chlorobi;Bacteroidetes; - cutoff=2, would truncate the taxonomy to Bacteria;Bacteroidetes-Chlorobi; \n");
- mothurOut("For the cutoff parameter levels count up from the root of the phylotree. This enables you to look at the grouping down to a specific resolution, say the genus level.\n");
- mothurOut("The label parameter allows you to specify which level you would like, and are separated by dashes. The default all levels in your taxonomy file. \n");
- mothurOut("For the label parameter, levels count down from the root to keep the output similiar to mothur's other commands which report information from finer resolution to coarser resolutions.\n");
- mothurOut("The phylotype command should be in the following format: \n");
- mothurOut("phylotype(taxonomy=yourTaxonomyFile, cutoff=yourCutoff, label=yourLabels) \n");
- mothurOut("Eaxample: phylotype(taxonomy=amazon.taxonomy, cutoff=5, label=1-3-5).\n\n");
+ m->mothurOut("The phylotype command reads a taxonomy file and outputs a .list, .rabund and .sabund file. \n");
+ m->mothurOut("The phylotype command parameter options are taxonomy, cutoff and label. The taxonomy parameter is required.\n");
+ m->mothurOut("The cutoff parameter allows you to specify the level you want to stop at. The default is the highest level in your taxonomy file. \n");
+ m->mothurOut("For example: taxonomy = Bacteria;Bacteroidetes-Chlorobi;Bacteroidetes; - cutoff=2, would truncate the taxonomy to Bacteria;Bacteroidetes-Chlorobi; \n");
+ m->mothurOut("For the cutoff parameter levels count up from the root of the phylotree. This enables you to look at the grouping down to a specific resolution, say the genus level.\n");
+ m->mothurOut("The label parameter allows you to specify which level you would like, and are separated by dashes. The default all levels in your taxonomy file. \n");
+ m->mothurOut("For the label parameter, levels count down from the root to keep the output similiar to mothur's other commands which report information from finer resolution to coarser resolutions.\n");
+ m->mothurOut("The phylotype command should be in the following format: \n");
+ m->mothurOut("phylotype(taxonomy=yourTaxonomyFile, cutoff=yourCutoff, label=yourLabels) \n");
+ m->mothurOut("Eaxample: phylotype(taxonomy=amazon.taxonomy, cutoff=5, label=1-3-5).\n\n");
}
catch(exception& e) {
- errorOut(e, "PhylotypeCommand", "help");
+ m->errorOut(e, "PhylotypeCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
+ vector<string> outputNames;
+
//reads in taxonomy file and makes all the taxonomies the same length
//by appending the last taxon to a given taxonomy as many times as needed to
//make it as long as the longest taxonomy in the file
for (int i = 0; i < leaves.size(); i++) { currentNodes[leaves[i]] = leaves[i]; }
bool done = false;
- if (tree->get(leaves[0]).parent == -1) { mothurOut("Empty Tree"); mothurOutEndLine(); done = true; }
+ if (tree->get(leaves[0]).parent == -1) { m->mothurOut("Empty Tree"); m->mothurOutEndLine(); done = true; }
string fileroot = outputDir + getRootName(getSimpleName(taxonomyFileName));
string outputRabundFile = fileroot + "tx.rabund";
openOutputFile(outputRabundFile, outRabund);
+ outputNames.push_back(outputListFile);
+ outputNames.push_back(outputSabundFile);
+ outputNames.push_back(outputRabundFile);
+
int count = 1;
//start at leaves of tree and work towards root, processing the labels the user wants
while((!done) && ((allLines == 1) || (labels.size() != 0))) {
if(allLines == 1 || labels.count(level) == 1){
//output level
- mothurOut(level); mothurOutEndLine();
+ m->mothurOut(level); m->mothurOutEndLine();
ListVector list;
list.setLabel(level);
delete tree;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "PhylotypeCommand", "execute");
+ m->errorOut(e, "PhylotypeCommand", "execute");
exit(1);
}
}
delete decalc;
}
catch(exception& e) {
- errorOut(e, "Pintail", "~Pintail");
+ m->errorOut(e, "Pintail", "~Pintail");
exit(1);
}
}
#endif
- mothurOut("Getting conservation... "); cout.flush();
+ m->mothurOut("Getting conservation... "); cout.flush();
if (consfile == "") {
- mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush();
+ m->mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush();
probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + getSimpleName(templateFileName));
- mothurOut("Done."); mothurOutEndLine();
- }else { probabilityProfile = readFreq(); mothurOut("Done."); }
- mothurOutEndLine();
+ m->mothurOut("Done."); m->mothurOutEndLine();
+ }else { probabilityProfile = readFreq(); m->mothurOut("Done."); }
+ m->mothurOutEndLine();
//make P into Q
for (int i = 0; i < probabilityProfile.size(); i++) { probabilityProfile[i] = 1 - probabilityProfile[i]; } //cout << i << '\t' << probabilityProfile[i] << endl;
}
}
- mothurOut("Calculating quantiles for your template. This can take a while... I will output the quantiles to a .quan file that you can input them using the quantiles parameter next time you run this command. Providing the .quan file will dramatically improve speed. "); cout.flush();
+ m->mothurOut("Calculating quantiles for your template. This can take a while... I will output the quantiles to a .quan file that you can input them using the quantiles parameter next time you run this command. Providing the .quan file will dramatically improve speed. "); cout.flush();
if (processors == 1) {
quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size());
}else { createProcessesQuan(); }
}
- mothurOut("Done."); mothurOutEndLine();
+ m->mothurOut("Done."); m->mothurOutEndLine();
}
if (reRead) {
}
catch(exception& e) {
- errorOut(e, "Pintail", "doPrep");
+ m->errorOut(e, "Pintail", "doPrep");
exit(1);
}
}
out << querySeq->getName() << '\t' << "div: " << deviation << "\tstDev: " << DE << "\tchimera flag: " << chimera << endl;
if (chimera == "Yes") {
- mothurOut(querySeq->getName() + "\tdiv: " + toString(deviation) + "\tstDev: " + toString(DE) + "\tchimera flag: " + chimera); mothurOutEndLine();
+ m->mothurOut(querySeq->getName() + "\tdiv: " + toString(deviation) + "\tstDev: " + toString(DE) + "\tchimera flag: " + chimera); m->mothurOutEndLine();
outAcc << querySeq->getName() << endl;
}
out << "Observed\t";
}
catch(exception& e) {
- errorOut(e, "Pintail", "print");
+ m->errorOut(e, "Pintail", "print");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "Pintail", "getChimeras");
+ m->errorOut(e, "Pintail", "getChimeras");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Pintail", "readFreq");
+ m->errorOut(e, "Pintail", "readFreq");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Pintail", "findPairs");
+ m->errorOut(e, "Pintail", "findPairs");
exit(1);
}
}
out.close();
exit(0);
- }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
//force parent to wait until all the processes are done
#endif
}
catch(exception& e) {
- errorOut(e, "Pintail", "createProcessesQuan");
+ m->errorOut(e, "Pintail", "createProcessesQuan");
exit(1);
}
}
inline bool comparePriority(seqPNode first, seqPNode second) { return (first.numIdentical > second.numIdentical); }
//**********************************************************************************************************************
-PreClusterCommand::PreClusterCommand(string option){
+PreClusterCommand::PreClusterCommand(string option) {
try {
abort = false;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the pre.cluster command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the pre.cluster command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "PreClusterCommand");
+ m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
exit(1);
}
}
void PreClusterCommand::help(){
try {
- mothurOut("The pre.cluster command groups sequences that are within a given number of base mismatches.\n");
- mothurOut("The pre.cluster command outputs a new fasta and name file.\n");
- mothurOut("The pre.cluster command parameters are fasta, names and diffs. The fasta parameter is required. \n");
- mothurOut("The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n");
- mothurOut("The diffs parameter allows you to specify maximum number of mismatched bases allowed between sequences in a grouping. The default is 1.\n");
- mothurOut("The pre.cluster command should be in the following format: \n");
- mothurOut("pre.cluster(fasta=yourFastaFile, names=yourNamesFile, diffs=yourMaxDiffs) \n");
- mothurOut("Example pre.cluster(fasta=amazon.fasta, diffs=2).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The pre.cluster command groups sequences that are within a given number of base mismatches.\n");
+ m->mothurOut("The pre.cluster command outputs a new fasta and name file.\n");
+ m->mothurOut("The pre.cluster command parameters are fasta, names and diffs. The fasta parameter is required. \n");
+ m->mothurOut("The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n");
+ m->mothurOut("The diffs parameter allows you to specify maximum number of mismatched bases allowed between sequences in a grouping. The default is 1.\n");
+ m->mothurOut("The pre.cluster command should be in the following format: \n");
+ m->mothurOut("pre.cluster(fasta=yourFastaFile, names=yourNamesFile, diffs=yourMaxDiffs) \n");
+ m->mothurOut("Example pre.cluster(fasta=amazon.fasta, diffs=2).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "help");
+ m->errorOut(e, "PreClusterCommand", "help");
exit(1);
}
}
//reads fasta file and return number of seqs
int numSeqs = readFASTA(); //fills alignSeqs and makes all seqs active
- if (numSeqs == 0) { mothurOut("Error reading fasta file...please correct."); mothurOutEndLine(); return 0; }
- if (diffs > length) { mothurOut("Error: diffs is greater than your sequence length."); mothurOutEndLine(); return 0; }
+ if (numSeqs == 0) { m->mothurOut("Error reading fasta file...please correct."); m->mothurOutEndLine(); return 0; }
+ if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); return 0; }
//clear sizes since you only needed this info to build the alignSeqs seqPNode structs
// sizes.clear();
string newNamesFile = fileroot + "precluster.names";
- mothurOut("Total number of sequences before precluster was " + toString(alignSeqs.size()) + "."); mothurOutEndLine();
- mothurOut("pre.cluster removed " + toString(count) + " sequences."); mothurOutEndLine();
+ m->mothurOut("Total number of sequences before precluster was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
+ m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine();
printData(newFastaFile, newNamesFile);
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(newFastaFile); m->mothurOutEndLine();
+ m->mothurOut(newNamesFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "execute");
+ m->errorOut(e, "PreClusterCommand", "execute");
exit(1);
}
}
if (namefile != "") {
itSize = sizes.find(seq.getName());
- if (itSize == sizes.end()) { mothurOut(seq.getName() + " is not in your names file, please correct."); mothurOutEndLine(); exit(1); }
+ if (itSize == sizes.end()) { m->mothurOut(seq.getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); exit(1); }
else{
seqPNode tempNode(itSize->second, seq, names[seq.getName()]);
alignSeqs.push_back(tempNode);
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "readFASTA");
+ m->errorOut(e, "PreClusterCommand", "readFASTA");
exit(1);
}
}
return numBad;
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "calcMisMatches");
+ m->errorOut(e, "PreClusterCommand", "calcMisMatches");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "printData");
+ m->errorOut(e, "PreClusterCommand", "printData");
exit(1);
}
}
in.close();
}
catch(exception& e) {
- errorOut(e, "PreClusterCommand", "readNameFile");
+ m->errorOut(e, "PreClusterCommand", "readNameFile");
exit(1);
}
}
class PreClusterCommand : public Command {
public:
- PreClusterCommand(string);
+ PreClusterCommand(string);
~PreClusterCommand();
int execute();
void help();
Progress::Progress(){
try {
- mothurOut("********************#****#****#****#****#****#****#****#****#****#****#");
+ m = MothurOut::getInstance();
+ m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#");
nTicks = 0;
finalPos = 0;
}
catch(exception& e) {
- errorOut(e, "Progress", "Progress");
+ m->errorOut(e, "Progress", "Progress");
exit(1);
}
}
Progress::Progress(string job, int end){
try {
- mothurOut("********************#****#****#****#****#****#****#****#****#****#****#\n");
+ m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#\n");
cout << setw(20) << left << job << setw(1) << marker;
- mothurOutJustToLog(job);
- mothurOut(toString(marker));
+ m->mothurOutJustToLog(job);
+ m->mothurOut(toString(marker));
cout.flush();
nTicks = 0;
finalPos = end;
}
catch(exception& e) {
- errorOut(e, "Progress", "Progress");
+ m->errorOut(e, "Progress", "Progress");
exit(1);
}
}
void Progress::newLine(string job, int end){
try {
- mothurOutEndLine();
+ m->mothurOutEndLine();
cout << setw(20) << left << job << setw(1) << marker;
- mothurOutJustToLog(job);
- mothurOut(toString(marker));
+ m->mothurOutJustToLog(job);
+ m->mothurOut(toString(marker));
cout.flush();
nTicks = 0;
finalPos = end;
}
catch(exception& e) {
- errorOut(e, "Progress", "newLine");
+ m->errorOut(e, "Progress", "newLine");
exit(1);
}
}
if(ratio > nTicks){
for(int i=nTicks;i<ratio;i++){
- mothurOut(toString(marker));
+ m->mothurOut(toString(marker));
cout.flush();
}
nTicks = ratio;
}
}
catch(exception& e) {
- errorOut(e, "Progress", "update");
+ m->errorOut(e, "Progress", "update");
exit(1);
}
}
void Progress::finish(){
try {
for(int i=nTicks;i<totalTicks;i++){
- mothurOut(toString(marker));
+ m->mothurOut(toString(marker));
cout.flush();
}
- mothurOutEndLine();
- mothurOut("***********************************************************************\n");
+ m->mothurOutEndLine();
+ m->mothurOut("***********************************************************************\n");
cout.flush();
}
catch(exception& e) {
- errorOut(e, "Progress", "finish");
+ m->errorOut(e, "Progress", "finish");
exit(1);
}
}
#define PROGRESS_H
#include "mothur.h"
+#include "mothurout.h"
class Progress {
private:
int nTicks;
- int finalPos;
+ int finalPos;
+ MothurOut* m;
};
#endif
return data;
}
catch(exception& e) {
- errorOut(e, "QStat", "getValues");
+ m->errorOut(e, "QStat", "getValues");
exit(1);
}
}
//**********************************************************************************************************************
-QuitCommand::QuitCommand(string option){
+QuitCommand::QuitCommand(string option) {
abort = false;
//allow user to run help
void QuitCommand::help(){
try {
- mothurOut("The quit command will terminate mothur and should be in the following format: \n");
- mothurOut("quit() or quit\n\n");
+ m->mothurOut("The quit command will terminate mothur and should be in the following format: \n");
+ m->mothurOut("quit() or quit\n\n");
}
catch(exception& e) {
- errorOut(e, "QuitCommand", "help");
+ m->errorOut(e, "QuitCommand", "help");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "RAbundVector");
+ m->errorOut(e, "RAbundVector", "RAbundVector");
exit(1);
}
}
data = rav;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "RAbundVector");
+ m->errorOut(e, "RAbundVector", "RAbundVector");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "RAbundVector");
+ m->errorOut(e, "RAbundVector", "RAbundVector");
exit(1);
}
}
numSeqs += (newBinSize - oldBinSize);
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "set");
+ m->errorOut(e, "RAbundVector", "set");
exit(1);
}
}
numSeqs += binSize;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "push_back");
+ m->errorOut(e, "RAbundVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "nonSortedPrint");
+ m->errorOut(e, "RAbundVector", "nonSortedPrint");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "print");
+ m->errorOut(e, "RAbundVector", "print");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "print");
+ m->errorOut(e, "RAbundVector", "print");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "getSAbundVector");
+ m->errorOut(e, "RAbundVector", "getSAbundVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "RAbundVector", "getOrderVector");
+ m->errorOut(e, "RAbundVector", "getOrderVector");
exit(1);
}
}
return output;
}
catch(exception& e) {
- errorOut(e, "RareCalc", "getValues");
+ m->errorOut(e, "RareCalc", "getValues");
exit(1);
}
}
class RareCalc {
public:
- RareCalc(RAbundVector* b) : bins(b), numSeqs(b->getNumSeqs()), maxRank(b->getMaxRank()), numBins(b->getNumBins()) { bMatrix = binomial(numSeqs+1); };
+ RareCalc(RAbundVector* b) : bins(b), numSeqs(b->getNumSeqs()), maxRank(b->getMaxRank()), numBins(b->getNumBins()) { bMatrix = binomial(numSeqs+1); m = MothurOut::getInstance(); }
EstOutput getValues(int);
string getName() { return "rarecalc"; }
private:
RAbundVector* bins;
vector<vector<double> > bMatrix;
int numSeqs, maxRank, numBins;
+ MothurOut* m;
};
/***********************************************************************/
this->label = label;
}
catch(exception& e) {
- errorOut(e, "RareDisplay", "init");
+ m->errorOut(e, "RareDisplay", "init");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "RareDisplay", "update");
+ m->errorOut(e, "RareDisplay", "update");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "RareDisplay", "update");
+ m->errorOut(e, "RareDisplay", "update");
exit(1);
}
}
index = 0;
}
catch(exception& e) {
- errorOut(e, "RareDisplay", "reset");
+ m->errorOut(e, "RareDisplay", "reset");
exit(1);
}
}
output->resetFile();
}
catch(exception& e) {
- errorOut(e, "RareDisplay", "close");
+ m->errorOut(e, "RareDisplay", "close");
exit(1);
}
}
delete rcd;
}
catch(exception& e) {
- errorOut(e, "Rarefact", "getCurve");
+ m->errorOut(e, "Rarefact", "getCurve");
exit(1);
}
}
delete rcd;
}
catch(exception& e) {
- errorOut(e, "Rarefact", "getSharedCurve");
+ m->errorOut(e, "Rarefact", "getSharedCurve");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Rarefact", "mergeVectors");
+ m->errorOut(e, "Rarefact", "mergeVectors");
exit(1);
}
}
public:
Rarefact(OrderVector* o, vector<Display*> disp) :
- numSeqs(o->getNumSeqs()), order(o), displays(disp), label(o->getLabel()) {};
+ numSeqs(o->getNumSeqs()), order(o), displays(disp), label(o->getLabel()) { m = MothurOut::getInstance(); }
Rarefact(vector<SharedRAbundVector*> shared, vector<Display*> disp) :
- lookup(shared), displays(disp) { globaldata = GlobalData::getInstance(); };
+ lookup(shared), displays(disp) { globaldata = GlobalData::getInstance(); m = MothurOut::getInstance(); }
~Rarefact(){};
void getCurve(int, int);
string label;
void mergeVectors(SharedRAbundVector*, SharedRAbundVector*);
vector<SharedRAbundVector*> lookup;
+ MothurOut* m;
};
//**********************************************************************************************************************
-RareFactCommand::RareFactCommand(string option){
+RareFactCommand::RareFactCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
allLines = 1;
labels.clear();
Estimators.clear();
-
+
//allow user to run help
if(option == "help") { validCalculator = new ValidCalculators(); help(); delete validCalculator; abort = true; }
}
//make sure the user has already run the read.otu command
- if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund, rabund or shared file before you can use the rarefact.single command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund, rabund or shared file before you can use the rarefact.single command."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
}
catch(exception& e) {
- errorOut(e, "RareFactCommand", "RareFactCommand");
+ m->errorOut(e, "RareFactCommand", "RareFactCommand");
exit(1);
}
}
void RareFactCommand::help(){
try {
- mothurOut("The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
- mothurOut("The rarefaction.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
- mothurOut("The rarefaction.single command parameters are label, iters, freq, calc and abund. No parameters are required. \n");
- mothurOut("The rarefaction.single command should be in the following format: \n");
- mothurOut("rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
- mothurOut("Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n");
- mothurOut("The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness.\n");
+ m->mothurOut("The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
+ m->mothurOut("The rarefaction.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
+ m->mothurOut("The rarefaction.single command parameters are label, iters, freq, calc and abund. No parameters are required. \n");
+ m->mothurOut("The rarefaction.single command should be in the following format: \n");
+ m->mothurOut("rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
+ m->mothurOut("Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n");
+ m->mothurOut("The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness.\n");
validCalculator->printCalc("rarefaction", cout);
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
}
catch(exception& e) {
- errorOut(e, "RareFactCommand", "help");
+ m->errorOut(e, "RareFactCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
+ vector<string> outputNames;
+
if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName); }
else { inputFileNames = parseSharedFile(globaldata->getSharedFile()); globaldata->setFormat("rabund"); }
globaldata->inputFileName = inputFileNames[p];
if (inputFileNames.size() > 1) {
- mothurOutEndLine(); mothurOut("Processing group " + groups[p]); mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
}
int i;
validCalculator = new ValidCalculators();
if (validCalculator->isValidCalculator("rarefaction", Estimators[i]) == true) {
if (Estimators[i] == "sobs") {
rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
+ outputNames.push_back(fileNameRoot+"rarefaction");
}else if (Estimators[i] == "chao") {
rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
+ outputNames.push_back(fileNameRoot+"r_chao");
}else if (Estimators[i] == "ace") {
if(abund < 5)
abund = 10;
rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
+ outputNames.push_back(fileNameRoot+"r_ace");
}else if (Estimators[i] == "jack") {
rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
+ outputNames.push_back(fileNameRoot+"r_jack");
}else if (Estimators[i] == "shannon") {
rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
+ outputNames.push_back(fileNameRoot+"r_shannon");
}else if (Estimators[i] == "npshannon") {
rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
+ outputNames.push_back(fileNameRoot+"r_npshannon");
}else if (Estimators[i] == "simpson") {
rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
+ outputNames.push_back(fileNameRoot+"r_simpson");
}else if (Estimators[i] == "bootstrap") {
rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+ outputNames.push_back(fileNameRoot+"r_bootstrap");
}else if (Estimators[i] == "coverage") {
rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
+ outputNames.push_back(fileNameRoot+"r_coverage");
}else if (Estimators[i] == "nseqs") {
rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
+ outputNames.push_back(fileNameRoot+"r_nseqs");
}
}
}
rCurve->getCurve(freq, nIters);
delete rCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
}
rCurve->getCurve(freq, nIters);
delete rCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
processedLabels.insert(order->getLabel());
userLabels.erase(order->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
rCurve->getCurve(freq, nIters);
delete rCurve;
- mothurOut(order->getLabel()); mothurOutEndLine();
+ m->mothurOut(order->getLabel()); m->mothurOutEndLine();
delete order;
}
}
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "RareFactCommand", "execute");
+ m->errorOut(e, "RareFactCommand", "execute");
exit(1);
}
}
return filenames;
}
catch(exception& e) {
- errorOut(e, "RareFactCommand", "parseSharedFile");
+ m->errorOut(e, "RareFactCommand", "parseSharedFile");
exit(1);
}
}
//**********************************************************************************************************************
-RareFactSharedCommand::RareFactSharedCommand(string option){
+RareFactSharedCommand::RareFactSharedCommand(string option) {
try {
globaldata = GlobalData::getInstance();
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); abort = true; }
- else if (globaldata->getGroupFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); abort = true; }
+ if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if (globaldata->getGroupFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
}
//if the user changes the output directory command factory will send this info to us in the output parameter
if (validCalculator->isValidCalculator("sharedrarefaction", Estimators[i]) == true) {
if (Estimators[i] == "sharedobserved") {
rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+ outputNames.push_back(fileNameRoot+"shared.rarefaction");
}else if (Estimators[i] == "sharednseqs") {
rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", "")));
+ outputNames.push_back(fileNameRoot+"shared.r_nseqs");
}
}
}
}
catch(exception& e) {
- errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
+ m->errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
exit(1);
}
}
void RareFactSharedCommand::help(){
try {
- mothurOut("The rarefaction.shared command can only be executed after a successful read.otu command.\n");
- mothurOut("The rarefaction.shared command parameters are label, iters, groups, jumble and calc. No parameters are required.\n");
- mothurOut("The rarefaction command should be in the following format: \n");
- mothurOut("rarefaction.shared(label=yourLabel, iters=yourIters, calc=yourEstimators, jumble=yourJumble, groups=yourGroups).\n");
- mothurOut("Example rarefaction.shared(label=unique-0.01-0.03, iters=10000, groups=B-C, jumble=T, calc=sharedobserved).\n");
- mothurOut("The default values for iters is 1000, freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness.\n");
- mothurOut("The default value for groups is all the groups in your groupfile, and jumble is true.\n");
+ m->mothurOut("The rarefaction.shared command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The rarefaction.shared command parameters are label, iters, groups, jumble and calc. No parameters are required.\n");
+ m->mothurOut("The rarefaction command should be in the following format: \n");
+ m->mothurOut("rarefaction.shared(label=yourLabel, iters=yourIters, calc=yourEstimators, jumble=yourJumble, groups=yourGroups).\n");
+ m->mothurOut("Example rarefaction.shared(label=unique-0.01-0.03, iters=10000, groups=B-C, jumble=T, calc=sharedobserved).\n");
+ m->mothurOut("The default values for iters is 1000, freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness.\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, and jumble is true.\n");
validCalculator->printCalc("sharedrarefaction", cout);
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
}
catch(exception& e) {
- errorOut(e, "RareFactSharedCommand", "help");
+ m->errorOut(e, "RareFactSharedCommand", "help");
exit(1);
}
}
string lastLabel = lookup[0]->getLabel();
if (lookup.size() < 2) {
- mothurOut("I cannot run the command without at least 2 valid groups.");
+ m->mothurOut("I cannot run the command without at least 2 valid groups.");
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
return 0;
}
rCurve->getSharedCurve(freq, nIters);
delete rCurve;
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
}
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
rCurve = new Rarefact(lookup, rDisplays);
rCurve->getSharedCurve(freq, nIters);
delete rCurve;
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
rCurve = new Rarefact(lookup, rDisplays);
rCurve->getSharedCurve(freq, nIters);
delete rCurve;
//reset groups parameter
globaldata->Groups.clear();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "RareFactSharedCommand", "execute");
+ m->errorOut(e, "RareFactSharedCommand", "execute");
exit(1);
}
}
class RareFactSharedCommand : public Command {
public:
- RareFactSharedCommand(string);
+ RareFactSharedCommand(string);
~RareFactSharedCommand();
int execute();
void help();
bool abort, allLines, jumble;
set<string> labels; //holds labels to be used
string label, calc, groups, outputDir;
- vector<string> Estimators, Groups;
+ vector<string> Estimators, Groups, outputNames;
};
return (left.dist < right.dist);
}
/*********************************************************************************************/
-ReadBlast::ReadBlast(string file, float c, float p, int l, bool m, bool h) : blastfile(file), cutoff(c), penalty(p), length(l), minWanted(m), hclusterWanted(h) {
+ReadBlast::ReadBlast(string file, float c, float p, int l, bool ms, bool h) : blastfile(file), cutoff(c), penalty(p), length(l), minWanted(ms), hclusterWanted(h) {
try {
+ m = MothurOut::getInstance();
matrix = NULL;
}
catch(exception& e) {
- errorOut(e, "ReadBlast", "ReadBlast");
+ m->errorOut(e, "ReadBlast", "ReadBlast");
exit(1);
}
}
}
}
}
- }else { mothurOut("Error in your blast file, cannot read."); mothurOutEndLine(); exit(1); }
+ }else { m->mothurOut("Error in your blast file, cannot read."); m->mothurOutEndLine(); exit(1); }
//read file
fileHandle.close();
}
catch(exception& e) {
- errorOut(e, "ReadBlast", "read");
+ m->errorOut(e, "ReadBlast", "read");
exit(1);
}
}
/*********************************************************************************************/
void ReadBlast::readNames(NameAssignment* nameMap) {
try {
- mothurOut("Reading names... "); cout.flush();
+ m->mothurOut("Reading names... "); cout.flush();
string name, hold, prevName;
int num = 1;
//nameMap->print(out);
//out.close();
- mothurOut(toString(num) + " names read."); mothurOutEndLine();
+ m->mothurOut(toString(num) + " names read."); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "ReadBlast", "readNames");
+ m->errorOut(e, "ReadBlast", "readNames");
exit(1);
}
}
SparseMatrix* matrix;
vector<seqDist> overlap;
+ MothurOut* m;
void readNames(NameAssignment*);
};
ReadCluster::ReadCluster(string distfile, float c){
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
distFile = distfile;
cutoff = c;
}
}
catch(exception& e) {
- errorOut(e, "ReadCluster", "read");
+ m->errorOut(e, "ReadCluster", "read");
exit(1);
}
}
}
else{
list = new ListVector(nameMap->getListVector());
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
}
char d;
}
else{
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
for(int j=0;j<i;j++){
in >> distance;
}
}
else{
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
for(int j=0;j<nseqs;j++){
in >> distance;
distFile = outputFile;
}
catch(exception& e) {
- errorOut(e, "ReadCluster", "convertPhylip2Column");
+ m->errorOut(e, "ReadCluster", "convertPhylip2Column");
exit(1);
}
}
string OutPutFile, format;
ListVector* list;
float cutoff;
+ MothurOut* m;
void convertPhylip2Column(NameAssignment*);
};
\r
}\r
catch(exception& e) {\r
- errorOut(e, "ReadColumnMatrix", "read");\r
+ m->errorOut(e, "ReadColumnMatrix", "read");\r
exit(1);\r
}\r
}\r
#include "readcolumn.h"
#include "readmatrix.hpp"
-ReadDistCommand::ReadDistCommand(string option){
+ReadDistCommand::ReadDistCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
if ((phylipfile != "") && (groupfile != "")) {
globaldata->setFormat("matrix"); }
- if ((phylipfile == "") && (columnfile == "")) { mothurOut("When executing a read.dist command you must enter a phylip or a column."); mothurOutEndLine(); abort = true; }
- else if ((phylipfile != "") && (columnfile != "")) { mothurOut("When executing a read.dist command you must enter ONLY ONE of the following: phylip or column."); mothurOutEndLine(); abort = true; }
+ if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a read.dist command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a read.dist command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
if (columnfile != "") {
if (namefile == "") { cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
}
catch(exception& e) {
- errorOut(e, "ReadDistCommand", "ReadDistCommand");
+ m->errorOut(e, "ReadDistCommand", "ReadDistCommand");
exit(1);
}
}
void ReadDistCommand::help(){
try {
- mothurOut("The read.dist command parameter options are phylip or column, group, name, cutoff and precision\n");
- mothurOut("The read.dist command can be used in two ways. The first is to read a phylip or column and run the cluster command\n");
- mothurOut("For this use the read.dist command should be in the following format: \n");
- mothurOut("read.dist(phylip=yourDistFile, name=yourNameFile, cutoff=yourCutoff, precision=yourPrecision) \n");
- mothurOut("The phylip or column parameter is required, but only one may be used. If you use a column file the name filename is required. \n");
- mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
- mothurOut("The second way to use the read.dist command is to read a phylip or column and a group, so you can use the libshuff command.\n");
- mothurOut("For this use the read.dist command should be in the following format: \n");
- mothurOut("read.dist(phylip=yourPhylipfile, group=yourGroupFile). The cutoff and precision parameters are not valid with this use. \n");
- mothurOut("Note: No spaces between parameter labels (i.e. phylip), '=' and parameters (i.e.yourPhylipfile).\n\n");
+ m->mothurOut("The read.dist command parameter options are phylip or column, group, name, cutoff and precision\n");
+ m->mothurOut("The read.dist command can be used in two ways. The first is to read a phylip or column and run the cluster command\n");
+ m->mothurOut("For this use the read.dist command should be in the following format: \n");
+ m->mothurOut("read.dist(phylip=yourDistFile, name=yourNameFile, cutoff=yourCutoff, precision=yourPrecision) \n");
+ m->mothurOut("The phylip or column parameter is required, but only one may be used. If you use a column file the name filename is required. \n");
+ m->mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
+ m->mothurOut("The second way to use the read.dist command is to read a phylip or column and a group, so you can use the libshuff command.\n");
+ m->mothurOut("For this use the read.dist command should be in the following format: \n");
+ m->mothurOut("read.dist(phylip=yourPhylipfile, group=yourGroupFile). The cutoff and precision parameters are not valid with this use. \n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. phylip), '=' and parameters (i.e.yourPhylipfile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ReadDistCommand", "help");
+ m->errorOut(e, "ReadDistCommand", "help");
exit(1);
}
}
time_t start = time(NULL);
size_t numDists = 0;
+ vector<string> outputNames;
+
if (format == "matrix") {
ifstream in;
openInputFile(distFileName, in);
//if files don't match...
if (matrix->getNumSeqs() < groupMap->getNumSeqs()) {
- mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences."); mothurOutEndLine();
+ m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences."); m->mothurOutEndLine();
//create new group file
if(outputDir == "") { outputDir += hasPath(groupfile); }
string newGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "editted.groups";
+ outputNames.push_back(newGroupFile);
ofstream outGroups;
openOutputFile(newGroupFile, outGroups);
}
outGroups.close();
- mothurOut(newGroupFile + " is a new group file containing only the sequence that are in your distance file. I will read this file instead."); mothurOutEndLine();
+ m->mothurOut(newGroupFile + " is a new group file containing only the sequence that are in your distance file. I will read this file instead."); m->mothurOutEndLine();
//read new groupfile
delete groupMap; groupMap = NULL;
//dist_string = dist_string.append("\t").append(toString(dist_cutoff[i]));
// count_string = count_string.append("\t").append(toString(dist_count[i]));
// }
- //mothurOut(dist_string); mothurOutEndLine(); mothurOut(count_string); mothurOutEndLine();
+ //m->mothurOut(dist_string); m->mothurOutEndLine(); m->mothurOut(count_string); m->mothurOutEndLine();
+ }
+
+ if (outputNames.size() != 0) {
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
}
- mothurOut("It took " + toString(time(NULL) - start) + " secs to read "); mothurOutEndLine();
+
+ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to read "); m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "ReadDistCommand", "execute");
+ m->errorOut(e, "ReadDistCommand", "execute");
exit(1);
}
}
class ReadMatrix {
public:
- ReadMatrix(){ D = new SparseMatrix(); }
+ ReadMatrix(){ D = new SparseMatrix(); m = MothurOut::getInstance(); }
virtual ~ReadMatrix() {}
virtual void read(NameAssignment*){};
virtual void read(GlobalData* globaldata){};
ListVector* list;
GlobalData* globaldata;
float cutoff;
+ MothurOut* m;
};
/***********************************************************************/
ReadOTUFile::ReadOTUFile(string pf): philFile(pf){
-
+ m = MothurOut::getInstance();
//openInputFile(philFile, fileHandle);
}
}
}
catch(exception& e) {
- errorOut(e, "ReadOTUFile", "read");
+ m->errorOut(e, "ReadOTUFile", "read");
exit(1);
}
}
SAbundVector* sabund;
RAbundVector* rabund;
GlobalData* globaldata;
+ MothurOut* m;
// InputData* getInput() { return input; }
};
#include "readotucommand.h"
//**********************************************************************************************************************
-ReadOtuCommand::ReadOtuCommand(string option){
+ReadOtuCommand::ReadOtuCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//you have not given a file
if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "")) {
- mothurOut("You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. "); mothurOutEndLine(); abort = true;
+ m->mothurOut("You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. "); m->mothurOutEndLine(); abort = true;
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
+ m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
exit(1);
}
}
void ReadOtuCommand::help(){
try {
- mothurOut("The read.otu command must be run before you execute a collect.single, rarefaction.single, summary.single, \n");
- mothurOut("collect.shared, rarefaction.shared or summary.shared command. Mothur will generate a .list, .rabund and .sabund upon completion of the cluster command \n");
- mothurOut("or you may use your own. The read.otu command parameter options are list, rabund, sabund, shared, group, order, label and groups.\n");
- mothurOut("The read.otu command can be used in two ways. The first is to read a list, rabund or sabund and run the collect.single, rarefaction.single or summary.single.\n");
- mothurOut("For this use the read.otu command should be in the following format: read.otu(list=yourListFile, order=yourOrderFile, label=yourLabels).\n");
- mothurOut("The list, rabund or sabund parameter is required, but you may only use one of them.\n");
- mothurOut("The label parameter is used to read specific labels in your input.\n");
- mothurOut("The second way to use the read.otu command is to read a list and a group, or a shared so you can use the collect.shared, rarefaction.shared or summary.shared commands.\n");
- mothurOut("In this case the read.otu command should be in the following format: read.otu(list=yourListFile, group=yourGroupFile) or read.otu(shared=yourSharedFile). \n");
- mothurOut("The list parameter and group paramaters or the shared paremeter is required. When using the command the second way with a list and group file read.otu command parses the .list file\n");
- mothurOut("and separates it into groups. It outputs a .shared file containing the OTU information for each group. The read.otu command also outputs a .rabund file for each group. \n");
- mothurOut("You can use the groups parameter to choose only specific groups to be used in the .shared and .rabund files. \n");
- mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
+ m->mothurOut("The read.otu command must be run before you execute a collect.single, rarefaction.single, summary.single, \n");
+ m->mothurOut("collect.shared, rarefaction.shared or summary.shared command. Mothur will generate a .list, .rabund and .sabund upon completion of the cluster command \n");
+ m->mothurOut("or you may use your own. The read.otu command parameter options are list, rabund, sabund, shared, group, order, label and groups.\n");
+ m->mothurOut("The read.otu command can be used in two ways. The first is to read a list, rabund or sabund and run the collect.single, rarefaction.single or summary.single.\n");
+ m->mothurOut("For this use the read.otu command should be in the following format: read.otu(list=yourListFile, order=yourOrderFile, label=yourLabels).\n");
+ m->mothurOut("The list, rabund or sabund parameter is required, but you may only use one of them.\n");
+ m->mothurOut("The label parameter is used to read specific labels in your input.\n");
+ m->mothurOut("The second way to use the read.otu command is to read a list and a group, or a shared so you can use the collect.shared, rarefaction.shared or summary.shared commands.\n");
+ m->mothurOut("In this case the read.otu command should be in the following format: read.otu(list=yourListFile, group=yourGroupFile) or read.otu(shared=yourSharedFile). \n");
+ m->mothurOut("The list parameter and group paramaters or the shared paremeter is required. When using the command the second way with a list and group file read.otu command parses the .list file\n");
+ m->mothurOut("and separates it into groups. It outputs a .shared file containing the OTU information for each group. The read.otu command also outputs a .rabund file for each group. \n");
+ m->mothurOut("You can use the groups parameter to choose only specific groups to be used in the .shared and .rabund files. \n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ReadOtuCommand", "help");
+ m->errorOut(e, "ReadOtuCommand", "help");
exit(1);
}
}
globaldata->setListFile("");
globaldata->setGroupFile("");
globaldata->setSharedFile("");
+ }else {
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(globaldata->getSharedFile()); m->mothurOutEndLine();
+ m->mothurOutEndLine();
}
delete shared;
return 0;
}
catch(exception& e) {
- errorOut(e, "ReadOtuCommand", "execute");
+ m->errorOut(e, "ReadOtuCommand", "execute");
exit(1);
}
}
}
else{
list = new ListVector(nameMap->getListVector());
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
}
char d;
}
else{
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
for(int j=0;j<i;j++){
fileHandle >> distance;
}
else{
- if(nameMap->count(name)==0){ mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
+ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
for(int j=0;j<nseqs;j++){
fileHandle >> distance;
}
if(nameMap->size() > 0){
//should probably tell them what is missing if we missed something
- mothurOut("missed something\t" + toString(nameMap->size())); mothurOutEndLine();
+ m->mothurOut("missed something\t" + toString(nameMap->size())); m->mothurOutEndLine();
}
} */
}
catch(exception& e) {
- errorOut(e, "ReadPhylipMatrix", "read");
+ m->errorOut(e, "ReadPhylipMatrix", "read");
exit(1);
}
}
ReadTree::ReadTree() {
try {
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
globaldata->gTree.clear();
}
catch(exception& e) {
- errorOut(e, "ReadTree", "ReadTree");
+ m->errorOut(e, "ReadTree", "ReadTree");
exit(1);
}
}
char d = f.get();
if(d == EOF){
- mothurOut("Error: Input file ends prematurely, expecting a " + name + "\n");
+ m->mothurOut("Error: Input file ends prematurely, expecting a " + name + "\n");
exit(1);
}
if(d != c){
- mothurOut("Error: Expected " + name + " in input file. Found " + toString(d) + ".\n");
+ m->mothurOut("Error: Expected " + name + " in input file. Found " + toString(d) + ".\n");
exit(1);
}
if(d == ')' && f.peek() == '\n'){
return d;
}
catch(exception& e) {
- errorOut(e, "ReadTree", "readSpecialChar");
+ m->errorOut(e, "ReadTree", "readSpecialChar");
exit(1);
}
}
char d = f.get();
if(d == EOF){
- mothurOut("Error: Input file ends prematurely, expecting a left parenthesis\n");
+ m->mothurOut("Error: Input file ends prematurely, expecting a left parenthesis\n");
exit(1);
}
return d;
}
catch(exception& e) {
- errorOut(e, "ReadTree", "readNodeChar");
+ m->errorOut(e, "ReadTree", "readNodeChar");
exit(1);
}
}
float b;
if(!(f >> b)){
- mothurOut("Error: Missing branch length in input tree.\n");
+ m->mothurOut("Error: Missing branch length in input tree.\n");
exit(1);
}
gobble(f);
return b;
}
catch(exception& e) {
- errorOut(e, "ReadTree", "readBranchLength");
+ m->errorOut(e, "ReadTree", "readBranchLength");
exit(1);
}
}
return readOk;
}
catch(exception& e) {
- errorOut(e, "ReadNewickTree", "read");
+ m->errorOut(e, "ReadNewickTree", "read");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "ReadNewickTree", "nexusTranslation");
+ m->errorOut(e, "ReadNewickTree", "nexusTranslation");
exit(1);
}
}
n = numLeaves; //number of leaves / sequences, we want node 1 to start where the leaves left off
lc = readNewickInt(filehandle, n, T);
- if (lc == -1) { mothurOut("error with lc"); mothurOutEndLine(); return -1; } //reports an error in reading
+ if (lc == -1) { m->mothurOut("error with lc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
if(filehandle.peek()==','){
readSpecialChar(filehandle,',',"comma");
}
if(rooted != 1){
rc = readNewickInt(filehandle, n, T);
- if (rc == -1) { mothurOut("error with rc"); mothurOutEndLine(); return -1; } //reports an error in reading
+ if (rc == -1) { m->mothurOut("error with rc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
if(filehandle.peek() == ')'){
readSpecialChar(filehandle,')',"right parenthesis");
}
n = T->getIndex(name);
if(n!=0){
- mothurOut("Internal error: The only taxon is not taxon 0.\n");
+ m->mothurOut("Internal error: The only taxon is not taxon 0.\n");
//exit(1);
readOk = -1; return -1;
}
}
catch(exception& e) {
- errorOut(e, "ReadNewickTree", "readTreeString");
+ m->errorOut(e, "ReadNewickTree", "readTreeString");
exit(1);
}
}
if(f.peek() == ':'){
readSpecialChar(f,':',"colon");
- if(n >= numNodes){ mothurOut("Error: Too many nodes in input tree\n"); readOk = -1; return -1; }
+ if(n >= numNodes){ m->mothurOut("Error: Too many nodes in input tree\n"); readOk = -1; return -1; }
T->tree[n].setBranchLength(readBranchLength(f));
}else{
//adds sequence names that are not in group file to the "xxx" group
if(group == "not found") {
- mothurOut("Name: " + name + " is not in your groupfile, and will be disregarded. \n"); //readOk = -1; return n1;
+ m->mothurOut("Name: " + name + " is not in your groupfile, and will be disregarded. \n"); //readOk = -1; return n1;
globaldata->gTreemap->namesOfSeqs.push_back(name);
globaldata->gTreemap->treemap[name].groupname = "xxx";
}
}
catch(exception& e) {
- errorOut(e, "ReadNewickTree", "readNewickInt");
+ m->errorOut(e, "ReadNewickTree", "readNewickInt");
exit(1);
}
}
protected:
GlobalData* globaldata;
int numNodes, numLeaves;
+ MothurOut* m;
};
#include "readtreecommand.h"
//**********************************************************************************************************************
-ReadTreeCommand::ReadTreeCommand(string option){
+ReadTreeCommand::ReadTreeCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//check for required parameters
treefile = validParameter.validFile(parameters, "tree", true);
if (treefile == "not open") { abort = true; }
- else if (treefile == "not found") { treefile = ""; mothurOut("tree is a required parameter for the read.tree command."); mothurOutEndLine(); abort = true; }
+ else if (treefile == "not found") { treefile = ""; m->mothurOut("tree is a required parameter for the read.tree command."); m->mothurOutEndLine(); abort = true; }
else { globaldata->setTreeFile(treefile); globaldata->setFormat("tree"); }
groupfile = validParameter.validFile(parameters, "group", true);
if (groupfile == "not open") { abort = true; }
- else if (groupfile == "not found") { groupfile = ""; mothurOut("group is a required parameter for the read.tree command."); mothurOutEndLine(); abort = true; }
+ else if (groupfile == "not found") { groupfile = ""; m->mothurOut("group is a required parameter for the read.tree command."); m->mothurOutEndLine(); abort = true; }
else {
globaldata->setGroupFile(groupfile);
//read in group map info.
}
}
catch(exception& e) {
- errorOut(e, "ReadTreeCommand", "ReadTreeCommand");
+ m->errorOut(e, "ReadTreeCommand", "ReadTreeCommand");
exit(1);
}
}
void ReadTreeCommand::help(){
try {
- mothurOut("The read.tree command must be run before you execute a unifrac.weighted, unifrac.unweighted. \n");
- mothurOut("It also must be run before using the parsimony command, unless you are using the randomtree parameter.\n");
- mothurOut("The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile).\n");
- mothurOut("The tree and group parameters are both required.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n\n");
+ m->mothurOut("The read.tree command must be run before you execute a unifrac.weighted, unifrac.unweighted. \n");
+ m->mothurOut("It also must be run before using the parsimony command, unless you are using the randomtree parameter.\n");
+ m->mothurOut("The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile).\n");
+ m->mothurOut("The tree and group parameters are both required.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n\n");
}
catch(exception& e) {
- errorOut(e, "ReadTreeCommand", "help");
+ m->errorOut(e, "ReadTreeCommand", "help");
exit(1);
}
}
readOk = read->read();
- if (readOk != 0) { mothurOut("Read Terminated."); mothurOutEndLine(); globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
+ if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine(); globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
vector<Tree*> T = globaldata->gTree;
map<string, string>::iterator it = nameMap.find(treeMap->namesOfSeqs[i]);
if (it == nameMap.end()) {
- mothurOut(treeMap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); mothurOutEndLine();
+ m->mothurOut(treeMap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); m->mothurOutEndLine();
treeMap->removeSeq(treeMap->namesOfSeqs[i]);
i--; //need this because removeSeq removes name from namesOfSeqs
}
return 0;
}
catch(exception& e) {
- errorOut(e, "ReadTreeCommand", "execute");
+ m->errorOut(e, "ReadTreeCommand", "execute");
exit(1);
}
}
splitAtComma(second, dupNames);
for (int i = 0; i < dupNames.size(); i++) { nameMap[dupNames[i]] = dupNames[i]; }
- }else { mothurOut(first + " has already been seen in namefile, disregarding names file."); mothurOutEndLine(); in.close(); globaldata->names.clear(); return 1; }
+ }else { m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); globaldata->names.clear(); return 1; }
}
in.close();
return 0;
}
catch(exception& e) {
- errorOut(e, "ReadTreeCommand", "readNamesFile");
+ m->errorOut(e, "ReadTreeCommand", "readNamesFile");
exit(1);
}
}
//**********************************************************************************************************************
-RemoveSeqsCommand::RemoveSeqsCommand(string option){
+RemoveSeqsCommand::RemoveSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
accnosfile = validParameter.validFile(parameters, "accnos", true);
if (accnosfile == "not open") { abort = true; }
- else if (accnosfile == "not found") { accnosfile = ""; mothurOut("You must provide an accnos file."); mothurOutEndLine(); abort = true; }
+ else if (accnosfile == "not found") { accnosfile = ""; m->mothurOut("You must provide an accnos file."); m->mothurOutEndLine(); abort = true; }
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
string temp = validParameter.validFile(parameters, "dups", false); if (temp == "not found") { temp = "false"; usedDups = ""; }
dups = isTrue(temp);
- if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "")) { mothurOut("You must provide one of the following: fasta, name, group, alignreport or list."); mothurOutEndLine(); abort = true; }
+ if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport or list."); m->mothurOutEndLine(); abort = true; }
int okay = 2;
if (outputDir != "") { okay++; }
if (usedDups != "") { okay++; }
- if ((usedDups != "") && (namefile == "")) { mothurOut("You may only use dups with the name option."); mothurOutEndLine(); abort = true; }
+ if ((usedDups != "") && (namefile == "")) { m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine(); abort = true; }
- if (parameters.size() > okay) { mothurOut("You may only enter one of the following: fasta, name, group, alignreport, or list."); mothurOutEndLine(); abort = true; }
+ if (parameters.size() > okay) { m->mothurOut("You may only enter one of the following: fasta, name, group, alignreport, or list."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "RemoveSeqsCommand");
+ m->errorOut(e, "RemoveSeqsCommand", "RemoveSeqsCommand");
exit(1);
}
}
void RemoveSeqsCommand::help(){
try {
- mothurOut("The remove.seqs command reads an .accnos file and one of the following file types: fasta, name, group, list or alignreport file.\n");
- mothurOut("It outputs a file containing the sequences NOT in the .accnos file.\n");
- mothurOut("The remove.seqs command parameters are accnos, fasta, name, group, list, alignreport and dups. You must provide accnos and one of the file parameters.\n");
- mothurOut("The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=false. If dups=true, then remove.seqs outputs a new .accnos file containing all the sequences removed. \n");
- mothurOut("The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
- mothurOut("Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The remove.seqs command reads an .accnos file and one of the following file types: fasta, name, group, list or alignreport file.\n");
+ m->mothurOut("It outputs a file containing the sequences NOT in the .accnos file.\n");
+ m->mothurOut("The remove.seqs command parameters are accnos, fasta, name, group, list, alignreport and dups. You must provide accnos and one of the file parameters.\n");
+ m->mothurOut("The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=false. If dups=true, then remove.seqs outputs a new .accnos file containing all the sequences removed. \n");
+ m->mothurOut("The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
+ m->mothurOut("Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "help");
+ m->errorOut(e, "RemoveSeqsCommand", "help");
exit(1);
}
}
else if (alignfile != "") { readAlign(); }
else if (listfile != "") { readList(); }
+ if (outputNames.size() != 0) {
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+ }
+
return 0;
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "execute");
+ m->errorOut(e, "RemoveSeqsCommand", "execute");
exit(1);
}
}
out.close();
if (wroteSomething == false) {
- mothurOut("Your file contains only sequences from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readFasta");
+ m->errorOut(e, "RemoveSeqsCommand", "readFasta");
exit(1);
}
}
out.close();
if (wroteSomething == false) {
- mothurOut("Your file contains only sequences from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readList");
+ m->errorOut(e, "RemoveSeqsCommand", "readList");
exit(1);
}
}
if (dups) { out2.close(); }
if (wroteDups == false) {
remove(outputFileName2.c_str());
- }
+ }else { outputNames.push_back(outputFileName2); }
if (wroteSomething == false) {
- mothurOut("Your file contains only sequences from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readName");
+ m->errorOut(e, "RemoveSeqsCommand", "readName");
exit(1);
}
}
out.close();
if (wroteSomething == false) {
- mothurOut("Your file contains only sequences from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readGroup");
+ m->errorOut(e, "RemoveSeqsCommand", "readGroup");
exit(1);
}
}
out.close();
if (wroteSomething == false) {
- mothurOut("Your file contains only sequences from the .accnos file."); mothurOutEndLine();
+ m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
- }
+ }else { outputNames.push_back(outputFileName); }
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readAlign");
+ m->errorOut(e, "RemoveSeqsCommand", "readAlign");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "RemoveSeqsCommand", "readAccnos");
+ m->errorOut(e, "RemoveSeqsCommand", "readAccnos");
exit(1);
}
}
set<string> names;
string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, outputDir;
bool abort, dups;
+ vector<string> outputNames;
void readFasta();
void readName();
//***************************************************************************************************************
-ReverseSeqsCommand::ReverseSeqsCommand(string option){
+ReverseSeqsCommand::ReverseSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
fasta = validParameter.validFile(parameters, "fasta", true);
if (fasta == "not open") { abort = true; }
- else if (fasta == "not found") { fasta = ""; mothurOut("fasta is a required parameter for the reverse.seqs command."); mothurOutEndLine(); abort = true; }
+ else if (fasta == "not found") { fasta = ""; m->mothurOut("fasta is a required parameter for the reverse.seqs command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
}
}
catch(exception& e) {
- errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
+ m->errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
exit(1);
}
}
void ReverseSeqsCommand::help(){
try {
- mothurOut("The reverse.seqs command reads a fastafile and ....\n");
- mothurOut("The reverse.seqs command parameter is fasta and it is required.\n");
- mothurOut("The reverse.seqs command should be in the following format: \n");
- mothurOut("reverse.seqs(fasta=yourFastaFile) \n");
+ m->mothurOut("The reverse.seqs command reads a fastafile and ....\n");
+ m->mothurOut("The reverse.seqs command parameter is fasta and it is required.\n");
+ m->mothurOut("The reverse.seqs command should be in the following format: \n");
+ m->mothurOut("reverse.seqs(fasta=yourFastaFile) \n");
}
catch(exception& e) {
- errorOut(e, "ReverseSeqsCommand", "help");
+ m->errorOut(e, "ReverseSeqsCommand", "help");
exit(1);
}
}
inFASTA.close();
outFASTA.close();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(reverseFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "ReverseSeqsCommand", "execute");
+ m->errorOut(e, "ReverseSeqsCommand", "execute");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "SAbundVector");
+ m->errorOut(e, "SAbundVector", "SAbundVector");
exit(1);
}
}
numSeqs = ns;
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "SAbundVector");
+ m->errorOut(e, "SAbundVector", "SAbundVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "SAbundVector");
+ m->errorOut(e, "SAbundVector", "SAbundVector");
exit(1);
}
}
if(sabund > maxRank) { maxRank = sabund; }
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "set");
+ m->errorOut(e, "SAbundVector", "set");
exit(1);
}
}
numSeqs += (maxRank * abundance);
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "push_back");
+ m->errorOut(e, "SAbundVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "print");
+ m->errorOut(e, "SAbundVector", "print");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "getRAbundVector");
+ m->errorOut(e, "SAbundVector", "getRAbundVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SAbundVector", "getOrderVector");
+ m->errorOut(e, "SAbundVector", "getOrderVector");
exit(1);
}
}
//***************************************************************************************************************
-ScreenSeqsCommand::ScreenSeqsCommand(string option){
+ScreenSeqsCommand::ScreenSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
- if (fastafile == "not found") { mothurOut("fasta is a required parameter for the screen.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastafile == "not found") { m->mothurOut("fasta is a required parameter for the screen.seqs command."); m->mothurOutEndLine(); abort = true; }
else if (fastafile == "not open") { abort = true; }
groupfile = validParameter.validFile(parameters, "group", true);
}
catch(exception& e) {
- errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
+ m->errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
exit(1);
}
}
void ScreenSeqsCommand::help(){
try {
- mothurOut("The screen.seqs command reads a fastafile and creates .....\n");
- mothurOut("The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, and group.\n");
- mothurOut("The fasta parameter is required.\n");
- mothurOut("The start parameter .... The default is -1.\n");
- mothurOut("The end parameter .... The default is -1.\n");
- mothurOut("The maxambig parameter .... The default is -1.\n");
- mothurOut("The maxhomop parameter .... The default is -1.\n");
- mothurOut("The minlength parameter .... The default is -1.\n");
- mothurOut("The maxlength parameter .... The default is -1.\n");
- mothurOut("The name parameter allows you to provide a namesfile, and the group parameter allows you to provide a groupfile.\n");
- mothurOut("The screen.seqs command should be in the following format: \n");
- mothurOut("screen.seqs(fasta=yourFastaFile, name=youNameFile, group=yourGroupFIle, start=yourStart, end=yourEnd, maxambig=yourMaxambig, \n");
- mothurOut("maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength) \n");
- mothurOut("Example screen.seqs(fasta=abrecovery.fasta, name=abrecovery.names, group=abrecovery.groups, start=..., end=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The screen.seqs command reads a fastafile and creates .....\n");
+ m->mothurOut("The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, and group.\n");
+ m->mothurOut("The fasta parameter is required.\n");
+ m->mothurOut("The start parameter .... The default is -1.\n");
+ m->mothurOut("The end parameter .... The default is -1.\n");
+ m->mothurOut("The maxambig parameter .... The default is -1.\n");
+ m->mothurOut("The maxhomop parameter .... The default is -1.\n");
+ m->mothurOut("The minlength parameter .... The default is -1.\n");
+ m->mothurOut("The maxlength parameter .... The default is -1.\n");
+ m->mothurOut("The name parameter allows you to provide a namesfile, and the group parameter allows you to provide a groupfile.\n");
+ m->mothurOut("The screen.seqs command should be in the following format: \n");
+ m->mothurOut("screen.seqs(fasta=yourFastaFile, name=youNameFile, group=yourGroupFIle, start=yourStart, end=yourEnd, maxambig=yourMaxambig, \n");
+ m->mothurOut("maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength) \n");
+ m->mothurOut("Example screen.seqs(fasta=abrecovery.fasta, name=abrecovery.names, group=abrecovery.groups, start=..., end=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "ScreenSeqsCommand", "help");
+ m->errorOut(e, "ScreenSeqsCommand", "help");
exit(1);
}
}
goodSeqOut.close();
badSeqOut.close();
inFASTA.close();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ m->mothurOut(goodSeqFile); m->mothurOutEndLine();
+ m->mothurOut(badSeqFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "ScreenSeqsCommand", "execute");
+ m->errorOut(e, "ScreenSeqsCommand", "execute");
exit(1);
}
}
//we were unable to remove some of the bad sequences
if (badSeqNames.size() != 0) {
for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {
- mothurOut("Your namefile does not include the sequence " + *it + " please correct.");
- mothurOutEndLine();
+ m->mothurOut("Your namefile does not include the sequence " + *it + " please correct.");
+ m->mothurOutEndLine();
}
}
//we were unable to remove some of the bad sequences
if (badSeqGroups.size() != 0) {
for (it = badSeqGroups.begin(); it != badSeqGroups.end(); it++) {
- mothurOut("Your namefile does not include the sequence " + *it + " please correct.");
- mothurOutEndLine();
+ m->mothurOut("Your namefile does not include the sequence " + *it + " please correct.");
+ m->mothurOutEndLine();
}
}
}
//we were unable to remove some of the bad sequences
if (badSeqNames.size() != 0) {
for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {
- mothurOut("Your groupfile does not include the sequence " + *it + " please correct.");
- mothurOutEndLine();
+ m->mothurOut("Your groupfile does not include the sequence " + *it + " please correct.");
+ m->mothurOutEndLine();
}
}
//we were unable to remove some of the bad sequences
if (badSeqNames.size() != 0) {
for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {
- mothurOut("Your file does not include the sequence " + *it + " please correct.");
- mothurOutEndLine();
+ m->mothurOut("Your file does not include the sequence " + *it + " please correct.");
+ m->mothurOutEndLine();
}
}
//**********************************************************************************************************************
-AlignCheckCommand::AlignCheckCommand(string option){
+AlignCheckCommand::AlignCheckCommand(string option) {
try {
abort = false;
haderror = 0;
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//check for required parameters
mapfile = validParameter.validFile(parameters, "map", true);
if (mapfile == "not open") { abort = true; }
- else if (mapfile == "not found") { mapfile = ""; mothurOut("You must provide an map file."); mothurOutEndLine(); abort = true; }
+ else if (mapfile == "not found") { mapfile = ""; m->mothurOut("You must provide an map file."); m->mothurOutEndLine(); abort = true; }
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
- else if (fastafile == "not found") { fastafile = ""; mothurOut("You must provide an fasta file."); mothurOutEndLine(); abort = true; }
+ else if (fastafile == "not found") { fastafile = ""; m->mothurOut("You must provide an fasta file."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "RemoveSeqsCommand");
+ m->errorOut(e, "AlignCheckCommand", "RemoveSeqsCommand");
exit(1);
}
}
void AlignCheckCommand::help(){
try {
- mothurOut("The align.check command reads a fasta file and map file.\n");
- mothurOut("It outputs a file containing the secondary structure matches in the .align.check file.\n");
- mothurOut("The align.check command parameters are fasta and map, both are required.\n");
- mothurOut("The align.check command should be in the following format: align.check(fasta=yourFasta, map=yourMap).\n");
- mothurOut("Example align.check(map=silva.ss.map, fasta=amazon.fasta).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ m->mothurOut("The align.check command reads a fasta file and map file.\n");
+ m->mothurOut("It outputs a file containing the secondary structure matches in the .align.check file.\n");
+ m->mothurOut("The align.check command parameters are fasta and map, both are required.\n");
+ m->mothurOut("The align.check command should be in the following format: align.check(fasta=yourFasta, map=yourMap).\n");
+ m->mothurOut("Example align.check(map=silva.ss.map, fasta=amazon.fasta).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "help");
+ m->errorOut(e, "AlignCheckCommand", "help");
exit(1);
}
}
in.close();
out.close();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(outfile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "execute");
+ m->errorOut(e, "AlignCheckCommand", "execute");
exit(1);
}
}
for(int i=0;i<seqLength;i++){
if(structMap[i] != 0){
if(structMap[structMap[i]] != i){
- mothurOut("Your map file contains an error: line " + toString(i) + " does not match line " + toString(structMap[i]) + "."); mothurOutEndLine();
+ m->mothurOut("Your map file contains an error: line " + toString(i) + " does not match line " + toString(structMap[i]) + "."); m->mothurOutEndLine();
}
}
}
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "readMap");
+ m->errorOut(e, "AlignCheckCommand", "readMap");
exit(1);
}
}
int length = sequence.length();
- if (length != seqLength) { mothurOut("your sequences are " + toString(length) + " long, but your map file only contains " + toString(seqLength) + " entries. please correct."); mothurOutEndLine(); haderror = 1; return data; }
+ if (length != seqLength) { m->mothurOut("your sequences are " + toString(length) + " long, but your map file only contains " + toString(seqLength) + " entries. please correct."); m->mothurOutEndLine(); haderror = 1; return data; }
for(int i=1;i<length;i++){
if(structMap[i] != 0){
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "getStats");
+ m->errorOut(e, "AlignCheckCommand", "getStats");
exit(1);
}
}
//***************************************************************************************************************
-SeqSummaryCommand::SeqSummaryCommand(string option){
+SeqSummaryCommand::SeqSummaryCommand(string option) {
try {
abort = false;
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
- else if (fastafile == "not found") { fastafile = ""; mothurOut("fasta is a required parameter for the summary.seqs command."); mothurOutEndLine(); abort = true; }
+ else if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the summary.seqs command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
}
}
catch(exception& e) {
- errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
+ m->errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
exit(1);
}
}
void SeqSummaryCommand::help(){
try {
- mothurOut("The summary.seqs command reads a fastafile and ....\n");
- mothurOut("The summary.seqs command parameter is fasta and it is required.\n");
- mothurOut("The summary.seqs command should be in the following format: \n");
- mothurOut("summary.seqs(fasta=yourFastaFile) \n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
+ m->mothurOut("The summary.seqs command reads a fastafile and ....\n");
+ m->mothurOut("The summary.seqs command parameter is fasta and it is required.\n");
+ m->mothurOut("The summary.seqs command should be in the following format: \n");
+ m->mothurOut("summary.seqs(fasta=yourFastaFile) \n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
}
catch(exception& e) {
- errorOut(e, "SeqSummaryCommand", "help");
+ m->errorOut(e, "SeqSummaryCommand", "help");
exit(1);
}
}
if (startPosition[0] == -1) { startPosition[0] = 0; }
if (endPosition[0] == -1) { endPosition[0] = 0; }
- mothurOutEndLine();
- mothurOut("\t\tStart\tEnd\tNBases\tAmbigs\tPolymer"); mothurOutEndLine();
- mothurOut("Minimum:\t" + toString(startPosition[0]) + "\t" + toString(endPosition[0]) + "\t" + toString(seqLength[0]) + "\t" + toString(ambigBases[0]) + "\t" + toString(longHomoPolymer[0])); mothurOutEndLine();
- mothurOut("2.5%-tile:\t" + toString(startPosition[ptile0_25]) + "\t" + toString(endPosition[ptile0_25]) + "\t" + toString(seqLength[ptile0_25]) + "\t" + toString(ambigBases[ptile0_25]) + "\t"+ toString(longHomoPolymer[ptile0_25])); mothurOutEndLine();
- mothurOut("25%-tile:\t" + toString(startPosition[ptile25]) + "\t" + toString(endPosition[ptile25]) + "\t" + toString(seqLength[ptile25]) + "\t" + toString(ambigBases[ptile25]) + "\t" + toString(longHomoPolymer[ptile25])); mothurOutEndLine();
- mothurOut("Median: \t" + toString(startPosition[ptile50]) + "\t" + toString(endPosition[ptile50]) + "\t" + toString(seqLength[ptile50]) + "\t" + toString(ambigBases[ptile50]) + "\t" + toString(longHomoPolymer[ptile50])); mothurOutEndLine();
- mothurOut("75%-tile:\t" + toString(startPosition[ptile75]) + "\t" + toString(endPosition[ptile75]) + "\t" + toString(seqLength[ptile75]) + "\t" + toString(ambigBases[ptile75]) + "\t" + toString(longHomoPolymer[ptile75])); mothurOutEndLine();
- mothurOut("97.5%-tile:\t" + toString(startPosition[ptile97_5]) + "\t" + toString(endPosition[ptile97_5]) + "\t" + toString(seqLength[ptile97_5]) + "\t" + toString(ambigBases[ptile97_5]) + "\t" + toString(longHomoPolymer[ptile97_5])); mothurOutEndLine();
- mothurOut("Maximum:\t" + toString(startPosition[ptile100]) + "\t" + toString(endPosition[ptile100]) + "\t" + toString(seqLength[ptile100]) + "\t" + toString(ambigBases[ptile100]) + "\t" + toString(longHomoPolymer[ptile100])); mothurOutEndLine();
- mothurOut("# of Seqs:\t" + toString(numSeqs)); mothurOutEndLine();
+ m->mothurOutEndLine();
+ m->mothurOut("\t\tStart\tEnd\tNBases\tAmbigs\tPolymer"); m->mothurOutEndLine();
+ m->mothurOut("Minimum:\t" + toString(startPosition[0]) + "\t" + toString(endPosition[0]) + "\t" + toString(seqLength[0]) + "\t" + toString(ambigBases[0]) + "\t" + toString(longHomoPolymer[0])); m->mothurOutEndLine();
+ m->mothurOut("2.5%-tile:\t" + toString(startPosition[ptile0_25]) + "\t" + toString(endPosition[ptile0_25]) + "\t" + toString(seqLength[ptile0_25]) + "\t" + toString(ambigBases[ptile0_25]) + "\t"+ toString(longHomoPolymer[ptile0_25])); m->mothurOutEndLine();
+ m->mothurOut("25%-tile:\t" + toString(startPosition[ptile25]) + "\t" + toString(endPosition[ptile25]) + "\t" + toString(seqLength[ptile25]) + "\t" + toString(ambigBases[ptile25]) + "\t" + toString(longHomoPolymer[ptile25])); m->mothurOutEndLine();
+ m->mothurOut("Median: \t" + toString(startPosition[ptile50]) + "\t" + toString(endPosition[ptile50]) + "\t" + toString(seqLength[ptile50]) + "\t" + toString(ambigBases[ptile50]) + "\t" + toString(longHomoPolymer[ptile50])); m->mothurOutEndLine();
+ m->mothurOut("75%-tile:\t" + toString(startPosition[ptile75]) + "\t" + toString(endPosition[ptile75]) + "\t" + toString(seqLength[ptile75]) + "\t" + toString(ambigBases[ptile75]) + "\t" + toString(longHomoPolymer[ptile75])); m->mothurOutEndLine();
+ m->mothurOut("97.5%-tile:\t" + toString(startPosition[ptile97_5]) + "\t" + toString(endPosition[ptile97_5]) + "\t" + toString(seqLength[ptile97_5]) + "\t" + toString(ambigBases[ptile97_5]) + "\t" + toString(longHomoPolymer[ptile97_5])); m->mothurOutEndLine();
+ m->mothurOut("Maximum:\t" + toString(startPosition[ptile100]) + "\t" + toString(endPosition[ptile100]) + "\t" + toString(seqLength[ptile100]) + "\t" + toString(ambigBases[ptile100]) + "\t" + toString(longHomoPolymer[ptile100])); m->mothurOutEndLine();
+ m->mothurOut("# of Seqs:\t" + toString(numSeqs)); m->mothurOutEndLine();
outSummary.close();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut(summaryFile); m->mothurOutEndLine();
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "SeqSummaryCommand", "execute");
+ m->errorOut(e, "SeqSummaryCommand", "execute");
exit(1);
}
}
/***********************************************************************/
Sequence::Sequence(){
+ m = MothurOut::getInstance();
initialize();
}
return sequence;
}
catch(exception& e) {
- errorOut(e, "Sequence", "getSequenceString");
+ m->errorOut(e, "Sequence", "getSequenceString");
exit(1);
}
}
return sequence;
}
catch(exception& e) {
- errorOut(e, "Sequence", "getCommentString");
+ m->errorOut(e, "Sequence", "getCommentString");
exit(1);
}
}
*/
#include "mothur.h"
-
+#include "mothurout.h"
/**************************************************************************************************/
void printSequence(ostream&);
private:
+ MothurOut* m;
void initialize();
string getSequenceString(ifstream&);
string getCommentString(ifstream&);
/***********************************************************************/
-SequenceDB::SequenceDB() {}
+SequenceDB::SequenceDB() { m = MothurOut::getInstance(); }
/***********************************************************************/
//the clear function free's the memory
SequenceDB::~SequenceDB() { clear(); }
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "SequenceDB");
+ m->errorOut(e, "SequenceDB", "SequenceDB");
exit(1);
}
}
return name;
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "readName");
+ m->errorOut(e, "SequenceDB", "readName");
exit(1);
}
}
return sequence;
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "readSequence");
+ m->errorOut(e, "SequenceDB", "readSequence");
exit(1);
}
}
data[index] = Sequence(data[index].getName(), newUnaligned);
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "set");
+ m->errorOut(e, "SequenceDB", "set");
exit(1);
}
}
data[index] = newSeq;
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "set");
+ m->errorOut(e, "SequenceDB", "set");
exit(1);
}
}
data.resize(newSize);
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "resize");
+ m->errorOut(e, "SequenceDB", "resize");
exit(1);
}
}
data.clear();
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "clear");
+ m->errorOut(e, "SequenceDB", "clear");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "print");
+ m->errorOut(e, "SequenceDB", "print");
exit(1);
}
}
data.push_back(newSequence);
}
catch(exception& e) {
- errorOut(e, "SequenceDB", "push_back");
+ m->errorOut(e, "SequenceDB", "push_back");
exit(1);
}
}
vector<Sequence> data;
string readName(ifstream&);
string readSequence(ifstream&);
+ MothurOut* m;
};
//**********************************************************************************************************************
-SetDirectoryCommand::SetDirectoryCommand(string option){
+SetDirectoryCommand::SetDirectoryCommand(string option) {
try {
abort = false;
if (input == "not found") { input = ""; }
if ((input == "") && (output == "")) {
- mothurOut("You must provide either an input or output for the set.outdir command."); mothurOutEndLine(); abort = true;
+ m->mothurOut("You must provide either an input or output for the set.outdir command."); m->mothurOutEndLine(); abort = true;
}
}
}
catch(exception& e) {
- errorOut(e, "SetDirectoryCommand", "SetDirectoryCommand");
+ m->errorOut(e, "SetDirectoryCommand", "SetDirectoryCommand");
exit(1);
}
}
void SetDirectoryCommand::help(){
try {
- mothurOut("The set.dir command can be used to direct the output files generated by mothur to a specific place, the directory must exist.\n");
- mothurOut("The set.dir command can also be used to specify the directory where your input files are located, the directory must exist.\n");
- mothurOut("The set.dir command parameter is output and is required.\n");
- mothurOut("To return the output to the same directory as the input files you may enter: output=clear.\n");
- mothurOut("To return the input to the same directory as the mothur.exe you may enter: input=clear.\n");
- mothurOut("The set.dir command should be in the following format: set.dir(output=yourOutputDirectory, input=yourInputDirectory).\n");
- mothurOut("Example set.outdir(output=/Users/lab/desktop/outputs, input=/Users/lab/desktop/inputs).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. output), '=' and parameters (i.e.yourOutputDirectory).\n\n");
+ m->mothurOut("The set.dir command can be used to direct the output files generated by mothur to a specific place, the directory must exist.\n");
+ m->mothurOut("The set.dir command can also be used to specify the directory where your input files are located, the directory must exist.\n");
+ m->mothurOut("The set.dir command parameter is output and is required.\n");
+ m->mothurOut("To return the output to the same directory as the input files you may enter: output=clear.\n");
+ m->mothurOut("To return the input to the same directory as the mothur.exe you may enter: input=clear.\n");
+ m->mothurOut("The set.dir command should be in the following format: set.dir(output=yourOutputDirectory, input=yourInputDirectory).\n");
+ m->mothurOut("Example set.outdir(output=/Users/lab/desktop/outputs, input=/Users/lab/desktop/inputs).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. output), '=' and parameters (i.e.yourOutputDirectory).\n\n");
}
catch(exception& e) {
- errorOut(e, "SetDirectoryCommand", "help");
+ m->errorOut(e, "SetDirectoryCommand", "help");
exit(1);
}
}
ofstream out;
out.open(outTemp.c_str(), ios::trunc);
if(!out) {
- mothurOut(output + " directory does not exist or is not writable."); mothurOutEndLine();
+ m->mothurOut(output + " directory does not exist or is not writable."); m->mothurOutEndLine();
}else{
out.close();
remove(outTemp.c_str());
- mothurOut("Changing output directory to " + output); mothurOutEndLine();
+ m->mothurOut("Changing output directory to " + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
}
}
ofstream in;
in.open(inTemp.c_str(), ios::trunc);
if(!in) {
- mothurOut(input + " directory does not exist or is not writable."); mothurOutEndLine();
+ m->mothurOut(input + " directory does not exist or is not writable."); m->mothurOutEndLine();
}else{
in.close();
remove(inTemp.c_str());
- mothurOut("Changing input directory to " + input); mothurOutEndLine();
+ m->mothurOut("Changing input directory to " + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "SetDirectoryCommand", "SetDirectoryCommand");
+ m->errorOut(e, "SetDirectoryCommand", "SetDirectoryCommand");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Shannon", "getValues");
+ m->errorOut(e, "Shannon", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SharedAce", "getValues");
+ m->errorOut(e, "SharedAce", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Anderberg", "getValues");
+ m->errorOut(e, "Anderberg", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "BrayCurtis", "getValues");
+ m->errorOut(e, "BrayCurtis", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "getValues");
+ m->errorOut(e, "SharedChao1", "getValues");
exit(1);
}
}
setCoef(f2root, 0);
}
catch(exception& e) {
- if ((toString(e.what()) == "vector::_M_fill_insert") || (toString(e.what()) == "St9bad_alloc")) { mothurOut("You are using " + toString(n) + " groups which creates 2^" + toString(n+1) + " nodes. Try reducing the number of groups you selected. "); mothurOutEndLine(); exit(1); }
- errorOut(e, "SharedChao1", "initialTree");
+ if ((toString(e.what()) == "vector::_M_fill_insert") || (toString(e.what()) == "St9bad_alloc")) { m->mothurOut("You are using " + toString(n) + " groups which creates 2^" + toString(n+1) + " nodes. Try reducing the number of groups you selected. "); m->mothurOutEndLine(); exit(1); }
+ m->errorOut(e, "SharedChao1", "initialTree");
exit(1);
}
}
updateBranchf2(f2root, bin, 0);
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "updateTree");
+ m->errorOut(e, "SharedChao1", "updateTree");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "updateBranchf1");
+ m->errorOut(e, "SharedChao1", "updateBranchf1");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "updateBranchf2");
+ m->errorOut(e, "SharedChao1", "updateBranchf2");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "setCoef");
+ m->errorOut(e, "SharedChao1", "setCoef");
exit(1);
}
}
//for debugging purposes
void SharedChao1::printTree() {
- mothurOut("F1 leaves"); mothurOutEndLine();
+ m->mothurOut("F1 leaves"); m->mothurOutEndLine();
printBranch(f1root);
- mothurOut("F2 leaves"); mothurOutEndLine();
+ m->mothurOut("F2 leaves"); m->mothurOutEndLine();
printBranch(f2root);
printBranch(node->left);
printBranch(node->right);
}else { //you are a leaf
- mothurOut(toString(node->lvalue)); mothurOutEndLine();
- mothurOut(toString(node->rvalue)); mothurOutEndLine();
+ m->mothurOut(toString(node->lvalue)); m->mothurOutEndLine();
+ m->mothurOut(toString(node->rvalue)); m->mothurOutEndLine();
}
}
catch(exception& e) {
- errorOut(e, "SharedChao1", "printBranch");
+ m->errorOut(e, "SharedChao1", "printBranch");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "SharedCommand");
+ m->errorOut(e, "SharedCommand", "SharedCommand");
exit(1);
}
}
vector<SharedRAbundVector*> lookup;
if ((globaldata->Groups.size() == 0) && (SharedList->getNumSeqs() != groupMap->getNumSeqs())) { //if the user has not specified any groups and their files don't match exit with error
- mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); mothurOutEndLine();
+ m->mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine();
out.close();
remove(filename.c_str()); //remove blank shared file you made
if (pickedGroups) { //check for otus with no seqs in them
eliminateZeroOTUS(lookup);
}
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
if (pickedGroups) { //check for otus with no seqs in them
eliminateZeroOTUS(lookup);
}
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
if (pickedGroups) { //check for otus with no seqs in them
eliminateZeroOTUS(lookup);
}
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
return 0;
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "execute");
+ m->errorOut(e, "SharedCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "printSharedData");
+ m->errorOut(e, "SharedCommand", "printSharedData");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "eliminateZeroOTUS");
+ m->errorOut(e, "SharedCommand", "eliminateZeroOTUS");
exit(1);
}
}
//you have sequences in your list file that are not in your group file
if (SharedList->getNumSeqs() > groupMap->getNumSeqs()) {
outputMisMatchName += "missing.group";
- mothurOut("For a list of names that are in your list file and not in your group file, please refer to " + outputMisMatchName + "."); mothurOutEndLine();
+ m->mothurOut("For a list of names that are in your list file and not in your group file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
openOutputFile(outputMisMatchName, outMisMatch);
if(group == "not found") { outMisMatch << name << endl; }
itList = listNames.find(name);
- if (itList != listNames.end()) { mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); }
+ if (itList != listNames.end()) { m->mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
else { listNames[name] = name; }
}
if(group == "not found") { outMisMatch << names << endl; }
itList = listNames.find(names);
- if (itList != listNames.end()) { mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); }
+ if (itList != listNames.end()) { m->mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
else { listNames[names] = names; }
}
}else {//you have sequences in your group file that are not in you list file
outputMisMatchName += "missing.name";
- mothurOut("For a list of names that are in your group file and not in your list file, please refer to " + outputMisMatchName + "."); mothurOutEndLine();
+ m->mothurOut("For a list of names that are in your group file and not in your list file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
map<string, string> namesInList;
map<string, string>::iterator itList;
names = names.substr(names.find_first_of(',')+1, names.length());
itList = namesInList.find(name);
- if (itList != namesInList.end()) { mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); }
+ if (itList != namesInList.end()) { m->mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
namesInList[name] = name;
}
itList = namesInList.find(names);
- if (itList != namesInList.end()) { mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); }
+ if (itList != namesInList.end()) { m->mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
//get last name
namesInList[names] = names;
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "createMisMatchFile");
+ m->errorOut(e, "SharedCommand", "createMisMatchFile");
exit(1);
}
}
return false;
}
catch(exception& e) {
- errorOut(e, "SharedCommand", "isValidGroup");
+ m->errorOut(e, "SharedCommand", "isValidGroup");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "JAbund", "getValues");
+ m->errorOut(e, "JAbund", "getValues");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedJackknife", "getValues");
+ m->errorOut(e, "SharedJackknife", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Jclass", "getValues");
+ m->errorOut(e, "Jclass", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Jest", "getValues");
+ m->errorOut(e, "Jest", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "KSTest", "getValues");
+ m->errorOut(e, "KSTest", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Kulczynski", "getValues");
+ m->errorOut(e, "Kulczynski", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "KulczynskiCody", "getValues");
+ m->errorOut(e, "KulczynskiCody", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Lennon", "getValues");
+ m->errorOut(e, "Lennon", "getValues");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "SharedListVector");
+ m->errorOut(e, "SharedListVector", "SharedListVector");
exit(1);
}
}
numSeqs += (nNames_new - nNames_old);
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "set");
+ m->errorOut(e, "SharedListVector", "set");
exit(1);
}
}
numSeqs += nNames;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "push_back");
+ m->errorOut(e, "SharedListVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "print");
+ m->errorOut(e, "SharedListVector", "print");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getRAbundVector");
+ m->errorOut(e, "SharedListVector", "getRAbundVector");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getSAbundVector");
+ m->errorOut(e, "SharedListVector", "getSAbundVector");
exit(1);
}
}
names = names.substr(names.find_first_of(',')+1, names.length());
groupName = groupmap->getGroup(name);
- if(groupName == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(groupName == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
order->push_back(i, binSize, groupName); //i represents what bin you are in
}
//get last name
groupName = groupmap->getGroup(names);
- if(groupName == "not found") { mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(groupName == "not found") { m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
order->push_back(i, binSize, groupName);
}
return order;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getSharedOrderVector");
+ m->errorOut(e, "SharedListVector", "getSharedOrderVector");
exit(1);
}
}
name = names.substr(0,names.find_first_of(','));
names = names.substr(names.find_first_of(',')+1, names.length());
group = groupmap->getGroup(name);
- if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
if (group == groupName) { //this name is in the group you want the vector for.
rav.set(i, rav.getAbundance(i) + 1, group); //i represents what bin you are in
}
//get last name
groupName = groupmap->getGroup(names);
- if(groupName == "not found") { mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(groupName == "not found") { m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
if (group == groupName) { //this name is in the group you want the vector for.
rav.set(i, rav.getAbundance(i) + 1, group); //i represents what bin you are in
}
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getSharedRAbundVector");
+ m->errorOut(e, "SharedListVector", "getSharedRAbundVector");
exit(1);
}
}
name = names.substr(0,names.find_first_of(','));
names = names.substr(names.find_first_of(',')+1, names.length());
group = groupmap->getGroup(name);
- if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in
}
//get last name
group = groupmap->getGroup(names);
- if(group == "not found") { mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in
}
return lookup;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getSharedRAbundVector");
+ m->errorOut(e, "SharedListVector", "getSharedRAbundVector");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getSharedSAbundVector");
+ m->errorOut(e, "SharedListVector", "getSharedSAbundVector");
exit(1);
}
}
}
else{
if(orderMap->count(seqName) == 0){
- mothurOut(seqName + " not found, check *.names file\n");
+ m->mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
}
if(orderMap->count(seqName) == 0){
- mothurOut(seqName + " not found, check *.names file\n");
+ m->mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
ov.set((*orderMap)[seqName], i);
}
}
catch(exception& e) {
- errorOut(e, "SharedListVector", "getOrderVector");
+ m->errorOut(e, "SharedListVector", "getOrderVector");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SharedMarczewski", "getValues");
+ m->errorOut(e, "SharedMarczewski", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "MorHorn", "getValues");
+ m->errorOut(e, "MorHorn", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Ochiai", "getValues");
+ m->errorOut(e, "Ochiai", "getValues");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "SharedOrderVector");
+ m->errorOut(e, "SharedOrderVector", "SharedOrderVector");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "print");
+ m->errorOut(e, "SharedOrderVector", "print");
exit(1);
}
}
/***********************************************************************/
void SharedOrderVector::resize(int){
- mothurOut("resize() did nothing in class SharedOrderVector");
+ m->mothurOut("resize() did nothing in class SharedOrderVector");
}
/***********************************************************************/
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "getRAbundVector");
+ m->errorOut(e, "SharedOrderVector", "getRAbundVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "getOrderVector");
+ m->errorOut(e, "SharedOrderVector", "getOrderVector");
exit(1);
}
}
return sharedRav;
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
+ m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
exit(1);
}
}
return lookup;
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
+ m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "getSharedSAbundVector");
+ m->errorOut(e, "SharedOrderVector", "getSharedSAbundVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedOrderVector", "updateStats");
+ m->errorOut(e, "SharedOrderVector", "updateStats");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
+ m->errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
+ m->errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
exit(1);
}
}
numSeqs += (newBinSize - oldBinSize);
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "set");
+ m->errorOut(e, "SharedRAbundVector", "set");
exit(1);
}
}
numSeqs += binSize;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "push_back");
+ m->errorOut(e, "SharedRAbundVector", "push_back");
exit(1);
}
}
numSeqs += binSize;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "insert");
+ m->errorOut(e, "SharedRAbundVector", "insert");
exit(1);
}
}
numSeqs += binSize;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "push_front");
+ m->errorOut(e, "SharedRAbundVector", "push_front");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "print");
+ m->errorOut(e, "SharedRAbundVector", "print");
exit(1);
}
}
return lookup;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getSharedRAbundVectors");
+ m->errorOut(e, "SharedRAbundVector", "getSharedRAbundVectors");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getRAbundVector");
+ m->errorOut(e, "SharedRAbundVector", "getRAbundVector");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getRAbundVector2");
+ m->errorOut(e, "SharedRAbundVector", "getRAbundVector2");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getSharedSAbundVector");
+ m->errorOut(e, "SharedRAbundVector", "getSharedSAbundVector");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getSAbundVector");
+ m->errorOut(e, "SharedRAbundVector", "getSAbundVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getSharedOrderVector");
+ m->errorOut(e, "SharedRAbundVector", "getSharedOrderVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SharedRAbundVector", "getOrderVector");
+ m->errorOut(e, "SharedRAbundVector", "getOrderVector");
exit(1);
}
}
if(bin > maxRank) { maxRank = bin; }
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "set");
+ m->errorOut(e, "SharedSAbundVector", "set");
exit(1);
}
}
numSeqs += (maxRank * abundance);
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "push_back");
+ m->errorOut(e, "SharedSAbundVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "print");
+ m->errorOut(e, "SharedSAbundVector", "print");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "getRAbundVector");
+ m->errorOut(e, "SharedSAbundVector", "getRAbundVector");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "getSAbundVector");
+ m->errorOut(e, "SharedSAbundVector", "getSAbundVector");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "getSharedRAbundVector");
+ m->errorOut(e, "SharedSAbundVector", "getSharedRAbundVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "getSharedOrderVector");
+ m->errorOut(e, "SharedSAbundVector", "getSharedOrderVector");
exit(1);
}
}
return ov;
}
catch(exception& e) {
- errorOut(e, "SharedSAbundVector", "getOrderVector");
+ m->errorOut(e, "SharedSAbundVector", "getOrderVector");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SharedSobs", "getValues");
+ m->errorOut(e, "SharedSobs", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SharedSobsCS", "getValues");
+ m->errorOut(e, "SharedSobsCS", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SorAbund", "getValues");
+ m->errorOut(e, "SorAbund", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SorClass", "getValues");
+ m->errorOut(e, "SorClass", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "SorEst", "getValues");
+ m->errorOut(e, "SorEst", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "ThetaN", "getValues");
+ m->errorOut(e, "ThetaN", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "ThetaYC", "getValues");
+ m->errorOut(e, "ThetaYC", "getValues");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "getSharedVectors");
+ m->errorOut(e, "SharedUtil", "getSharedVectors");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "getSharedVectorswithReplacement");
+ m->errorOut(e, "SharedUtil", "getSharedVectorswithReplacement");
exit(1);
}
}
//check that groups are valid
for (int i = 0; i < userGroups.size(); i++) {
if (isValidGroup(userGroups[i], allGroups) != true) {
- mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
+ m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
// erase the invalid group from userGroups
userGroups.erase(userGroups.begin()+i);
i--;
//if the user only entered invalid groups
if (userGroups.size() == 0) {
- mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
for (int i = 0; i < allGroups.size(); i++) {
userGroups.push_back(allGroups[i]);
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "setGroups");
+ m->errorOut(e, "SharedUtil", "setGroups");
exit(1);
}
}
//check that groups are valid
for (int i = 0; i < userGroups.size(); i++) {
if (isValidGroup(userGroups[i], allGroups) != true) {
- mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
+ m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
// erase the invalid group from userGroups
userGroups.erase(userGroups.begin()+i);
i--;
if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) {
//if the user only entered invalid groups
if ((userGroups.size() == 0) || (userGroups.size() == 1)) {
- mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
for (int i = 0; i < allGroups.size(); i++) {
userGroups.push_back(allGroups[i]);
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "setGroups");
+ m->errorOut(e, "SharedUtil", "setGroups");
exit(1);
}
}
//check that groups are valid
for (int i = 0; i < userGroups.size(); i++) {
if (isValidGroup(userGroups[i], allGroups) != true) {
- mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
+ m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
// erase the invalid group from globaldata->Groups
userGroups.erase(userGroups.begin()+i);
i--;
userGroups.push_back(allGroups[i]);
}
}
- mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
}else if (userGroups.size() == 1) {
- mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
userGroups.clear();
for (int i=0; i < allGroups.size(); i++) {
if (allGroups[i] != "xxx") {
}else if ((mode == "unweighted") || (mode == "parsimony")) {
//if the user only entered invalid groups
if ((userGroups.size() == 0) && (numGroups == 0)) {
- mothurOut("When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
for (int i = 0; i < allGroups.size(); i++) {
if (allGroups[i] != "xxx") {
userGroups.push_back(allGroups[i]);
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "setGroups");
+ m->errorOut(e, "SharedUtil", "setGroups");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "getCombos");
+ m->errorOut(e, "SharedUtil", "getCombos");
exit(1);
}
}
return false;
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "isValidGroup");
+ m->errorOut(e, "SharedUtil", "isValidGroup");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SharedUtil", "updateGroupIndex");
+ m->errorOut(e, "SharedUtil", "updateGroupIndex");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
class SharedRAbundVector;
class SharedOrderVector;
class SharedUtil {
public:
- SharedUtil() {};
+ SharedUtil() { m = MothurOut::getInstance(); }
~SharedUtil() {};
void getSharedVectors(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
bool isValidGroup(string, vector<string>);
private:
-
+ MothurOut* m;
};
double f0 = ace[0]-rank->getNumBins();
- data[0] = f0 * (1 - pow(1 - f1/n/f0, m));
+ data[0] = f0 * (1 - pow(1 - f1/n/f0, f));
delete calc;
return data;
}
catch(exception& e) {
- errorOut(e, "Shen", "getValues");
+ m->errorOut(e, "Shen", "getValues");
exit(1);
}
}
class Shen : public Calculator {
public:
- Shen(int size, int n) : m(size), abund(n), Calculator("shen", 1, false) {};
+ Shen(int size, int n) : f(size), abund(n), Calculator("shen", 1, false) {};
EstOutput getValues(SAbundVector*);
EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
private:
- int m;
+ int f;
int abund;
};
return data;
}
catch(exception& e) {
- errorOut(e, "Simpson", "getValues");
+ m->errorOut(e, "Simpson", "getValues");
exit(1);
}
}
removeCell(rowCells[rowInd], -1 , -1);
}
catch(exception& e) {
- errorOut(e, "SingleLinkage", "update");
+ m->errorOut(e, "SingleLinkage", "update");
exit(1);
}
}
return(changed);
}
catch(exception& e) {
- errorOut(e, "SingleLinkage", "updateDistance");
+ m->errorOut(e, "SingleLinkage", "updateDistance");
exit(1);
}
}
/***********************************************************************/
Slayer::Slayer(int win, int increment, int parentThreshold, float div, int i, int snp) :
- windowSize(win), windowStep(increment), parentFragmentThreshold(parentThreshold), divRThreshold(div), iters(i), percentSNPSample(snp){}
+ windowSize(win), windowStep(increment), parentFragmentThreshold(parentThreshold), divRThreshold(div), iters(i), percentSNPSample(snp){ m = MothurOut::getInstance(); }
/***********************************************************************/
string Slayer::getResults(Sequence* query, vector<Sequence*> refSeqs) {
try {
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "getResults");
+ m->errorOut(e, "Slayer", "getResults");
exit(1);
}
}
//check window size
if (length < (2*windowSize+windowStep)) {
- mothurOut("Your window size is too large for " + q->getName() + ". I will make the window size " + toString(length/4) + " which is 1/4 the filtered length."); mothurOutEndLine();
+ m->mothurOut("Your window size is too large for " + q->getName() + ". I will make the window size " + toString(length/4) + " which is 1/4 the filtered length."); m->mothurOutEndLine();
windowSize = length / 4;
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "runBellerophon");
+ m->errorOut(e, "Slayer", "runBellerophon");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "getSNPS");
+ m->errorOut(e, "Slayer", "getSNPS");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "bootstrapSNPS");
+ m->errorOut(e, "Slayer", "bootstrapSNPS");
exit(1);
}
}
return percentID;
}
catch(exception& e) {
- errorOut(e, "Slayer", "snpQA");
+ m->errorOut(e, "Slayer", "snpQA");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "snpQB");
+ m->errorOut(e, "Slayer", "snpQB");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Slayer", "snpAB");
+ m->errorOut(e, "Slayer", "snpAB");
exit(1);
}
}
return percentID;
}
catch(exception& e) {
- errorOut(e, "Slayer", "computePercentID");
+ m->errorOut(e, "Slayer", "computePercentID");
exit(1);
}
}
return maskMap;
}
catch(exception& e) {
- errorOut(e, "Slayer", "verticalFilter");
+ m->errorOut(e, "Slayer", "verticalFilter");
exit(1);
}
}
float snpQA(vector<snps>);
float snpQB(vector<snps>);
float snpAB(vector<snps>);
+ MothurOut* m;
};
return dCXYValues;
}
catch(exception& e) {
- errorOut(e, "SLibshuff", "evaluateAll");
+ m->errorOut(e, "SLibshuff", "evaluateAll");
exit(1);
}
}
return sum;
}
catch(exception& e) {
- errorOut(e, "SLibshuff", "sCalculate");
+ m->errorOut(e, "SLibshuff", "sCalculate");
exit(1);
}
}
double f1 = (double)rank->get(1);
double f2 = (double)rank->get(2);
- data[0] = f1*f1/2/f2 * (1 - pow(1 - 2*f2/n/f1, m));
+ data[0] = f1*f1/2/f2 * (1 - pow(1 - 2*f2/n/f1, f));
return data;
}
catch(exception& e) {
- errorOut(e, "Solow", "getValues");
+ m->errorOut(e, "Solow", "getValues");
exit(1);
}
}
class Solow : public Calculator {
public:
- Solow(int size) : m(size), Calculator("solow", 1, false) {};
+ Solow(int size) : f(size), Calculator("solow", 1, false) {};
EstOutput getValues(SAbundVector*);
EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
private:
- int m;
+ int f;
};
/***********************************************************************/
-SparseMatrix::SparseMatrix() : numNodes(0), minsIndex(0), smallDist(1e6){}
+SparseMatrix::SparseMatrix() : numNodes(0), minsIndex(0), smallDist(1e6){ m = MothurOut::getInstance(); }
/***********************************************************************/
// clustering and the clustering algorithm updates smallDist
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "rmCell");
+ m->errorOut(e, "SparseMatrix", "rmCell");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "addCell");
+ m->errorOut(e, "SparseMatrix", "addCell");
exit(1);
}
}
smallDist = 1e6;
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "clear");
+ m->errorOut(e, "SparseMatrix", "clear");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "print");
+ m->errorOut(e, "SparseMatrix", "print");
exit(1);
}
}
try {
int index = 0;
- mothurOutEndLine(); mothurOut("Index\tRow\tColumn\tDistance"); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("Index\tRow\tColumn\tDistance"); m->mothurOutEndLine();
for(MatData currentCell=matrix.begin();currentCell!=matrix.end();currentCell++){
- mothurOut(toString(index) + "\t" + toString(list->get(currentCell->row)) + "\t" + toString(list->get(currentCell->column)) + "\t" + toString(currentCell->dist)); mothurOutEndLine();
+ m->mothurOut(toString(index) + "\t" + toString(list->get(currentCell->row)) + "\t" + toString(list->get(currentCell->column)) + "\t" + toString(currentCell->dist)); m->mothurOutEndLine();
index++;
}
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "print");
+ m->errorOut(e, "SparseMatrix", "print");
exit(1);
}
}
return smallCell;
}
catch(exception& e) {
- errorOut(e, "SparseMatrix", "getSmallestCell");
+ m->errorOut(e, "SparseMatrix", "getSmallestCell");
exit(1);
}
}
#define SPARSEMATRIX_H
#include "mothur.h"
+#include "mothurout.h"
class ListVector;
vector<PCell*> mins;
float smallDist;
int minsIndex;
+ MothurOut* m;
};
/***********************************************************************/
return topMatches;
}
catch(exception& e) {
- errorOut(e, "SuffixDB", "findClosestSequences");
+ m->errorOut(e, "SuffixDB", "findClosestSequences");
exit(1);
}
}
count++;
}
catch(exception& e) {
- errorOut(e, "SuffixDB", "addSequence");
+ m->errorOut(e, "SuffixDB", "addSequence");
exit(1);
}
}
parentNode(parent), // we store the parent node as an int
startCharPosition(start), // the suffix tree class will hold the sequence that the startCharPosition and
endCharPosition(end) // endCharPosition indices correspond to
- { /* do nothing */ }
+ { /* do nothing */ m = MothurOut::getInstance(); }
void SuffixNode::setChildren(char, int) { /* do nothing */ } // there's no children in a leaf
void SuffixLeaf::print(string sequence, int nodeNumber){
- mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" +
+ m->mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" +
toString(-1) + "\t" + toString(startCharPosition) + "\t" + toString(endCharPosition) + "\t");
- mothurOut("/");
+ m->mothurOut("/");
for(int i=startCharPosition;i<=endCharPosition;i++){
- mothurOut(toString(deCodeSequence(sequence[i])));
+ m->mothurOut(toString(deCodeSequence(sequence[i])));
}
- mothurOut("/"); mothurOutEndLine();
+ m->mothurOut("/"); m->mothurOutEndLine();
}
//********************************************************************************************************************
}
void SuffixBranch::print(string sequence, int nodeNumber){ // this method is different that than
- mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" + // of a leaf because it prints out a
+ m->mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" + // of a leaf because it prints out a
toString(suffixNode) + "\t" + toString(startCharPosition) + "\t" + toString(endCharPosition) + "\t"); // value for the suffix node
- mothurOut("/");
+ m->mothurOut("/");
for(int i=startCharPosition;i<=endCharPosition;i++){
- mothurOut(toString(deCodeSequence(sequence[i])));
+ m->mothurOut(toString(deCodeSequence(sequence[i])));
}
- mothurOut("/"); mothurOutEndLine();
+ m->mothurOut("/"); m->mothurOutEndLine();
}
// we can access the children by subtracting '0' from the the char value from the string, the difference is an int
*/
#include "mothur.h"
+#include "mothurout.h"
//********************************************************************************************************************
int parentNode;
int startCharPosition;
int endCharPosition;
+ MothurOut* m;
};
//********************************************************************************************************************
//********************************************************************************************************************
-SuffixTree::SuffixTree(){}
+SuffixTree::SuffixTree(){ m = MothurOut::getInstance(); }
//********************************************************************************************************************
void SuffixTree::print(){
vector<SuffixNode*> hold = nodeVector;
sort(hold.begin(), hold.end(), compareParents);
- mothurOut("Address\t\tParent\tNode\tSuffix\tStartC\tEndC\tSuffix"); mothurOutEndLine();
+ m->mothurOut("Address\t\tParent\tNode\tSuffix\tStartC\tEndC\tSuffix"); m->mothurOutEndLine();
for(int i=1;i<=nodeCounter;i++){
hold[i]->print(sequence, i);
}
int nodeCounter;
string seqName;
string sequence;
+ MothurOut* m;
};
//**********************************************************************************************************************
-SummaryCommand::SummaryCommand(string option){
+SummaryCommand::SummaryCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
}
//make sure the user has already run the read.otu command
- if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund, rabund or shared file before you can use the summary.single command."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund, rabund or shared file before you can use the summary.single command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
}
}
catch(exception& e) {
- errorOut(e, "SummaryCommand", "SummaryCommand");
+ m->errorOut(e, "SummaryCommand", "SummaryCommand");
exit(1);
}
}
void SummaryCommand::help(){
try {
- mothurOut("The summary.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
- mothurOut("The summary.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
- mothurOut("The summary.single command parameters are label, calc, abund. No parameters are required.\n");
- mothurOut("The summary.single command should be in the following format: \n");
- mothurOut("summary.single(label=yourLabel, calc=yourEstimators).\n");
- mothurOut("Example summary.single(label=unique-.01-.03, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson).\n");
+ m->mothurOut("The summary.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
+ m->mothurOut("The summary.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n");
+ m->mothurOut("The summary.single command parameters are label, calc, abund. No parameters are required.\n");
+ m->mothurOut("The summary.single command should be in the following format: \n");
+ m->mothurOut("summary.single(label=yourLabel, calc=yourEstimators).\n");
+ m->mothurOut("Example summary.single(label=unique-.01-.03, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson).\n");
validCalculator->printCalc("summary", cout);
- mothurOut("The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson\n");
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n\n");
+ m->mothurOut("The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n\n");
}
catch(exception& e) {
- errorOut(e, "SummaryCommand", "help");
+ m->errorOut(e, "SummaryCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
+ vector<string> outputNames;
+
if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName); }
else { inputFileNames = parseSharedFile(globaldata->getSharedFile()); globaldata->setFormat("rabund"); }
string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p])) + "summary";
globaldata->inputFileName = inputFileNames[p];
+ outputNames.push_back(fileNameRoot);
if (inputFileNames.size() > 1) {
- mothurOutEndLine(); mothurOut("Processing group " + groups[p]); mothurOutEndLine(); mothurOutEndLine();
+ m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
}
sumCalculators.clear();
if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
- mothurOut(sabund->getLabel()); mothurOutEndLine();
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
processedLabels.insert(sabund->getLabel());
userLabels.erase(sabund->getLabel());
delete sabund;
sabund = input->getSAbundVector(lastLabel);
- mothurOut(sabund->getLabel()); mothurOutEndLine();
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
processedLabels.insert(sabund->getLabel());
userLabels.erase(sabund->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (sabund != NULL) { delete sabund; }
sabund = input->getSAbundVector(lastLabel);
- mothurOut(sabund->getLabel()); mothurOutEndLine();
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
outputFileHandle << sabund->getLabel();
for(int i=0;i<sumCalculators.size();i++){
vector<double> data = sumCalculators[i]->getValues(sabund);
globaldata->sabund = NULL;
}
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "SummaryCommand", "execute");
+ m->errorOut(e, "SummaryCommand", "execute");
exit(1);
}
}
return filenames;
}
catch(exception& e) {
- errorOut(e, "SummaryCommand", "parseSharedFile");
+ m->errorOut(e, "SummaryCommand", "parseSharedFile");
exit(1);
}
}
//**********************************************************************************************************************
-SummarySharedCommand::SummarySharedCommand(string option){
+SummarySharedCommand::SummarySharedCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- mothurOut("You must read a list and a group, or a shared before you can use the summary.shared command."); mothurOutEndLine(); abort = true;
+ m->mothurOut("You must read a list and a group, or a shared before you can use the summary.shared command."); m->mothurOutEndLine(); abort = true;
}
//if the user changes the output directory command factory will send this info to us in the output parameter
outputFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "shared.summary";
openOutputFile(outputFileName, outputFileHandle);
+ outputNames.push_back(outputFileName);
+
mult = false;
}
}
}
catch(exception& e) {
- errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
+ m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
exit(1);
}
}
void SummarySharedCommand::help(){
try {
- mothurOut("The summary.shared command can only be executed after a successful read.otu command.\n");
- mothurOut("The summary.shared command parameters are label, calc and all. No parameters are required.\n");
- mothurOut("The summary.shared command should be in the following format: \n");
- mothurOut("summary.shared(label=yourLabel, calc=yourEstimators, groups=yourGroups).\n");
- mothurOut("Example summary.shared(label=unique-.01-.03, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
+ m->mothurOut("The summary.shared command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The summary.shared command parameters are label, calc and all. No parameters are required.\n");
+ m->mothurOut("The summary.shared command should be in the following format: \n");
+ m->mothurOut("summary.shared(label=yourLabel, calc=yourEstimators, groups=yourGroups).\n");
+ m->mothurOut("Example summary.shared(label=unique-.01-.03, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
validCalculator->printCalc("sharedsummary", cout);
- mothurOut("The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan\n");
- mothurOut("The default value for groups is all the groups in your groupfile.\n");
- mothurOut("The label parameter is used to analyze specific labels in your input.\n");
- mothurOut("The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
- mothurOut("If you use sharedchao and run into memory issues, set all to false. \n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
+ m->mothurOut("The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+ m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+ m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
+ m->mothurOut("If you use sharedchao and run into memory issues, set all to false. \n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
}
catch(exception& e) {
- errorOut(e, "SummarySharedCommand", "help");
+ m->errorOut(e, "SummarySharedCommand", "help");
exit(1);
}
}
try {
if (abort == true) { return 0; }
-
+
//if the users entered no valid calculators don't execute command
if (sumCalculators.size() == 0) { return 0; }
//check if any calcs can do multiples
if (mult == true) {
outAllFileName = ((getRootName(globaldata->inputFileName)) + "sharedmultiple.summary");
openOutputFile(outAllFileName, outAll);
+ outputNames.push_back(outAllFileName);
outAll << "label" <<'\t' << "comparison" << '\t';
for(int i=0;i<sumCalculators.size();i++){
}
if (lookup.size() < 2) {
- mothurOut("I cannot run the command without at least 2 valid groups.");
+ m->mothurOut("I cannot run the command without at least 2 valid groups.");
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
//close files and clean up
mult = false;
outAll.close();
remove(outAllFileName.c_str());
+ outputNames.pop_back();
}
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
delete input; globaldata->ginput = NULL;
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "SummarySharedCommand", "execute");
+ m->errorOut(e, "SummarySharedCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SummarySharedCommand", "process");
+ m->errorOut(e, "SummarySharedCommand", "process");
exit(1);
}
}
bool abort, allLines, mult, all;
set<string> labels; //holds labels to be used
string label, calc, groups;
- vector<string> Estimators, Groups;
+ vector<string> Estimators, Groups, outputNames;
vector<SharedRAbundVector*> lookup;
string outputFileName, format, outAllFileName, outputDir;
ofstream outputFileHandle, outAll;
//**********************************************************************************************************************
-SystemCommand::SystemCommand(string option){
+SystemCommand::SystemCommand(string option) {
try {
abort = false;
if(option == "help") { help(); abort = true; }
else {
- if (option == "") { mothurOut("You must enter a command to run."); mothurOutEndLine(); abort = true; }
+ if (option == "") { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; }
else {
//check for outputdir and inputdir parameters
int commaPos = option.find_first_of(',');
}
catch(exception& e) {
- errorOut(e, "SystemCommand", "SystemCommand");
+ m->errorOut(e, "SystemCommand", "SystemCommand");
exit(1);
}
}
void SystemCommand::help(){
try {
- mothurOut("The system command allows you to execute a system command from within mothur.\n");
- mothurOut("The system has no parameters.\n");
- mothurOut("The system command should be in the following format: system(yourCommand).\n");
- mothurOut("Example system(clear).\n");
+ m->mothurOut("The system command allows you to execute a system command from within mothur.\n");
+ m->mothurOut("The system has no parameters.\n");
+ m->mothurOut("The system command should be in the following format: system(yourCommand).\n");
+ m->mothurOut("Example system(clear).\n");
}
catch(exception& e) {
- errorOut(e, "SystemCommand", "help");
+ m->errorOut(e, "SystemCommand", "help");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "SystemCommand", "execute");
+ m->errorOut(e, "SystemCommand", "execute");
exit(1);
}
}
/**************************************************************************************************/
TaxEqualizer::TaxEqualizer(string tfile, int c) : cutoff(c) {
try {
+ m = MothurOut::getInstance();
containsConfidence = false;
ifstream inTax;
if ((cutoff != -1) && (cutoff < highestLevel)) {
highestLevel = cutoff;
}else if (cutoff > highestLevel) {
- mothurOut("The highest level taxonomy you have is " + toString(highestLevel) + " and your cutoff is " + toString(cutoff) + ". I will set the cutoff to " + toString(highestLevel));
- mothurOutEndLine();
+ m->mothurOut("The highest level taxonomy you have is " + toString(highestLevel) + " and your cutoff is " + toString(cutoff) + ". I will set the cutoff to " + toString(highestLevel));
+ m->mothurOutEndLine();
}
inTax.close();
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "TaxEqualizer");
+ m->errorOut(e, "TaxEqualizer", "TaxEqualizer");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "getHighestLevel");
+ m->errorOut(e, "TaxEqualizer", "getHighestLevel");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "extendTaxonomy");
+ m->errorOut(e, "TaxEqualizer", "extendTaxonomy");
exit(1);
}
}
tax += ";";
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "truncateTaxonomy");
+ m->errorOut(e, "TaxEqualizer", "truncateTaxonomy");
exit(1);
}
}
tax = newTax;
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "removeConfidences");
+ m->errorOut(e, "TaxEqualizer", "removeConfidences");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
//reads in taxonomy file and makes all the taxonomies the same length
//by appending the last taxon to a given taxonomy as many times as needed to
void extendTaxonomy(string, string&, int); //name, taxonomy, desired level
void truncateTaxonomy(string, string&, int); //name, taxonomy, desired level
void removeConfidences(string&); //removes the confidence limits on the taxon
-
+ MothurOut* m;
};
Tree::Tree() {
try {
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
if (globaldata->runParse == true) { parseTreeFile(); globaldata->runParse = false; }
//for(int i = 0; i < globaldata->Treenames.size(); i++) { cout << i << '\t' << globaldata->Treenames[i] << endl; }
}
}
catch(exception& e) {
- errorOut(e, "Tree", "Tree");
+ m->errorOut(e, "Tree", "Tree");
exit(1);
}
}
map<string, string>::iterator itNames = globaldata->names.find(name);
- if (itNames == globaldata->names.end()) { mothurOut(name + " is not in your name file, please correct."); mothurOutEndLine(); exit(1); }
+ if (itNames == globaldata->names.end()) { m->mothurOut(name + " is not in your name file, please correct."); m->mothurOutEndLine(); exit(1); }
else {
vector<string> dupNames;
splitAtComma(globaldata->names[name], dupNames);
}
catch(exception& e) {
- errorOut(e, "Tree", "addNamesToCounts");
+ m->errorOut(e, "Tree", "addNamesToCounts");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "getIndex");
+ m->errorOut(e, "Tree", "getIndex");
exit(1);
}
}
globaldata->gTreemap->setIndex(searchName, index);
}
catch(exception& e) {
- errorOut(e, "Tree", "setIndex");
+ m->errorOut(e, "Tree", "setIndex");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "assembleTree");
+ m->errorOut(e, "Tree", "assembleTree");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "getCopy");
+ m->errorOut(e, "Tree", "getCopy");
exit(1);
}
}
return parsimony;
}
catch(exception& e) {
- errorOut(e, "Tree", "mergeGroups");
+ m->errorOut(e, "Tree", "mergeGroups");
exit(1);
}
}
return parsimony;
}
catch(exception& e) {
- errorOut(e, "Tree", "mergeUserGroups");
+ m->errorOut(e, "Tree", "mergeUserGroups");
exit(1);
}
}
return sum;
}
catch(exception& e) {
- errorOut(e, "Tree", "mergeGcounts");
+ m->errorOut(e, "Tree", "mergeGcounts");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "randomLabels");
+ m->errorOut(e, "Tree", "randomLabels");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "randomLabels");
+ m->errorOut(e, "Tree", "randomLabels");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "randomBlengths");
+ m->errorOut(e, "Tree", "randomBlengths");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "randomTopology");
+ m->errorOut(e, "Tree", "randomTopology");
exit(1);
}
}
out << ";" << endl;
}
catch(exception& e) {
- errorOut(e, "Tree", "print");
+ m->errorOut(e, "Tree", "print");
exit(1);
}
}
out << ";" << endl;
}
catch(exception& e) {
- errorOut(e, "Tree", "printForBoot");
+ m->errorOut(e, "Tree", "printForBoot");
exit(1);
}
}
out.close();
}
catch(exception& e) {
- errorOut(e, "Tree", "createNewickFile");
+ m->errorOut(e, "Tree", "createNewickFile");
exit(1);
}
}
return -1;
}
catch(exception& e) {
- errorOut(e, "Tree", "findRoot");
+ m->errorOut(e, "Tree", "findRoot");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Tree", "printBranch");
+ m->errorOut(e, "Tree", "printBranch");
exit(1);
}
}
filehandle.close();
}
catch(exception& e) {
- errorOut(e, "Tree", "parseTreeFile");
+ m->errorOut(e, "Tree", "parseTreeFile");
exit(1);
}
}
return 0;
}
catch(exception& e) {
- errorOut(e, "Tree", "readTreeString");
+ m->errorOut(e, "Tree", "readTreeString");
exit(1);
}
}
//not included in the tree.
//only takes names from the first tree in the tree file and assumes that all trees use the same names.
int readTreeString(ifstream&);
+ MothurOut* m;
};
#include "mothur.h"
#include "tree.h"
+#include "mothurout.h"
/* The tree calculator class is the parent class for tree calculators in mothur. */
class TreeCalculator {
public:
- TreeCalculator(){};
+ TreeCalculator(){ m = MothurOut::getInstance(); }
TreeCalculator(string n) : name(n) {};
virtual ~TreeCalculator(){};
virtual EstOutput getValues(Tree*) = 0;
protected:
EstOutput data;
string name;
+ MothurOut* m;
};
//**********************************************************************************************************************
-TreeGroupCommand::TreeGroupCommand(string option){
+TreeGroupCommand::TreeGroupCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
else { globaldata->setNameFile(namefile); }
//error checking on files
- if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == ""))) { mothurOut("You must run the read.otu command or provide a distance file before running the tree.shared command."); mothurOutEndLine(); abort = true; }
- else if ((phylipfile != "") && (columnfile != "")) { mothurOut("When running the tree.shared command with a distance file you may not use both the column and the phylip parameters."); mothurOutEndLine(); abort = true; }
+ if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == ""))) { m->mothurOut("You must run the read.otu command or provide a distance file before running the tree.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the tree.shared command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
if (columnfile != "") {
- if (namefile == "") { mothurOut("You need to provide a namefile if you are going to use the column format."); mothurOutEndLine(); abort = true; }
+ if (namefile == "") { m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); abort = true; }
}
//check for optional parameter and set defaults
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
+ m->errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
exit(1);
}
}
void TreeGroupCommand::help(){
try {
- mothurOut("The tree.shared command creates a .tre to represent the similiarity between groups or sequences.\n");
- mothurOut("The tree.shared command can only be executed after a successful read.otu command or by providing a distance file.\n");
- mothurOut("The tree.shared command parameters are groups, calc, phylip, column, name, cutoff, precision and label.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
- mothurOut("The group names are separated by dashes. The label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n");
- mothurOut("The phylip or column parameter are required if you do not run the read.otu command first, and only one may be used. If you use a column file the name filename is required. \n");
- mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
- mothurOut("The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n");
- mothurOut("Example tree.shared(groups=A-B-C, calc=jabund-sorabund).\n");
- mothurOut("The default value for groups is all the groups in your groupfile.\n");
- mothurOut("The default value for calc is jclass-thetayc.\n");
- mothurOut("The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose.\n");
+ m->mothurOut("The tree.shared command creates a .tre to represent the similiarity between groups or sequences.\n");
+ m->mothurOut("The tree.shared command can only be executed after a successful read.otu command or by providing a distance file.\n");
+ m->mothurOut("The tree.shared command parameters are groups, calc, phylip, column, name, cutoff, precision and label.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n");
+ m->mothurOut("The group names are separated by dashes. The label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n");
+ m->mothurOut("The phylip or column parameter are required if you do not run the read.otu command first, and only one may be used. If you use a column file the name filename is required. \n");
+ m->mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n");
+ m->mothurOut("The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n");
+ m->mothurOut("Example tree.shared(groups=A-B-C, calc=jabund-sorabund).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+ m->mothurOut("The default value for calc is jclass-thetayc.\n");
+ m->mothurOut("The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose.\n");
validCalculator->printCalc("treegroup", cout);
- mothurOut("Or the tree.shared command can be in the following format: tree.shared(phylip=yourPhylipFile).\n");
- mothurOut("Example tree.shared(phylip=abrecovery.dist).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("Or the tree.shared command can be in the following format: tree.shared(phylip=yourPhylipFile).\n");
+ m->mothurOut("Example tree.shared(phylip=abrecovery.dist).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "help");
+ m->errorOut(e, "TreeGroupCommand", "help");
exit(1);
}
}
if (format == "sharedfile") {
//if the users entered no valid calculators don't execute command
- if (treeCalculators.size() == 0) { mothurOut("You have given no valid calculators."); mothurOutEndLine(); return 0; }
+ if (treeCalculators.size() == 0) { m->mothurOut("You have given no valid calculators."); m->mothurOutEndLine(); return 0; }
//you have groups
read = new ReadOTUFile(globaldata->inputFileName);
lookup = input->getSharedRAbundVectors();
lastLabel = lookup[0]->getLabel();
- if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups. I cannot run the command."); mothurOutEndLine(); return 0; }
+ if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); return 0; }
//used in tree constructor
globaldata->runParse = false;
//create a new filename
outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "tre";
+ outputNames.push_back(outputFile);
createTree();
- mothurOut("Tree complete. "); mothurOutEndLine();
+ m->mothurOut("Tree complete. "); m->mothurOutEndLine();
}
//reset groups parameter
globaldata->Groups.clear();
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "execute");
+ m->errorOut(e, "TreeGroupCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "createTree");
+ m->errorOut(e, "TreeGroupCommand", "createTree");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "printSims");
+ m->errorOut(e, "TreeGroupCommand", "printSims");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "makeSimsDist");
+ m->errorOut(e, "TreeGroupCommand", "makeSimsDist");
exit(1);
}
}
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
processedLabels.insert(lookup[0]->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
process(lookup);
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
for(int i = 0 ; i < treeCalculators.size(); i++) { delete treeCalculators[i]; }
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "makeSimsShared");
+ m->errorOut(e, "TreeGroupCommand", "makeSimsShared");
exit(1);
}
}
//create a new filename
outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
+ outputNames.push_back(outputFile);
for (int k = 0; k < thisLookup.size(); k++) {
for (int l = k; l < thisLookup.size(); l++) {
}
catch(exception& e) {
- errorOut(e, "TreeGroupCommand", "process");
+ m->errorOut(e, "TreeGroupCommand", "process");
exit(1);
}
}
bool abort, allLines;
set<string> labels; //holds labels to be used
string phylipfile, columnfile, namefile, calc, groups, label, outputDir;
- vector<string> Estimators, Groups; //holds estimators to be used
+ vector<string> Estimators, Groups, outputNames; //holds estimators to be used
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
void process(vector<SharedRAbundVector*>);
return false;
}
catch(exception& e) {
- errorOut(e, "TreeMap", "isValidGroup");
+ m->errorOut(e, "TreeMap", "isValidGroup");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "TreeMap", "print");
+ m->errorOut(e, "TreeMap", "print");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TreeMap", "makeSim");
+ m->errorOut(e, "TreeMap", "makeSim");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TreeMap", "makeSim");
+ m->errorOut(e, "TreeMap", "makeSim");
exit(1);
}
}
class TreeMap {
public:
- TreeMap() {};
+ TreeMap() { m = MothurOut::getInstance(); }
TreeMap(string);
~TreeMap();
void readMap();
map<string, GroupIndex>::iterator it;
map<string, int>::iterator it2;
void setNamesOfGroups(string);
+ MothurOut* m;
};
/****************************************************************/
Node::Node() {
+ m = MothurOut::getInstance();
//initialize node
name = "";
branchLength = -1;
//to be used by printTree in the Tree class to print the leaf info
void Node::printNode() {
try{
- mothurOut(toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
+ m->mothurOut(toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
- for (int i = 0; i < group.size(); i++) { mothurOut( group[i] + " "); }
+ for (int i = 0; i < group.size(); i++) { m->mothurOut( group[i] + " "); }
//there is a branch length
if (branchLength != -1) {
- mothurOut(" " + toString(branchLength));
+ m->mothurOut(" " + toString(branchLength));
}
- mothurOut(" |");
+ m->mothurOut(" |");
map<string, int>::iterator it;
for(it=pGroups.begin();it!=pGroups.end();it++){
- mothurOut(" " + it->first + ":" + toString(it->second));
+ m->mothurOut(" " + it->first + ":" + toString(it->second));
}
- mothurOut(" |");
+ m->mothurOut(" |");
for(it=pcount.begin();it!=pcount.end();it++){
- mothurOut(" " + it->first + ":" + toString(it->second));
+ m->mothurOut(" " + it->first + ":" + toString(it->second));
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "Node", "printNode");
+ m->errorOut(e, "Node", "printNode");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
/* This class represents a node on a tree. */
int lchild;
int rchild;
int vectorIndex;
+ MothurOut* m;
};
#endif
//***************************************************************************************************************
-TrimSeqsCommand::TrimSeqsCommand(string option){
+TrimSeqsCommand::TrimSeqsCommand(string option) {
try {
abort = false;
//check for required parameters
fastaFile = validParameter.validFile(parameters, "fasta", true);
- if (fastaFile == "not found") { mothurOut("fasta is a required parameter for the screen.seqs command."); mothurOutEndLine(); abort = true; }
+ if (fastaFile == "not found") { m->mothurOut("fasta is a required parameter for the screen.seqs command."); m->mothurOutEndLine(); abort = true; }
else if (fastaFile == "not open") { abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
allFiles = isTrue(temp);
if(allFiles && oligoFile == ""){
- mothurOut("You selected allfiles, but didn't enter an oligos file. Ignoring the allfiles request."); mothurOutEndLine();
+ m->mothurOut("You selected allfiles, but didn't enter an oligos file. Ignoring the allfiles request."); m->mothurOutEndLine();
}
if((qAverage != 0 && qThreshold != 0) && qFileName == ""){
- mothurOut("You didn't provide a quality file name, quality criteria will be ignored."); mothurOutEndLine();
+ m->mothurOut("You didn't provide a quality file name, quality criteria will be ignored."); m->mothurOutEndLine();
qAverage=0;
qThreshold=0;
}
if(!flip && oligoFile=="" && !maxLength && !minLength && (maxAmbig==-1) && !maxHomoP && qFileName == ""){
- mothurOut("You didn't set any options... quiting command."); mothurOutEndLine();
+ m->mothurOut("You didn't set any options... quiting command."); m->mothurOutEndLine();
abort = true;
}
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
+ m->errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
exit(1);
}
}
void TrimSeqsCommand::help(){
try {
- mothurOut("The trim.seqs command reads a fastaFile and creates .....\n");
- mothurOut("The trim.seqs command parameters are fasta, flip, oligos, maxambig, maxhomop, minlength, maxlength, qfile, qthreshold, qaverage, qtrim and allfiles.\n");
- mothurOut("The fasta parameter is required.\n");
- mothurOut("The flip parameter .... The default is 0.\n");
- mothurOut("The oligos parameter .... The default is "".\n");
- mothurOut("The maxambig parameter .... The default is -1.\n");
- mothurOut("The maxhomop parameter .... The default is 0.\n");
- mothurOut("The minlength parameter .... The default is 0.\n");
- mothurOut("The maxlength parameter .... The default is 0.\n");
- mothurOut("The qfile parameter .....\n");
- mothurOut("The qthreshold parameter .... The default is 0.\n");
- mothurOut("The qaverage parameter .... The default is 0.\n");
- mothurOut("The allfiles parameter .... The default is F.\n");
- mothurOut("The qtrim parameter .... The default is F.\n");
- mothurOut("The trim.seqs command should be in the following format: \n");
- mothurOut("trim.seqs(fasta=yourFastaFile, flip=yourFlip, oligos=yourOligos, maxambig=yourMaxambig, \n");
- mothurOut("maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength) \n");
- mothurOut("Example trim.seqs(fasta=abrecovery.fasta, flip=..., oligos=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n");
- mothurOut("For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n\n");
+ m->mothurOut("The trim.seqs command reads a fastaFile and creates .....\n");
+ m->mothurOut("The trim.seqs command parameters are fasta, flip, oligos, maxambig, maxhomop, minlength, maxlength, qfile, qthreshold, qaverage, qtrim and allfiles.\n");
+ m->mothurOut("The fasta parameter is required.\n");
+ m->mothurOut("The flip parameter .... The default is 0.\n");
+ m->mothurOut("The oligos parameter .... The default is "".\n");
+ m->mothurOut("The maxambig parameter .... The default is -1.\n");
+ m->mothurOut("The maxhomop parameter .... The default is 0.\n");
+ m->mothurOut("The minlength parameter .... The default is 0.\n");
+ m->mothurOut("The maxlength parameter .... The default is 0.\n");
+ m->mothurOut("The qfile parameter .....\n");
+ m->mothurOut("The qthreshold parameter .... The default is 0.\n");
+ m->mothurOut("The qaverage parameter .... The default is 0.\n");
+ m->mothurOut("The allfiles parameter .... The default is F.\n");
+ m->mothurOut("The qtrim parameter .... The default is F.\n");
+ m->mothurOut("The trim.seqs command should be in the following format: \n");
+ m->mothurOut("trim.seqs(fasta=yourFastaFile, flip=yourFlip, oligos=yourOligos, maxambig=yourMaxambig, \n");
+ m->mothurOut("maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength) \n");
+ m->mothurOut("Example trim.seqs(fasta=abrecovery.fasta, flip=..., oligos=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n");
+ m->mothurOut("For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n\n");
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "help");
+ m->errorOut(e, "TrimSeqsCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
+ vector<string> outputNames;
+
numFPrimers = 0; //this needs to be initialized
numRPrimers = 0;
ofstream outFASTA;
string trimSeqFile = outputDir + getRootName(getSimpleName(fastaFile)) + "trim.fasta";
openOutputFile(trimSeqFile, outFASTA);
+ outputNames.push_back(trimSeqFile);
ofstream outGroups;
vector<ofstream*> fastaFileNames;
if(oligoFile != ""){
string groupFile = outputDir + getRootName(getSimpleName(fastaFile)) + "groups";
openOutputFile(groupFile, outGroups);
+ outputNames.push_back(groupFile);
getOligos(fastaFileNames);
}
ofstream scrapFASTA;
string scrapSeqFile = outputDir + getRootName(getSimpleName(fastaFile)) + "scrap.fasta";
openOutputFile(scrapSeqFile, scrapFASTA);
+ outputNames.push_back(scrapSeqFile);
ifstream qFile;
if(qFileName != "") { openInputFile(qFileName, qFile); }
openInputFile(getRootName(fastaFile) + groupVector[i] + ".fasta", inFASTA);
ofstream outGroups;
openOutputFile(outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[i] + ".groups", outGroups);
+ outputNames.push_back(outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[i] + ".groups");
while(!inFASTA.eof()){
if(inFASTA.get() == '>'){
outGroups.close();
inFASTA.close();
}
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "execute");
+ m->errorOut(e, "TrimSeqsCommand", "execute");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "getOligos");
+ m->errorOut(e, "TrimSeqsCommand", "getOligos");
exit(1);
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "stripBarcode");
+ m->errorOut(e, "TrimSeqsCommand", "stripBarcode");
exit(1);
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "stripForward");
+ m->errorOut(e, "TrimSeqsCommand", "stripForward");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "stripReverse");
+ m->errorOut(e, "TrimSeqsCommand", "stripReverse");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "cullLength");
+ m->errorOut(e, "TrimSeqsCommand", "cullLength");
exit(1);
}
return success;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "cullHomoP");
+ m->errorOut(e, "TrimSeqsCommand", "cullHomoP");
exit(1);
}
return success;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "cullAmbigs");
+ m->errorOut(e, "TrimSeqsCommand", "cullAmbigs");
exit(1);
}
return success;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "compareDNASeq");
+ m->errorOut(e, "TrimSeqsCommand", "compareDNASeq");
exit(1);
}
string name;
qFile >> name;
- if (name.length() != 0) { if(name.substr(1) != seq.getName()) { mothurOut("sequence name mismatch btwn fasta and qual file"); mothurOutEndLine(); } }
+ if (name.length() != 0) { if(name.substr(1) != seq.getName()) { m->mothurOut("sequence name mismatch btwn fasta and qual file"); m->mothurOutEndLine(); } }
while (!qFile.eof()) { char c = qFile.get(); if (c == 10 || c == 13){ break; } }
int score;
return 1;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "stripQualThreshold");
+ m->errorOut(e, "TrimSeqsCommand", "stripQualThreshold");
exit(1);
}
}
string name;
qFile >> name;
- if (name[0] == '>') { if(name.substr(1) != seq.getName()) { mothurOut("sequence name mismatch btwn fasta: " + seq.getName() + " and qual file: " + name); mothurOutEndLine(); } }
+ if (name[0] == '>') { if(name.substr(1) != seq.getName()) { m->mothurOut("sequence name mismatch btwn fasta: " + seq.getName() + " and qual file: " + name); m->mothurOutEndLine(); } }
while (!qFile.eof()) { char c = qFile.get(); if (c == 10 || c == 13){ break; } }
return success;
}
catch(exception& e) {
- errorOut(e, "TrimSeqsCommand", "cullQualAverage");
+ m->errorOut(e, "TrimSeqsCommand", "cullQualAverage");
exit(1);
}
}
#include "unifracunweightedcommand.h"
/***********************************************************/
-UnifracUnweightedCommand::UnifracUnweightedCommand(string option) {
+UnifracUnweightedCommand::UnifracUnweightedCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
Groups.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
}
if (globaldata->gTree.size() == 0) {//no trees were read
- mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); mothurOutEndLine(); abort = true; }
+ m->mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
T = globaldata->gTree;
tmap = globaldata->gTreemap;
sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
+ outputNames.push_back(sumFile);
openOutputFile(sumFile, outSum);
util = new SharedUtil();
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
+ m->errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
exit(1);
}
}
void UnifracUnweightedCommand::help(){
try {
- mothurOut("The unifrac.unweighted command can only be executed after a successful read.tree command.\n");
- mothurOut("The unifrac.unweighted command parameters are groups, iters, distance and random. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 1 valid group.\n");
- mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
- mothurOut("The distance parameter allows you to create a distance file from the results. The default is false.\n");
- mothurOut("The random parameter allows you to shut off the comparison to random trees. The default is true, meaning compare your trees with randomly generated trees.\n");
- mothurOut("The unifrac.unweighted command should be in the following format: unifrac.unweighted(groups=yourGroups, iters=yourIters).\n");
- mothurOut("Example unifrac.unweighted(groups=A-B-C, iters=500).\n");
- mothurOut("The default value for groups is all the groups in your groupfile, and iters is 1000.\n");
- mothurOut("The unifrac.unweighted command output two files: .unweighted and .uwsummary their descriptions are in the manual.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The unifrac.unweighted command can only be executed after a successful read.tree command.\n");
+ m->mothurOut("The unifrac.unweighted command parameters are groups, iters, distance and random. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 1 valid group.\n");
+ m->mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
+ m->mothurOut("The distance parameter allows you to create a distance file from the results. The default is false.\n");
+ m->mothurOut("The random parameter allows you to shut off the comparison to random trees. The default is true, meaning compare your trees with randomly generated trees.\n");
+ m->mothurOut("The unifrac.unweighted command should be in the following format: unifrac.unweighted(groups=yourGroups, iters=yourIters).\n");
+ m->mothurOut("Example unifrac.unweighted(groups=A-B-C, iters=500).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, and iters is 1000.\n");
+ m->mothurOut("The unifrac.unweighted command output two files: .unweighted and .uwsummary their descriptions are in the manual.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "help");
+ m->errorOut(e, "UnifracUnweightedCommand", "help");
exit(1);
}
}
//create new tree with same num nodes and leaves as users
outSum << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" <<'\t' << "UWSig" << endl;
- mothurOut("Tree#\tGroups\tUWScore\tUWSig"); mothurOutEndLine();
+ m->mothurOut("Tree#\tGroups\tUWScore\tUWSig"); m->mothurOutEndLine();
//get pscores for users trees
for (int i = 0; i < T.size(); i++) {
counter = 0;
- if (random) { output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted", itersString); }
+ if (random) {
+ output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted", itersString);
+ outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted");
+ }
//get unweighted for users tree
rscoreFreq.resize(numComp);
globaldata->Groups.clear();
outSum.close();
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "execute");
+ m->errorOut(e, "UnifracUnweightedCommand", "execute");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "printUnweightedFile");
+ m->errorOut(e, "UnifracUnweightedCommand", "printUnweightedFile");
exit(1);
}
}
for(int a = 0; a < numComp; a++) {
outSum << i+1 << '\t';
- mothurOut(toString(i+1) + "\t");
+ m->mothurOut(toString(i+1) + "\t");
if (random) {
if (UWScoreSig[a][0] > (1/(float)iters)) {
outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << UWScoreSig[a][0] << endl;
cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << UWScoreSig[a][0] << endl;
- mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t" + toString(UWScoreSig[a][0])); mothurOutEndLine();
+ m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t" + toString(UWScoreSig[a][0])); m->mothurOutEndLine();
}else {
outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl;
cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl;
- mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t<" + toString((1/float(iters)))); mothurOutEndLine();
+ m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t<" + toString((1/float(iters)))); m->mothurOutEndLine();
}
}else{
outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << "0.00" << endl;
cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << "0.00" << endl;
- mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t0.00"); mothurOutEndLine();
+ m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t0.00"); m->mothurOutEndLine();
}
}
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "printUWSummaryFile");
+ m->errorOut(e, "UnifracUnweightedCommand", "printUWSummaryFile");
exit(1);
}
}
void UnifracUnweightedCommand::createPhylipFile(int i) {
try {
string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted.dist";
+ outputNames.push_back(phylipFileName);
+
ofstream out;
openOutputFile(phylipFileName, out);
out.close();
}
catch(exception& e) {
- errorOut(e, "UnifracUnweightedCommand", "createPhylipFile");
+ m->errorOut(e, "UnifracUnweightedCommand", "createPhylipFile");
exit(1);
}
}
bool abort, phylip, random;
string groups, itersString, outputDir;
- vector<string> Groups; //holds groups to be used
+ vector<string> Groups, outputNames; //holds groups to be used
ofstream outSum, out;
ifstream inFile;
globaldata = GlobalData::getInstance();
abort = false;
Groups.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
}
if (globaldata->gTree.size() == 0) {//no trees were read
- mothurOut("You must execute the read.tree command, before you may execute the unifrac.weighted command."); mothurOutEndLine(); abort = true; }
+ m->mothurOut("You must execute the read.tree command, before you may execute the unifrac.weighted command."); m->mothurOutEndLine(); abort = true; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
tmap = globaldata->gTreemap;
sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".wsummary";
openOutputFile(sumFile, outSum);
+ outputNames.push_back(sumFile);
util = new SharedUtil();
string s; //to make work with setgroups
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
+ m->errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
exit(1);
}
}
void UnifracWeightedCommand::help(){
try {
- mothurOut("The unifrac.weighted command can only be executed after a successful read.tree command.\n");
- mothurOut("The unifrac.weighted command parameters are groups, iters, distance and random. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
- mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
- mothurOut("The distance parameter allows you to create a distance file from the results. The default is false.\n");
- mothurOut("The random parameter allows you to shut off the comparison to random trees. The default is true, meaning compare your trees with randomly generated trees.\n");
- mothurOut("The unifrac.weighted command should be in the following format: unifrac.weighted(groups=yourGroups, iters=yourIters).\n");
- mothurOut("Example unifrac.weighted(groups=A-B-C, iters=500).\n");
- mothurOut("The default value for groups is all the groups in your groupfile, and iters is 1000.\n");
- mothurOut("The unifrac.weighted command output two files: .weighted and .wsummary their descriptions are in the manual.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The unifrac.weighted command can only be executed after a successful read.tree command.\n");
+ m->mothurOut("The unifrac.weighted command parameters are groups, iters, distance and random. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n");
+ m->mothurOut("The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n");
+ m->mothurOut("The distance parameter allows you to create a distance file from the results. The default is false.\n");
+ m->mothurOut("The random parameter allows you to shut off the comparison to random trees. The default is true, meaning compare your trees with randomly generated trees.\n");
+ m->mothurOut("The unifrac.weighted command should be in the following format: unifrac.weighted(groups=yourGroups, iters=yourIters).\n");
+ m->mothurOut("Example unifrac.weighted(groups=A-B-C, iters=500).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile, and iters is 1000.\n");
+ m->mothurOut("The unifrac.weighted command output two files: .weighted and .wsummary their descriptions are in the manual.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "help");
+ m->errorOut(e, "UnifracWeightedCommand", "help");
exit(1);
}
}
rScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
uScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
- if (random) { output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted", itersString); }
+ if (random) {
+ output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted", itersString);
+ outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted");
+ }
userData = weighted->getValues(T[i]); //userData[0] = weightedscore
//so if you have 1000 random trees the index returned is 100
//then there are 900 trees with a score greater then you.
//giving you a signifigance of 0.900
- int index = findIndex(userData[f], f); if (index == -1) { mothurOut("error in UnifracWeightedCommand"); mothurOutEndLine(); exit(1); } //error code
+ int index = findIndex(userData[f], f); if (index == -1) { m->mothurOut("error in UnifracWeightedCommand"); m->mothurOutEndLine(); exit(1); } //error code
//the signifigance is the number of trees with the users score or higher
WScoreSig.push_back((iters-index)/(float)iters);
delete randT;
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "execute");
+ m->errorOut(e, "UnifracWeightedCommand", "execute");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "printWeightedFile");
+ m->errorOut(e, "UnifracWeightedCommand", "printWeightedFile");
exit(1);
}
}
try {
//column headers
outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" << endl;
- mothurOut("Tree#\tGroups\tWScore\tWSig"); mothurOutEndLine();
+ m->mothurOut("Tree#\tGroups\tWScore\tWSig"); m->mothurOutEndLine();
//format output
outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
if (WScoreSig[count] > (1/(float)iters)) {
outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << WScoreSig[count] << endl;
cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << WScoreSig[count] << endl;
- mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t" + toString(WScoreSig[count])); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t" + toString(WScoreSig[count])); m->mothurOutEndLine();
}else{
outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl;
cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl;
- mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t<" + toString((1/float(iters)))); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t<" + toString((1/float(iters)))); m->mothurOutEndLine();
}
}else{
outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "0.00" << endl;
cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "0.00" << endl;
- mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t0.00"); mothurOutEndLine();
+ m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t0.00"); m->mothurOutEndLine();
}
count++;
}
outSum.close();
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "printWSummaryFile");
+ m->errorOut(e, "UnifracWeightedCommand", "printWSummaryFile");
exit(1);
}
}
for (int i = 0; i < T.size(); i++) {
string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted.dist";
+ outputNames.push_back(phylipFileName);
ofstream out;
openOutputFile(phylipFileName, out);
}
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "createPhylipFile");
+ m->errorOut(e, "UnifracWeightedCommand", "createPhylipFile");
exit(1);
}
}
return rScores[index].size();
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "findIndex");
+ m->errorOut(e, "UnifracWeightedCommand", "findIndex");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "UnifracWeightedCommand", "calculateFreqsCums");
+ m->errorOut(e, "UnifracWeightedCommand", "calculateFreqsCums");
exit(1);
}
}
class UnifracWeightedCommand : public Command {
public:
- UnifracWeightedCommand(string);
+ UnifracWeightedCommand(string);
~UnifracWeightedCommand() { if (abort == false) { delete weighted; delete util; } }
int execute();
void help();
bool abort, phylip, random;
string groups, itersString;
- vector<string> Groups; //holds groups to be used
+ vector<string> Groups, outputNames; //holds groups to be used
ofstream outSum;
}
catch(exception& e) {
- errorOut(e, "Unweighted", "getValues");
+ m->errorOut(e, "Unweighted", "getValues");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Unweighted", "getValues");
+ m->errorOut(e, "Unweighted", "getValues");
exit(1);
}
}
return results;
}
catch(exception& e) {
- errorOut(e, "UVEst", "getUVest");
+ m->errorOut(e, "UVEst", "getUVest");
exit(1);
}
}
/***********************************************************************/
class UVEst {
public:
- EstOutput getUVest(vector<SharedRAbundVector*>);
+ UVEst() { m = MothurOut::getInstance(); }
+ EstOutput getUVest(vector<SharedRAbundVector*>);
+ private:
+ MothurOut* m;
};
/***********************************************************************/
/********************************************************************/
ValidCalculators::ValidCalculators() {
try {
+ m = MothurOut::getInstance();
+
initialSingle();
initialShared();
initialRarefaction();
initialHeat();
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "ValidCalculator");
+ m->errorOut(e, "ValidCalculator", "ValidCalculator");
exit(1);
}
}
if ((single.find(calculator)) != (single.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
for (it = single.begin(); it != single.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
//are you looking for a calculator for a shared parameter
}else if (parameter == "shared") {
if ((shared.find(calculator)) != (shared.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ");
for (it = shared.begin(); it != shared.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
//are you looking for a calculator for a rarefaction parameter
}else if (parameter == "rarefaction") {
if ((rarefaction.find(calculator)) != (rarefaction.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
//are you looking for a calculator for a summary parameter
}else if (parameter == "summary") {
if ((summary.find(calculator)) != (summary.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
for (it = summary.begin(); it != summary.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
//are you looking for a calculator for a sharedsummary parameter
}else if (parameter == "sharedsummary") {
if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "sharedrarefaction") {
//is it valid
if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
+ m->mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "vennsingle") {
//is it valid
if ((vennsingle.find(calculator)) != (vennsingle.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "vennshared") {
//is it valid
if ((vennshared.find(calculator)) != (vennshared.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
for (it = vennshared.begin(); it != vennshared.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "treegroup") {
//is it valid
if ((treegroup.find(calculator)) != (treegroup.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
for (it = treegroup.begin(); it != treegroup.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "matrix") {
//is it valid
if ((matrix.find(calculator)) != (matrix.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
for (it = matrix.begin(); it != matrix.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "heat") {
//is it valid
if ((heat.find(calculator)) != (heat.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
for (it = heat.begin(); it != heat.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "boot") {
//is it valid
if ((boot.find(calculator)) != (boot.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
for (it = boot.begin(); it != boot.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
}else if (parameter == "distance") {
//is it valid
if ((distance.find(calculator)) != (distance.end())) {
return true;
}else {
- mothurOut(calculator + " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
+ m->mothurOut(calculator + " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
for (it = distance.begin(); it != distance.end(); it++) {
- mothurOut(it->first + ", ");
+ m->mothurOut(it->first + ", ");
}
- mothurOutEndLine();
+ m->mothurOutEndLine();
return false; }
//not a valid parameter
}else { return false; }
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "isValidCalculator");
+ m->errorOut(e, "ValidCalculator", "isValidCalculator");
exit(1);
}
}
single["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialSingle");
+ m->errorOut(e, "ValidCalculator", "initialSingle");
exit(1);
}
}
shared["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialShared");
+ m->errorOut(e, "ValidCalculator", "initialShared");
exit(1);
}
}
rarefaction["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialRarefaction");
+ m->errorOut(e, "ValidCalculator", "initialRarefaction");
exit(1);
}
}
summary["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialSummary");
+ m->errorOut(e, "ValidCalculator", "initialSummary");
exit(1);
}
}
sharedsummary["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialSharedSummary");
+ m->errorOut(e, "ValidCalculator", "initialSharedSummary");
exit(1);
}
}
sharedrarefaction["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialSharedRarefact");
+ m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
exit(1);
}
}
vennsingle["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialVennSingle");
+ m->errorOut(e, "ValidCalculator", "initialVennSingle");
exit(1);
}
}
vennshared["default"] = "default";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialVennShared");
+ m->errorOut(e, "ValidCalculator", "initialVennShared");
exit(1);
}
}
treegroup["braycurtis"] = "braycurtis";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialTreeGroups");
+ m->errorOut(e, "ValidCalculator", "initialTreeGroups");
exit(1);
}
}
heat["braycurtis"] = "braycurtis";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialHeat");
+ m->errorOut(e, "ValidCalculator", "initialHeat");
exit(1);
}
}
matrix["braycurtis"] = "braycurtis";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialMatrix");
+ m->errorOut(e, "ValidCalculator", "initialMatrix");
exit(1);
}
}
boot["braycurtis"] = "braycurtis";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialBoot");
+ m->errorOut(e, "ValidCalculator", "initialBoot");
exit(1);
}
}
distance["onegap"] = "onegap";
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "initialDistance");
+ m->errorOut(e, "ValidCalculator", "initialDistance");
exit(1);
}
}
out << endl;
}
catch(exception& e) {
- errorOut(e, "ValidCalculator", "printCalc");
+ m->errorOut(e, "ValidCalculator", "printCalc");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
//This class contains a list of all valid calculators in Mothur.
//It has a function which will tell you if your calculator is valid for the given parameter.
void initialBoot();
void initialDistance();
void initialHeat();
+
+ MothurOut* m;
};
#endif
ValidParameters::ValidParameters() {
try {
+ m = MothurOut::getInstance();
initParameterRanges();
}
catch(exception& e) {
- errorOut(e, "ValidParameters", "ValidParameters");
+ m->errorOut(e, "ValidParameters", "ValidParameters");
exit(1);
}
}
}
}
if(!valid) {
- mothurOut(parameter + " is not a valid parameter."); mothurOutEndLine();
- mothurOut("The valid parameters are: ");
+ m->mothurOut(parameter + " is not a valid parameter."); m->mothurOutEndLine();
+ m->mothurOut("The valid parameters are: ");
for(int i = 0; i < numParams-1; i++)
- mothurOut(cParams.at(i) + ", ");
- mothurOut("and " + cParams.at(numParams-1) + ".\n");
+ m->mothurOut(cParams.at(i) + ", ");
+ m->mothurOut("and " + cParams.at(numParams-1) + ".\n");
return false;
}
double logNum = log10((double)pVal);
double diff = (double)((int)logNum - logNum);
if(diff != 0) {
- mothurOut("The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n");
+ m->mothurOut("The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n");
return false;
}
}
else if(range.at(4).compare("only") == 0)
c = 1;
else {
- mothurOut("The range can only be 'between' or 'only' the bounding numbers.\n");
+ m->mothurOut("The range can only be 'between' or 'only' the bounding numbers.\n");
return false;
}
else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
d = 1;
else {
- mothurOut("The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n");
+ m->mothurOut("The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n");
return false;
}
else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
e = 1;
else {
- mothurOut("The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n");
+ m->mothurOut("The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n");
return false;
}
if(!valid) {
- mothurOut("The '" + parameter + "' parameter needs to be ");
+ m->mothurOut("The '" + parameter + "' parameter needs to be ");
if(c == 1)
- mothurOut("either '" + toString(a) + "' or '" + toString(b) + "'.\n");
+ m->mothurOut("either '" + toString(a) + "' or '" + toString(b) + "'.\n");
else {
if(a != piSentinel) {
- mothurOut(">");
+ m->mothurOut(">");
if(d != 0)
- mothurOut("=");
- mothurOut(" '" + toString(a) + "'");
+ m->mothurOut("=");
+ m->mothurOut(" '" + toString(a) + "'");
}
if(b == piSentinel)
- mothurOut( "'.\n");
+ m->mothurOut( "'.\n");
else if(a != piSentinel)
- mothurOut(" and ");
+ m->mothurOut(" and ");
if(b != piSentinel) {
- mothurOut("<");
+ m->mothurOut("<");
if(e != 0)
- mothurOut("=");
- mothurOut(" '" + toString(b) + "'.\n");
+ m->mothurOut("=");
+ m->mothurOut(" '" + toString(b) + "'.\n");
}
}
return false;
return true;
}
catch(exception& e) {
- errorOut(e, "ValidParameters", "isValidParameters");
+ m->errorOut(e, "ValidParameters", "isValidParameters");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "ValidParameters", "validFile");
+ m->errorOut(e, "ValidParameters", "validFile");
exit(1);
}
}
parameterRanges["size"] = addParameters(sizeArray, rangeSize);
}
catch(exception& e) {
- errorOut(e, "ValidParameters", "initParameterRanges");
+ m->errorOut(e, "ValidParameters", "initParameterRanges");
exit(1);
}
}
return pVector;
}
catch(exception& e) {
- errorOut(e, "ValidParameters", "addParameters");
+ m->errorOut(e, "ValidParameters", "addParameters");
exit(1);
}
}
*/
#include "mothur.h"
+#include "mothurout.h"
//This class contains a list of all valid parameters in Mothur.
//It has a function which will tell you if your parameter is valid.
private:
map<string, string>::iterator it;
map<string, vector<string> > parameterRanges;
+ MothurOut* m;
};
Venn::Venn(string o) : outputDir(o) {
try {
globaldata = GlobalData::getInstance();
+ m = MothurOut::getInstance();
}
catch(exception& e) {
- errorOut(e, "Venn", "Venn");
+ m->errorOut(e, "Venn", "Venn");
exit(1);
}
}
//**********************************************************************************************************************
-void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
+vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
try {
-
+
+ vector<string> outputNames;
+
for(int i=0;i<vCalcs.size();i++){
string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg";
+ outputNames.push_back(filenamesvg);
openOutputFile(filenamesvg, outsvg);
vector<double> data = vCalcs[i]->getValues(sabund);
outsvg << "</g>\n</svg>\n";
outsvg.close();
}
+
+ return outputNames;
}
catch(exception& e) {
- errorOut(e, "Venn", "getPic");
+ m->errorOut(e, "Venn", "getPic");
exit(1);
}
}
//**********************************************************************************************************************
-void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
+vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
try {
vector<SharedRAbundVector*> subset;
+ vector<string> outputNames;
/******************* 1 Group **************************/
if (lookup.size() == 1) {
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ outputNames.push_back(filenamesvg);
openOutputFile(filenamesvg, outsvg);
//in essence you want to run it like a single
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ outputNames.push_back(filenamesvg);
openOutputFile(filenamesvg, outsvg);
//get estimates for sharedAB
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
-
string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ outputNames.push_back(filenamesvg);
openOutputFile(filenamesvg, outsvg);
if (vCalcs[i]->getName() == "sharedace") {
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); mothurOutEndLine(); }
+ if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); m->mothurOutEndLine(); }
else{
string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ outputNames.push_back(filenamesvg);
openOutputFile(filenamesvg, outsvg);
}
}
+ return outputNames;
+
}
catch(exception& e) {
- errorOut(e, "Venn", "getPic");
+ m->errorOut(e, "Venn", "getPic");
exit(1);
}
}
Venn(string);
~Venn(){};
- void getPic(SAbundVector*, vector<Calculator*>);
- void getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
+ vector<string> getPic(SAbundVector*, vector<Calculator*>);
+ vector<string> getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
private:
GlobalData* globaldata;
Calculator* singleCalc;
string groupComb, outputDir;
ofstream outsvg;
+ MothurOut* m;
};
/***********************************************************************/
//**********************************************************************************************************************
-VennCommand::VennCommand(string option){
+VennCommand::VennCommand(string option) {
try {
globaldata = GlobalData::getInstance();
abort = false;
allLines = 1;
labels.clear();
-
+
//allow user to run help
if(option == "help") { help(); abort = true; }
//make sure the user has already run the read.otu command
if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
- mothurOut("You must read a list, or a list and a group, or a shared before you can use the venn command."); mothurOutEndLine(); abort = true;
+ m->mothurOut("You must read a list, or a list and a group, or a shared before you can use the venn command."); m->mothurOutEndLine(); abort = true;
}
//if the user changes the output directory command factory will send this info to us in the output parameter
}
catch(exception& e) {
- errorOut(e, "VennCommand", "VennCommand");
+ m->errorOut(e, "VennCommand", "VennCommand");
exit(1);
}
}
void VennCommand::help(){
try {
- mothurOut("The venn command can only be executed after a successful read.otu command.\n");
- mothurOut("The venn command parameters are groups, calc, abund and label. No parameters are required.\n");
- mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your venn diagram, you may only use a maximum of 4 groups.\n");
- mothurOut("The group names are separated by dashes. The label allows you to select what distance levels you would like a venn diagram created for, and are also separated by dashes.\n");
- mothurOut("The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, label=yourLabels, abund=yourAbund).\n");
- mothurOut("Example venn(groups=A-B-C, calc=sharedsobs-sharedchao, abund=20).\n");
- mothurOut("The default value for groups is all the groups in your groupfile up to 4, and all labels in your inputfile will be used.\n");
- mothurOut("The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups.\n");
- mothurOut("The default available estimators for calc are sobs, chao and ace if you have only read a list file, and sharedsobs, sharedchao and sharedace if you have read a list and group file or a shared file.\n");
- mothurOut("The only estmiator available four 4 groups is sharedsobs.\n");
- mothurOut("The venn command outputs a .svg file for each calculator you specify at each distance you choose.\n");
- mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
+ m->mothurOut("The venn command can only be executed after a successful read.otu command.\n");
+ m->mothurOut("The venn command parameters are groups, calc, abund and label. No parameters are required.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your venn diagram, you may only use a maximum of 4 groups.\n");
+ m->mothurOut("The group names are separated by dashes. The label allows you to select what distance levels you would like a venn diagram created for, and are also separated by dashes.\n");
+ m->mothurOut("The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, label=yourLabels, abund=yourAbund).\n");
+ m->mothurOut("Example venn(groups=A-B-C, calc=sharedsobs-sharedchao, abund=20).\n");
+ m->mothurOut("The default value for groups is all the groups in your groupfile up to 4, and all labels in your inputfile will be used.\n");
+ m->mothurOut("The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups.\n");
+ m->mothurOut("The default available estimators for calc are sobs, chao and ace if you have only read a list file, and sharedsobs, sharedchao and sharedace if you have read a list and group file or a shared file.\n");
+ m->mothurOut("The only estmiator available four 4 groups is sharedsobs.\n");
+ m->mothurOut("The venn command outputs a .svg file for each calculator you specify at each distance you choose.\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
}
catch(exception& e) {
- errorOut(e, "VennCommand", "help");
+ m->errorOut(e, "VennCommand", "help");
exit(1);
}
}
if (abort == true) { return 0; }
string lastLabel;
+ vector<string> outputNames;
//if the users entered no valid calculators don't execute command
if (vennCalculators.size() == 0) { return 0; }
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
if (lookup.size() > 4) {
- mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); m->mothurOutEndLine();
for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
}
- venn->getPic(lookup, vennCalculators);
+
+ vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
}
if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
if (lookup.size() > 4) {
- mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); m->mothurOutEndLine();
for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
}
- venn->getPic(lookup, vennCalculators);
+ vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
//restore real lastlabel to save below
lookup[0]->setLabel(saveLabel);
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
lookup = input->getSharedRAbundVectors(lastLabel);
- mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
processedLabels.insert(lookup[0]->getLabel());
userLabels.erase(lookup[0]->getLabel());
if (lookup.size() > 4) {
- mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); mothurOutEndLine();
+ m->mothurOut("Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile."); m->mothurOutEndLine();
for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
}
- venn->getPic(lookup, vennCalculators);
+ vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
- mothurOut(sabund->getLabel()); mothurOutEndLine();
- venn->getPic(sabund, vennCalculators);
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+
processedLabels.insert(sabund->getLabel());
userLabels.erase(sabund->getLabel());
delete sabund;
sabund = input->getSAbundVector(lastLabel);
- mothurOut(sabund->getLabel()); mothurOutEndLine();
- venn->getPic(sabund, vennCalculators);
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+
processedLabels.insert(sabund->getLabel());
userLabels.erase(sabund->getLabel());
set<string>::iterator it;
bool needToRun = false;
for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
+ m->mothurOut("Your file does not include the label " + *it);
if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
needToRun = true;
}else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
}
}
if (sabund != NULL) { delete sabund; }
sabund = input->getSAbundVector(lastLabel);
- mothurOut(sabund->getLabel()); mothurOutEndLine();
- venn->getPic(sabund, vennCalculators);
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
+ vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
+ for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+
delete sabund;
}
}
for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+
return 0;
}
catch(exception& e) {
- errorOut(e, "VennCommand", "execute");
+ m->errorOut(e, "VennCommand", "execute");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Weighted", "getValues");
+ m->errorOut(e, "Weighted", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Weighted", "getValues");
+ m->errorOut(e, "Weighted", "getValues");
exit(1);
}
}
return data;
}
catch(exception& e) {
- errorOut(e, "Whittaker", "getValues");
+ m->errorOut(e, "Whittaker", "getValues");
exit(1);
}
}