]> git.donarmstrong.com Git - mothur.git/commitdiff
added logfile feature
authorwestcott <westcott>
Thu, 25 Jun 2009 18:33:56 +0000 (18:33 +0000)
committerwestcott <westcott>
Thu, 25 Jun 2009 18:33:56 +0000 (18:33 +0000)
148 files changed:
ace.cpp
aligncommand.cpp
alignment.cpp
averagelinkage.cpp
bergerparker.cpp
binsequencecommand.cpp
blastalign.cpp
blastdb.cpp
boneh.cpp
bootstrap.cpp
bootstrapsharedcommand.cpp
bstick.cpp
calculator.cpp
calculator.h
chao1.cpp
cluster.cpp
clustercommand.cpp
collect.cpp
collectcommand.cpp
collectsharedcommand.cpp
commandfactory.cpp
commandoptionparser.cpp
completelinkage.cpp
concensuscommand.cpp
coverage.cpp
database.cpp
deconvolutecommand.cpp
distancecommand.cpp
distancedb.cpp
efron.cpp
engine.cpp
fastamap.cpp
fileoutput.cpp
filterseqscommand.cpp
fullmatrix.cpp
geom.cpp
getgroupcommand.cpp
getlabelcommand.cpp
getlinecommand.cpp
getoturepcommand.cpp
getoturepcommand.h
getrabundcommand.cpp
getsabundcommand.cpp
globaldata.cpp
globaldata.hpp
goodscoverage.cpp
groupmap.cpp
heatmap.cpp
heatmapcommand.cpp
heatmapsim.cpp
heatmapsimcommand.cpp
helpcommand.cpp
inputdata.cpp
jackknife.cpp
kmerdb.cpp
libshuff.cpp
libshuffcommand.cpp
listvector.cpp
logsd.cpp
matrixoutputcommand.cpp
mergefilecommand.cpp
mothur.cpp
mothur.h
nameassignment.cpp
nast.cpp
nocommands.cpp
npshannon.cpp
optionparser.cpp
ordervector.cpp
parselistcommand.cpp
parsimony.cpp
parsimonycommand.cpp
progress.cpp
qstat.cpp
quitcommand.cpp
rabundvector.cpp
rarecalc.cpp
raredisplay.cpp
rarefact.cpp
rarefactcommand.cpp
rarefactsharedcommand.cpp
readcolumn.cpp
readdistcommand.cpp
readotu.cpp
readotucommand.cpp
readphylip.cpp
readtree.cpp
readtreecommand.cpp
reversecommand.cpp
sabundvector.cpp
screenseqscommand.cpp
seqsummarycommand.cpp
sequencedb.cpp
shannon.cpp
sharedace.cpp
sharedanderbergs.cpp
sharedbraycurtis.cpp
sharedchao1.cpp
sharedcommand.cpp
sharedjabund.cpp
sharedjackknife.cpp
sharedjclass.cpp
sharedjest.cpp
sharedkstest.cpp
sharedkulczynski.cpp
sharedkulczynskicody.cpp
sharedlennon.cpp
sharedlistvector.cpp
sharedmarczewski.cpp
sharedmorisitahorn.cpp
sharedochiai.cpp
sharedordervector.cpp
sharedrabundvector.cpp
sharedsabundvector.cpp
sharedsobs.cpp
sharedsobscollectsummary.cpp
sharedsorabund.cpp
sharedsorclass.cpp
sharedsorest.cpp
sharedthetan.cpp
sharedthetayc.cpp
sharedutilities.cpp
shen.cpp
simpson.cpp
singlelinkage.cpp
slibshuff.cpp
solow.cpp
sparsematrix.cpp
suffixdb.cpp
suffixnodes.cpp
suffixtree.cpp
summarycommand.cpp
summarysharedcommand.cpp
tree.cpp
treegroupscommand.cpp
treemap.cpp
treenode.cpp
trimseqscommand.cpp
unifracunweightedcommand.cpp
unifracweightedcommand.cpp
unweighted.cpp
uvest.cpp
validcalculator.cpp
validparameter.cpp
venn.cpp
venncommand.cpp
weighted.cpp
whittaker.cpp

diff --git a/ace.cpp b/ace.cpp
index 54d0946eab9cf0b2230ef45ef8749b1feecb9da0..639a48f6e45ac2503bbfbea4d2ba368cfadcd293 100644 (file)
--- a/ace.cpp
+++ b/ace.cpp
@@ -140,13 +140,9 @@ EstOutput Ace::getValues(SAbundVector* rank) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Ace class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Ace", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Ace class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 4bf18d7712276da69d5fc4eb488bc249a213d9c7..0f5c86f5bf1cdc73f048a4c6a7a52b928875bbee 100644 (file)
@@ -58,11 +58,19 @@ AlignCommand::AlignCommand(string option){
                        
                        //check for required parameters
                        templateFileName = validParameter.validFile(parameters, "template", true);
-                       if (templateFileName == "not found") { cout << "template is a required parameter for the align.seqs command." << endl; abort = true; }
+                       if (templateFileName == "not found") { 
+                               mothurOut("template is a required parameter for the align.seqs command."); 
+                               mothurOutEndLine();
+                               abort = true; 
+                       }
                        else if (templateFileName == "not open") { abort = true; }      
                        
                        candidateFileName = validParameter.validFile(parameters, "candidate", true);
-                       if (candidateFileName == "not found") { cout << "candidate is a required parameter for the align.seqs command." << endl; abort = true; }
+                       if (candidateFileName == "not found") { 
+                               mothurOut("candidate is a required parameter for the align.seqs command."); 
+                               mothurOutEndLine();
+                               abort = true; 
+                       }
                        else if (candidateFileName == "not open") { abort = true; }     
                        
                        //check for optional parameter and set defaults
@@ -93,13 +101,9 @@ AlignCommand::AlignCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AlignCommand class Function AlignCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "AlignCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AlignCommand class function AlignCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -117,29 +121,25 @@ AlignCommand::~AlignCommand(){
 
 void AlignCommand::help(){
        try {
-               cout << "The align.seqs command reads a file containing sequences and creates an alignment file and a report file." << "\n";
-               cout << "The align.seqs command parameters are template, candidate, search, ksize, align, match, mismatch, gapopen and gapextend.  " << "\n";
-               cout << "The template and candidate parameters are required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The ksize parameter allows you to specify the kmer size for finding most similar template to candidate.  The default is 7." << "\n";
-               cout << "The match parameter allows you to specify the bonus for having the same base. The default is 1.0." << "\n";
-               cout << "The mistmatch parameter allows you to specify the penalty for having different bases.  The default is -1.0." << "\n";
-               cout << "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -1.0." << "\n";
-               cout << "The gapextend parameter allows you to specify the penalty for extending a gap in an alignment.  The default is -2.0." << "\n";
-               cout << "The align.seqs command should be in the following format: " << "\n";
-               cout << "align.seqs(template=yourTemplateFile, candidate=yourCandidateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty) " << "\n";
-               cout << "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";
-               cout << "Note: No spaces between parameter labels (i.e. candidate), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n";
+               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.\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 7.\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 -1.0.\n");
+               mothurOut("The gapextend parameter allows you to specify the penalty for extending a gap in an alignment.  The default is -2.0.\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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AlignCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AlignCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -153,7 +153,10 @@ int AlignCommand::execute(){
                else if(search == "suffix")             {       templateDB = new SuffixDB(templateFileName);                    }
                else if(search == "blast")              {       templateDB = new BlastDB(templateFileName, gapOpen, gapExtend, match, misMatch);        }
                else {
-                       cout << search << " is not a valid search option. I will run the command using kmer, ksize=8." << endl; kmerSize = 8;
+                       mothurOut(search + " is not a valid search option. I will run the command using kmer, ksize=8.");
+                       mothurOutEndLine();
+                       kmerSize = 8;
+                       
                        templateDB = new KmerDB(templateFileName, kmerSize);
                }
                
@@ -162,7 +165,8 @@ int AlignCommand::execute(){
                else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
                else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
                else {
-                       cout << align << " is not a valid alignment option. I will run the command using needleman." << endl;
+                       mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
+                       mothurOutEndLine();
                        alignment = new NeedlemanOverlap(gapOpen, match, misMatch, 3000);
                }
                
@@ -234,21 +238,16 @@ int AlignCommand::execute(){
                driver(lines[0], alignFileName, reportFileName);
 #endif
                
-               cout << "It took " << time(NULL) - start << " secs to align " << numFastaSeqs << " sequences" << endl;
-               cout << endl;
-               
-               
+               mothurOut("It took " + toString(time(NULL) - start) + " secs to align " + toString(numFastaSeqs) + " sequences.");
+               mothurOutEndLine();
+               mothurOutEndLine();
                
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AlignCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AlignCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -291,13 +290,9 @@ int AlignCommand::driver(linePair* line, string alignFName, string reportFName){
                return 1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AlignCommand class Function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "driver");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AlignCommand class function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************************/
@@ -318,7 +313,7 @@ void AlignCommand::createProcesses(string alignFileName, string reportFileName)
                        }else if (pid == 0){
                                driver(lines[process], alignFileName + toString(getpid()) + ".temp", reportFileName + toString(getpid()) + ".temp");
                                exit(0);
-                       }else { cout << "unable to spawn the necessary processes." << endl; exit(0); }
+                       }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
                }
                
                //force parent to wait until all the processes are done
@@ -329,13 +324,9 @@ void AlignCommand::createProcesses(string alignFileName, string reportFileName)
 #endif         
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AlignCommand class Function createProcesses. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "createProcesses");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AlignCommand class function createProcesses. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************************/
@@ -357,13 +348,9 @@ void AlignCommand::appendAlignFiles(string temp, string filename) {
                output.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "appendAlignFiles");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************************/
@@ -387,13 +374,9 @@ void AlignCommand::appendReportFiles(string temp, string filename) {
                output.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AlignCommand", "appendReportFiles");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index d64d8b20bb61d7a1718c5965a41729b0b6640255..6014506f5e5f3065b13328b4205c972d4b78334a 100644 (file)
@@ -96,11 +96,7 @@ Alignment::~Alignment(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Alignment class Function ~Alignment. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Alignment class function ~Alignment. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Alignment", "~Alignment");
                exit(1);
        }
 }
index 54f380353c6d97f018218c74e7667b3df1f89637..26283ff800ca1241be49d4e7eaf18a97d89617d4 100644 (file)
@@ -67,15 +67,9 @@ void AverageLinkage::update(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the AverageLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "AverageLinkage", "update");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the AverageLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-       
 }
 
 /***********************************************************************/
index b900ce146875232e7decc11126a73a82eeec06be..a1e4b060ccf961dc7aa6bd075173f1b91d4776ac 100644 (file)
@@ -23,13 +23,9 @@ EstOutput BergerParker::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BergerParker class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BergerParker", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BergerParker class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index a291caae25782de3d9af111fc149011c77d72eea..88057379be6f400e656b73f5a9c85d4f52a32a22 100644 (file)
@@ -37,12 +37,16 @@ BinSeqCommand::BinSeqCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if (globaldata->getListFile() == "") { cout << "You must read a listfile before running the bin.seqs command." << endl; abort = true; }
+                       if (globaldata->getListFile() == "") { 
+                               mothurOut("You must read a listfile before running the bin.seqs command."); 
+                               mothurOutEndLine(); 
+                               abort = true; 
+                       }
                        
                        
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { cout << "fasta is a required parameter for the bin.seqs command." << endl; abort = true; }
+                       if (fastafile == "not found") { mothurOut("fasta is a required parameter for the bin.seqs command.");  mothurOutEndLine(); abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
                
                        //check for optional parameter and set defaults
@@ -62,7 +66,7 @@ BinSeqCommand::BinSeqCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if ((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -90,40 +94,30 @@ BinSeqCommand::BinSeqCommand(string option){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function BinSeqCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BinSeqCommand", "BinSeqCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function BinSeqCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void BinSeqCommand::help(){
        try {
-               cout << "The bin.seqs command can only be executed after a successful read.otu command of a listfile." << "\n";
-               cout << "The bin.seqs command parameters are fasta, name, line, label and group.  The fasta parameter is required, and you may not use line and label at the same time." << "\n";
-               cout << "The line and label allow you to select what distance levels you would like a output files created for, and are separated by dashes." << "\n";
-               cout << "The bin.seqs command should be in the following format: bin.seqs(fasta=yourFastaFile, name=yourNamesFile, group=yourGroupFile, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example bin.seqs(fasta=amazon.fasta, group=amazon.groups, line=1-3-5, name=amazon.names)." << "\n";
-               cout << "The default value for line and label are all lines in your inputfile." << "\n";
-               cout << "The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name." << "\n";
-               cout << "If you provide a groupfile, then it also appends the sequences group to the name." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n";
+               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, line, label and group.  The fasta parameter is required, and you may not use line and label at the same time.\n");
+               mothurOut("The line and label allow 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, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example bin.seqs(fasta=amazon.fasta, group=amazon.groups, line=1-3-5, name=amazon.names).\n");
+               mothurOut("The default value for line and label are 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BinSeqCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
-
-
 //**********************************************************************************************************************
 
 BinSeqCommand::~BinSeqCommand(){
@@ -208,12 +202,12 @@ int BinSeqCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + ".");  mothurOutEndLine();
                        }
                }
                
@@ -231,13 +225,9 @@ int BinSeqCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BinSeqCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -269,13 +259,9 @@ void BinSeqCommand::readNamesFile() {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BinSeqCommand", "readNamesFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 //return 1 if error, 0 otherwise
@@ -285,7 +271,7 @@ int BinSeqCommand::process(ListVector* list, int count) {
                                string outputFileName = getRootName(globaldata->getListFile()) + list->getLabel() + ".fasta";
                                openOutputFile(outputFileName, out);
 
-                               cout << list->getLabel() << '\t' << count << endl;
+                               mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                
                                //for each bin in the list vector
                                for (int i = 0; i < list->size(); i++) {
@@ -306,7 +292,7 @@ int BinSeqCommand::process(ListVector* list, int count) {
                                                        }else {//if you do have groups
                                                                string group = groupMap->getGroup(name);
                                                                if (group == "not found") {  
-                                                                       cout << name << " is missing from your group file. Please correct. " << endl;
+                                                                       mothurOut(name + " is missing from your group file. Please correct. ");  mothurOutEndLine();
                                                                        remove(outputFileName.c_str());
                                                                        return 1;
                                                                }else{
@@ -316,7 +302,7 @@ int BinSeqCommand::process(ListVector* list, int count) {
                                                                }
                                                        }
                                                }else { 
-                                                       cout << name << " is missing from your fasta or name file. Please correct. " << endl; 
+                                                       mothurOut(name + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine();
                                                        remove(outputFileName.c_str());
                                                        return 1;
                                                }
@@ -334,7 +320,7 @@ int BinSeqCommand::process(ListVector* list, int count) {
                                                }else {//if you do have groups
                                                        string group = groupMap->getGroup(binnames);
                                                        if (group == "not found") {  
-                                                               cout << binnames << " is missing from your group file. Please correct. " << endl;
+                                                               mothurOut(binnames + " is missing from your group file. Please correct. "); mothurOutEndLine();
                                                                remove(outputFileName.c_str());
                                                                return 1;
                                                        }else{
@@ -344,7 +330,7 @@ int BinSeqCommand::process(ListVector* list, int count) {
                                                        }
                                                }
                                        }else { 
-                                               cout << binnames << " is missing from your fasta or name file. Please correct. " << endl; 
+                                               mothurOut(binnames + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine();
                                                remove(outputFileName.c_str());
                                                return 1;
                                        }
@@ -355,13 +341,9 @@ int BinSeqCommand::process(ListVector* list, int count) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BinSeqCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
index cb6abf97b8840aa32bfc4e9bf95315e30e4dbf10..0645fb031f0d2a4e98b4caba5695f30ecd555474 100644 (file)
@@ -102,9 +102,9 @@ void BlastAlignment::setPairwiseSeqs(){     //      This method call assigns the blast ge
                        pairwiseLength = 0;
                        
 //                     string dummy;
-//                     while(dummy != "query:"){       cout << dummy << endl;blastFile >> dummy;       }
+//                     while(dummy != "query:"){       mothurOut(dummy, ""); mothurOutEndLine(); blastFile >> dummy;   }
 //                     blastFile >> seqBend;
-//                     cout << seqBend << endl;
+//                     mothurOut(toString(seqBend), ""); mothurOutEndLine();
 //                     for(int i=0;i<seqBend;i++){
 //                             seqAaln += 'Z';
 //                             seqBaln += 'X';
index e442fa229b49e08d5c7b80495d3c8a10d75d9430..0cba83323db70f0748e4e6a5ec0d902ee8294945 100644 (file)
@@ -19,7 +19,7 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
        
        globaldata = GlobalData::getInstance();
        
-       cout << "Generating the temporary BLAST database...\t"; cout.flush();
+       mothurOut("Generating the temporary BLAST database...\t");      cout.flush();
 
        int randNumber = rand();
        dbFileName = toString(randNumber) + ".template.unaligned.fasta";
@@ -42,7 +42,7 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
        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
-       cout << "DONE." << endl << endl;        cout.flush();
+       mothurOut("DONE."); mothurOutEndLine(); mothurOutEndLine(); cout.flush();
        emptySequence = Sequence();
        emptySequence.setName("no_match");
        emptySequence.setUnaligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
index 32ec033e540dc24dbd8933aac8ac7e96b69f5bef..dc1475a4f2f9d0639d2aa234403bee0b3d3e1021 100644 (file)
--- a/boneh.cpp
+++ b/boneh.cpp
@@ -77,13 +77,9 @@ EstOutput Boneh::getValues(SAbundVector* sabund){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Boneh", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index 2cba2fe08274827a5852116a43dc0994289285f6..649a6028e84fb338ceba0d86bca8d75a138a0be7 100644 (file)
@@ -32,13 +32,9 @@ EstOutput Bootstrap::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Bootstrap class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Bootstrap", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Bootstrap class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 68ef54aaafc0281886e364ac9dad335fb6eacd87..ca21a57c4c34e5c09d8de39e8525e972a16d32f7 100644 (file)
@@ -52,8 +52,8 @@ BootSharedCommand::BootSharedCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the bootstrap.shared command." << endl; abort = true; }
-                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the bootstrap.shared command." << endl; abort = true; }
+                               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; }
                        }
                        
                        //check for optional parameter and set defaults
@@ -73,7 +73,7 @@ BootSharedCommand::BootSharedCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -142,36 +142,28 @@ BootSharedCommand::BootSharedCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function BootSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "BootSharedCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function BootSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void BootSharedCommand::help(){
        try {
-               cout << "The bootstrap.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The bootstrap.shared command parameters are groups, calc, iters, line and label.  You may not use line and label at the same time." << "\n";
-               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes." << "\n";
-               cout << "The bootstrap.shared command should be in the following format: bootstrap.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels, iters=yourIters)." << "\n";
-               cout << "Example bootstrap.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorabund, iters=100)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
-               cout << "The default value for calc is jclass-thetayc. The default for iters is 1000." << "\n";
+               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, line and label.  You may not use line and label at the same time.\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 line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n");
+               mothurOut("The bootstrap.shared command should be in the following format: bootstrap.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels, iters=yourIters).\n");
+               mothurOut("Example bootstrap.shared(groups=A-B-C, line=1-3-5, 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -230,7 +222,7 @@ int BootSharedCommand::execute(){
                
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(order->getLabel()) == 1){                   
                                
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(order);
                                
                                processedLabels.insert(order->getLabel());
@@ -243,7 +235,7 @@ int BootSharedCommand::execute(){
                                
                                delete order;
                                order = input->getSharedOrderVector(lastLabel);                                                                                                 
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(order);
 
                                processedLabels.insert(order->getLabel());
@@ -263,12 +255,12 @@ int BootSharedCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + ".");  mothurOutEndLine();
                        }
                }
                
@@ -276,7 +268,7 @@ int BootSharedCommand::execute(){
                if (needToRun == true)  {
                                delete order;
                                order = input->getSharedOrderVector(lastLabel);                                                                                                 
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(order);
                                delete order;
 
@@ -288,13 +280,9 @@ int BootSharedCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 //**********************************************************************************************************************
 
@@ -365,34 +353,26 @@ void BootSharedCommand::createTree(ostream* out){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "createTree");
                exit(1);
        }
 }
 /***********************************************************/
 void BootSharedCommand::printSims() {
        try {
-               cout << "simsMatrix" << endl;
+               mothurOut("simsMatrix"); mothurOutEndLine(); 
                for (int m = 0; m < simMatrix.size(); m++)      {
                        for (int n = 0; n < simMatrix.size(); n++)      {
-                               cout << simMatrix[m][n] << '\t'
+                               mothurOut(simMatrix[m][n]);  mothurOut("\t")
                        }
-                       cout << endl;
+                       mothurOutEndLine(); 
                }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "printSims");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 void BootSharedCommand::process(SharedOrderVector* order) {
@@ -453,13 +433,9 @@ void BootSharedCommand::process(SharedOrderVector* order) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BootSharedCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BootSharedCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 
index c3ff58fc7a12dbe5c7650acc3a095ee6c4cf3111..566099772e8cecc3d230dbb033aa1bebed1ab885 100644 (file)
@@ -67,8 +67,8 @@ EstOutput BStick::getValues(SAbundVector* rank){
                data[1] = 0.886/sqrt(rdata.size());
                data[2] = 1.031/sqrt(rdata.size());
 
-               /*cout << critVal << "\n";
-               cout << "If D-Statistic is less than the critical value then the data fits the Broken Stick model w/ 95% confidence.\n\n";*/
+               /*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");*/
                
 
                if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
@@ -78,13 +78,9 @@ EstOutput BStick::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BStick class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BStick", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BStick class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index c45ddbffae174303b07e47b94d5183a37339022a..7f7296b7362912843d85448bd625454de709aeae 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "calculator.h"
 
-/***********************************************************************/
+/***********************************************************************
 void VecCalc::printElements(vector<double> vec){
        try {
                for(int i = 0; i < vec.size(); i++)
@@ -26,7 +26,7 @@ void VecCalc::printElements(vector<double> vec){
        }       
 }
 
-/***********************************************************************/
+/***********************************************************************
 
 void VecCalc::printElements(vector<string> vec){
        try {
@@ -43,7 +43,7 @@ void VecCalc::printElements(vector<string> vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 int VecCalc::findString(vector<string> vec, string str){
        try {
                for(int i = 0; i < vec.size(); i++)
@@ -60,11 +60,11 @@ int VecCalc::findString(vector<string> vec, string str){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::mean(vector<double> vec){
        return sumElements(vec)/vec.size();
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::stError(vector<double> vec){
        try {
                double sum = 0;
@@ -88,13 +88,9 @@ int VecCalc::sumElements(vector<int> vec){
                return sumElements(vec,0);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "sumElements");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 int VecCalc::sumElements(vector<int> vec, int index){
@@ -105,13 +101,9 @@ int VecCalc::sumElements(vector<int> vec, int index){
                return sum;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "sumElements");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -123,13 +115,9 @@ double VecCalc::sumElements(vector<double> vec){
                return sum;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "sumElements");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 double VecCalc::sumElements(vector<double> vec, int index){
@@ -140,15 +128,11 @@ double VecCalc::sumElements(vector<double> vec, int index){
                return sum;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "sumElements");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function sumElements. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::findMax(vector<double> vec){
        try {
                double max = -1000000.0;
@@ -176,13 +160,9 @@ int VecCalc::numNZ(vector<int> vec){
                return numNZ;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function numNZ. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "numNZ");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function numNZ. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 double VecCalc::numNZ(vector<double> vec){
@@ -194,15 +174,11 @@ double VecCalc::numNZ(vector<double> vec){
                return numNZ;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VecCalc class Function numNZ. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VecCalc", "numNZ");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VecCalc class function numNZ. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::numPos(vector<double> vec){
        try {
                double numPos = 0;
@@ -220,7 +196,7 @@ double VecCalc::numPos(vector<double> vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::findMaxDiff(vector<double> vec1, vector<double> vec2){
        try {
                double maxDiff = -10000000000.0;
@@ -238,7 +214,7 @@ double VecCalc::findMaxDiff(vector<double> vec1, vector<double> vec2){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double VecCalc::findDStat(vector<double> vec1, vector<double> vec2, double num){
        try {
                double mDiff = findMaxDiff(vec1, vec2);
@@ -253,7 +229,7 @@ double VecCalc::findDStat(vector<double> vec1, vector<double> vec2, double num){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<int> VecCalc::findQuartiles(vector<double> vec){
        try {
                vector<int> quartiles;
@@ -286,7 +262,7 @@ vector<int> VecCalc::findQuartiles(vector<double> vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::add(vector<double> vec, double x){
        try {
                vector<double> newVec;
@@ -303,7 +279,7 @@ vector<double> VecCalc::add(vector<double> vec, double x){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::multiply(vector<double> vec, double x){
        try {
                vector<double> newVec;
@@ -320,7 +296,7 @@ vector<double> VecCalc::multiply(vector<double> vec, double x){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::power(vector<double> vec, double p){
        try {
                vector<double> newVec;
@@ -337,7 +313,7 @@ vector<double> VecCalc::power(vector<double> vec, double p){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::addVecs(vector<double> vec1, vector<double> vec2) //Vectors must be the same size.
 {      try {
                vector<double> newVec;
@@ -354,7 +330,7 @@ vector<double> VecCalc::addVecs(vector<double> vec1, vector<double> vec2) //Vect
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::multVecs(vector<double> vec1, vector<double> vec2) //Vectors must be the same size.
 {      try {
                vector<double> newVec;
@@ -371,7 +347,7 @@ vector<double> VecCalc::multVecs(vector<double> vec1, vector<double> vec2) //Vec
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::remDup(vector<double> vec){
        try {
                vector<double> newVec;
@@ -390,7 +366,7 @@ vector<double> VecCalc::remDup(vector<double> vec){
                exit(1);
        }       
 }      
-/***********************************************************************/      
+/***********************************************************************       
 vector<double> VecCalc::genCVec(vector<double> vec1){
        try {
                vector<double> vec2;
@@ -411,7 +387,7 @@ vector<double> VecCalc::genCVec(vector<double> vec1){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::genRelVec(vector<double> vec){ 
        try {
                vector<double> newVec;
@@ -429,7 +405,7 @@ vector<double> VecCalc::genRelVec(vector<double> vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::genDiffVec(vector<double> vec1, vector<double> vec2){
        try {
                vector<double> newVec;
@@ -446,7 +422,7 @@ vector<double> VecCalc::genDiffVec(vector<double> vec1, vector<double> vec2){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::genCSVec(vector<double> vec){
        try {
                vector<double> newVec;
@@ -478,7 +454,7 @@ vector<double> VecCalc::genCSVec(vector<double> vec){
                exit(1);
        }       
 }
-/***********************************************************************/      
+/***********************************************************************       
 vector<double> VecCalc::genTotVec(vector<vector<double> > vec){
        try {
                vector<double> newVec = vec.at(0);
@@ -495,7 +471,7 @@ vector<double> VecCalc::genTotVec(vector<vector<double> > vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<double> VecCalc::quicksort(vector<double> vec){
        try {
                sort(vec.rbegin(), vec.rend());
@@ -510,7 +486,7 @@ vector<double> VecCalc::quicksort(vector<double> vec){
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<vector<double> > VecCalc::gen2DVec(vector<double> vec, int div, int type){
        try {
                vector<vector<double> > vec2D;
@@ -536,7 +512,7 @@ vector<vector<double> > VecCalc::gen2DVec(vector<double> vec, int div, int type)
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 vector<string> VecCalc::getSData(char name[]){
        try {
                vector<string> vec;
@@ -561,7 +537,7 @@ vector<string> VecCalc::getSData(char name[]){
 }
 /***********************************************************************/      
 
-/***********************************************************************/
+/***********************************************************************
 void BrokenStick::doBStick(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -600,7 +576,7 @@ void BrokenStick::doBStick(vector<double> vec)//vec = The data vector.
        }       
 }
 
-/***********************************************************************/
+/***********************************************************************
 double kEq(double k, double spec)
 {
        return k/(1-k)*pow(1-k, spec)/(1-pow(1-k, spec));
@@ -652,7 +628,7 @@ double kEq(double k, double spec)
        }       
 }*/
 
-/***********************************************************************/
+/***********************************************************************
 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;
@@ -703,7 +679,7 @@ void Jackknifing::doJK(vector<double> vec, double cols)//vec = the data vector i
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 void KS2SampleTest::doKSTest(vector<double> abun1, vector<double> abun2)//abun1 = 1st vector of abundances, abun2 = 2nd vector of abundances
 {      try {
                VecCalc vecCalc;
@@ -745,7 +721,7 @@ void KS2SampleTest::doKSTest(vector<double> abun1, vector<double> abun2)//abun1
        }       
 }
 
-/***********************************************************************/
+/***********************************************************************
 
 void QStatistic::doQStat(vector<double> vec)//vec = The data vector.
 {      try {
@@ -772,7 +748,7 @@ void QStatistic::doQStat(vector<double> vec)//vec = The data vector.
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double SSBPDiversityIndices::getShan(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -793,7 +769,7 @@ double SSBPDiversityIndices::getShan(vector<double> vec)//vec = The data vector.
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double SSBPDiversityIndices::getSimp(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -812,7 +788,7 @@ double SSBPDiversityIndices::getSimp(vector<double> vec)//vec = The data vector.
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 double SSBPDiversityIndices::getBP(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -828,7 +804,7 @@ double SSBPDiversityIndices::getBP(vector<double> vec)//vec = The data vector.
                exit(1);
        }       
 }
-/***********************************************************************/
+/***********************************************************************
 void SSBPDiversityIndices::doSSBP(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -897,16 +873,12 @@ double TDTable::getConfLimit(int row, int col) //Rows are the degrees of freedom
                return values[row][col];
        }
        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";
+               errorOut(e, "TDTable", "getConfLimit");
                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);
-       }       
 }
 
-/***********************************************************************/
+/***********************************************************************
 double KOSTable::getConfLimit(int index) //Table of Critical values for N = 4-20 for One-Sample Kolmogorov-Smirnov Test
 {    try {                       
                //Confidence Level = .05
index 5dc081296748412a8e61e883d11ac60d70cfd864..ffc92b929f75fe7164301f94f969e384ad9d907a 100644 (file)
@@ -41,43 +41,43 @@ protected:
 /**************************************************************************************************/
 /*This Class holds all of the methods that manipulate vectors.
 These methods are used in the other classes.
-This class must be included if any of the other classes are to be used.*/
+This class must be included if any of the other classes are to be used. */
 
 class VecCalc
 {
        // The methods seen in the order here is how they are ordered throughout the class.
        public:
                VecCalc(){};
-               void printElements(vector<double>); //This prints the values of the vector on one line with a space between each value.
-               void printElements(vector<string>); //This prints the values of the vector on one line with a space between each value.
-               int findString(vector<string>, string);//This returns the index of the given string in the given <string> vector, if the string does not exist in the vector it returns -1.
-               double mean(vector<double>); //This returns the mean value of the vector.
-               double stError(vector<double>); //This returns the standard error of the vector.
+               //void printElements(vector<double>); //This prints the values of the vector on one line with a space between each value.
+               //void printElements(vector<string>); //This prints the values of the vector on one line with a space between each value.
+               //int findString(vector<string>, string);//This returns the index of the given string in the given <string> vector, if the string does not exist in the vector it returns -1.
+               //double mean(vector<double>); //This returns the mean value of the vector.
+               //double stError(vector<double>); //This returns the standard error of the vector.
                int sumElements(vector<int>, int);
                int sumElements(vector<int>);
                double sumElements(vector<double>); //This returns the sum of all the values in the vector.
                double sumElements(vector<double>, int); //This returns the sum of all the values in the vector excluding those whose index is before the given index.  
-               double findMax(vector<double>); //This returns the maximum value in the vector.
+               //double findMax(vector<double>); //This returns the maximum value in the vector.
                int numNZ(vector<int>); //This returns the number of non-zero values in the vector.
                double numNZ(vector<double>); //This returns the number of non-zero values in the vector.
-               double numPos(vector<double>); //This returns the number of positive values in the vector.
-               double findMaxDiff(vector<double>, vector<double>); //This returns the absolute value of the maximum difference between the two vectors.
-               double findDStat(vector<double>, vector<double>, double); //This returns the D-Statistic of the two vectors with the given total number of species.
-               vector<int> findQuartiles(vector<double>); //This returns a vector with the first element being the index of the lower quartile of the vector and the second element being the index of the upper quartile of the vector.
-               vector<double> add(vector<double>, double); //This adds the given number to every element in the given vector and returns the new vector.
-               vector<double> multiply(vector<double>, double); //This multiplies every element in the given vector by the given number and returns the new vector.
-               vector<double> power(vector<double>, double); //This raises every element in the given vector to the given number and returns the new vector.
-               vector<double> addVecs(vector<double>,vector<double>); //The given vectors must be the same size. This adds the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
-               vector<double> multVecs(vector<double>,vector<double>); //The given vectors must be the same size. This multiplies the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
-               vector<double> remDup(vector<double>); //This returns a vector that contains 1 of each unique element in the given vector. The order of the elements is not changed.
-               vector<double> genCVec(vector<double>); //This returns a cumilative vector of the given vector. The ith element of the returned vector is the sum of all the elements in the given vector up to i.
-               vector<double> genRelVec(vector<double>); //This finds the sum of all the elements in the given vector and then divides the ith element in the given vector by that sum and then puts the result into a new vector, which is returned after all of the elements in the given vector have been used.
-               vector<double> genDiffVec(vector<double>, vector<double>);//This subtracts the ith element of the second given vector from the ith element of the first given vector and returns the new vector.
-               vector<double> genCSVec(vector<double>);//This calculates the number of species that have the same number of individuals as the ith element of the given vector and then returns a cumulative vector.
-               vector<double> genTotVec(vector<vector<double> >); //This adds up the ith element of all the columns and puts that value into a new vector. It those this for all the rows and then returns the new vector.
-               vector<double> quicksort(vector<double>); //This sorts the given vector from highest to lowest and returns the sorted vector.
-               vector<vector<double> > gen2DVec(vector<double>, int, int); //(vector, #rows/columns, 0 if the second parameter was rows, 1 if the second parameter was columns) Transforms a single vector that was formatted like a table into a 2D vector.
-               vector<string> getSData(char[]);//This takes a file name as a parameter and reads all of the data in the file into a <string> vector.
+               //double numPos(vector<double>); //This returns the number of positive values in the vector.
+               //double findMaxDiff(vector<double>, vector<double>); //This returns the absolute value of the maximum difference between the two vectors.
+               //double findDStat(vector<double>, vector<double>, double); //This returns the D-Statistic of the two vectors with the given total number of species.
+               //vector<int> findQuartiles(vector<double>); //This returns a vector with the first element being the index of the lower quartile of the vector and the second element being the index of the upper quartile of the vector.
+               //vector<double> add(vector<double>, double); //This adds the given number to every element in the given vector and returns the new vector.
+               //vector<double> multiply(vector<double>, double); //This multiplies every element in the given vector by the given number and returns the new vector.
+               //vector<double> power(vector<double>, double); //This raises every element in the given vector to the given number and returns the new vector.
+               //vector<double> addVecs(vector<double>,vector<double>); //The given vectors must be the same size. This adds the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
+               //vector<double> multVecs(vector<double>,vector<double>); //The given vectors must be the same size. This multiplies the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
+               //vector<double> remDup(vector<double>); //This returns a vector that contains 1 of each unique element in the given vector. The order of the elements is not changed.
+               //vector<double> genCVec(vector<double>); //This returns a cumilative vector of the given vector. The ith element of the returned vector is the sum of all the elements in the given vector up to i.
+               //vector<double> genRelVec(vector<double>); //This finds the sum of all the elements in the given vector and then divides the ith element in the given vector by that sum and then puts the result into a new vector, which is returned after all of the elements in the given vector have been used.
+               ///vector<double> genDiffVec(vector<double>, vector<double>);//This subtracts the ith element of the second given vector from the ith element of the first given vector and returns the new vector.
+               //vector<double> genCSVec(vector<double>);//This calculates the number of species that have the same number of individuals as the ith element of the given vector and then returns a cumulative vector.
+               //vector<double> genTotVec(vector<vector<double> >); //This adds up the ith element of all the columns and puts that value into a new vector. It those this for all the rows and then returns the new vector.
+               //vector<double> quicksort(vector<double>); //This sorts the given vector from highest to lowest and returns the sorted vector.
+               //vector<vector<double> > gen2DVec(vector<double>, int, int); //(vector, #rows/columns, 0 if the second parameter was rows, 1 if the second parameter was columns) Transforms a single vector that was formatted like a table into a 2D vector.
+               //vector<string> getSData(char[]);//This takes a file name as a parameter and reads all of the data in the file into a <string> vector.
 };
 
 /**************************************************************************************************/
@@ -85,7 +85,7 @@ class VecCalc
 /*This Class is similar to the GeometricSeries.h class. It calculates
 the broken stick distribution of the table and prints the D-Statistic 
 and the confidence limits for the Kolmogorov-Smirnov 1-Sample test
-with a 95% confidence level.*/
+with a 95% confidence level.
 
 class BrokenStick
 {
@@ -104,7 +104,7 @@ It prints the D-Statistic and the critical values for the Kolmogorov-Smirnov
                void doGeomTest(vector<double>);
 };*/
 
-/**************************************************************************************************/
+/**************************************************************************************************
 //This Class calculates the jackknifed estimate of the data and
 //prints it and the confidence limits at a chosen confidence level.
 
@@ -113,10 +113,10 @@ class Jackknifing
        public:
                void doJK(vector<double>, double);
 };
-/**************************************************************************************************/
+/**************************************************************************************************
 /*This Class stores calculates the Kolmogorov-Smirnov 2-Sample test between two samples.
 It prints the D-Statistic and the critical value for the test at 
-the 90% and 95% confidence interval.*/
+the 90% and 95% confidence interval.
 
 class KS2SampleTest
 {
@@ -124,14 +124,14 @@ class KS2SampleTest
                void doKSTest(vector<double>, vector<double>);
 };
 
-/**************************************************************************************************/
+/**************************************************************************************************
 //This Class calculates and prints the Q-Statistic for the data.
 class QStatistic
 {
        public:
                void doQStat(vector<double>);
 };
-/**************************************************************************************************/
+/**************************************************************************************************
 class SSBPDiversityIndices
 {
        public:
@@ -148,7 +148,7 @@ class TDTable
                double getConfLimit(int,int);
 };
 
-/**************************************************************************************************/
+/**************************************************************************************************
 //This Class stores the table of the confidence limits of the One-Sample Kolmogorov-Smirnov Test.
 class KOSTable
 {
index 7757fb0c776bd2e87916b025e8478a62d96d2257..b601b51f727490aeb3804f23b2aaa20ef1fad135 100644 (file)
--- a/chao1.cpp
+++ b/chao1.cpp
@@ -60,13 +60,9 @@ EstOutput Chao1::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Chao1 class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Chao1", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Chao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 1ccb34943d32b907b656fd6fc6272a11501f549f..b9754bee094c28f7921506371fedf764c76fefd7 100644 (file)
@@ -56,59 +56,41 @@ void Cluster::getRowColCells(){
                nColCells = colCells.size();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Cluster", "getRowColCells");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Cluster class function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
 
 void Cluster::clusterBins(){
        try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol);
-
+       
                rabund->set(smallCol, rabund->get(smallRow)+rabund->get(smallCol));     
                rabund->set(smallRow, 0);       
                rabund->setLabel(toString(smallDist));
 
-       //      cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Cluster", "clusterBins");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Cluster class function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
-
 }
 
 /***********************************************************************/
 
 void Cluster::clusterNames(){
        try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(smallRow) << '\t' << list->get(smallCol);
-
+       
                list->set(smallCol, list->get(smallRow)+','+list->get(smallCol));
                list->set(smallRow, "");        
                list->setLabel(toString(smallDist));
        
-       //      cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
     }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Cluster", "clusterNames");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Cluster class function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index eeba407eefc7bfb39a6bc60428a796f7bfb47068..593f2629ff9f1107ddaf6bd10c568047118c1070 100644 (file)
@@ -36,7 +36,7 @@ ClusterCommand::ClusterCommand(string option){
                        
                        //error checking to make sure they read a distance file
                        if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
-                               cout << "Before you use the cluster command, you first need to read in a distance matrix." << endl;  abort = true;
+                               mothurOut("Before you use the cluster command, you first need to read in a distance matrix."); mothurOutEndLine(); abort = true;
                        } 
                
                        //check for optional parameter and set defaults
@@ -56,7 +56,7 @@ ClusterCommand::ClusterCommand(string option){
 
                        
                        if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
-                       else {cout << "Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average." << endl; abort = true; }
+                       else { mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); mothurOutEndLine(); abort = true; }
 
                        
                        if (abort == false) {
@@ -73,7 +73,7 @@ ClusterCommand::ClusterCommand(string option){
                                if(method == "furthest")        {       cluster = new CompleteLinkage(rabund, list, matrix);    tag = "fn";     }
                                else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix);              tag = "nn";     }
                                else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix);             tag = "an";     }
-                               else                                            {       cout << "error - not recognized method" << endl;        abort = true;   }       
+                               else                                            {       mothurOut("error - not recognized method"); mothurOutEndLine(); abort = true;   }       
                                
                                fileroot = getRootName(globaldata->inputFileName);
                        
@@ -88,11 +88,7 @@ ClusterCommand::ClusterCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ClusterCommand class Function ClusterCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ClusterCommand class function ClusterCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ClusterCommand", "ClusterCommand");                
                exit(1);
        }
 }
@@ -101,20 +97,16 @@ ClusterCommand::ClusterCommand(string option){
 
 void ClusterCommand::help(){
        try {
-               cout << "The cluster command can only be executed after a successful read.dist command." << "\n";
-               cout << "The cluster command parameter options are method, cuttoff and precision. No parameters are required." << "\n";
-               cout << "The cluster command should be in the following format: " << "\n";
-               cout << "cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) " << "\n";
-               cout << "The acceptable cluster methods are furthest, nearest and average.  If no method is provided then furthest is assumed." << "\n" << "\n";        
+                mothurOut("The cluster command can only be executed after a successful read.dist command.\n");
+                mothurOut("The cluster command parameter options are method, cuttoff and precision. 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ClusterCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ClusterCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ClusterCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -186,14 +178,9 @@ int ClusterCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ClusterCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ClusterCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ClusterCommand", "execute");
                exit(1);
        }
-
 }
 
 //**********************************************************************************************************************
@@ -209,13 +196,8 @@ void ClusterCommand::printData(string label){
                oldList.print(listFile);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ClusterCommand class Function printData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ClusterCommand class function printData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ClusterCommand", "printData");
                exit(1);
        }
-
 }
 //**********************************************************************************************************************
index ac4aa4dc431a6fff7709546ccca9e0a34736fda3..2d1f6e38573d10288f4192c1208f19c919673821 100644 (file)
@@ -52,14 +52,9 @@ void Collect::getCurve(int increment = 1){
                                delete ccd;
         }
         catch(exception& e) {
-                cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-                exit(1);
+                       errorOut(e, "Collect", "getCurve");
+                       exit(1);
         }
-        catch(...) {
-                cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-                exit(1);
-        }
-
 }
 
 /***********************************************************************/
@@ -164,14 +159,9 @@ try {
 
         }
         catch(exception& e) {
-                cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-                exit(1);
+                errorOut(e, "Collect", "getSharedCurve");
+                               exit(1);
         }
-        catch(...) {
-                cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-                exit(1);
-        }
-
 }
 
 /**************************************************************************************/
index dbb2edebb57d76152b570902b4f3b4151bc39d71..c3a58d6768d834487364b0844e2892219fe05873 100644 (file)
@@ -59,7 +59,7 @@ CollectCommand::CollectCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single command." << endl; abort = true; }
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the collect.single command."); mothurOutEndLine(); abort = true; }
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -78,7 +78,7 @@ CollectCommand::CollectCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -158,38 +158,29 @@ CollectCommand::CollectCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectCommand", "CollectCommand");
                exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectCommand class function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
+       }                       
 }
 //**********************************************************************************************************************
 
 void CollectCommand::help(){
        try {
-               cout << "The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. " << "\n";
-               cout << "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";
-               cout << "The collect.single command parameters are label, line, freq, calc and abund.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The collect.single command should be in the following format: " << "\n";
-               cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
-               cout << "Example collect(label=unique-.01-.03, line=0-5-10, iters=10000, freq=10, calc=sobs-chao-ace-jack)." << "\n";
-               cout << "The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson." << "\n";
+               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, line, freq, calc and abund.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The collect.single command should be in the following format: \n");
+               mothurOut("collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
+               mothurOut("Example collect(label=unique-.01-.03, line=0-5-10, 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");
                validCalculator->printCalc("single", cout);
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
+               mothurOut("The label and line parameters are used to analyze specific lines in your input.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -236,7 +227,7 @@ int CollectCommand::execute(){
                                cCurve->getCurve(freq);
                                delete cCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                                userLines.erase(count);
@@ -253,7 +244,7 @@ int CollectCommand::execute(){
                                cCurve->getCurve(freq);
                                delete cCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                        }
@@ -269,12 +260,12 @@ int CollectCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -283,7 +274,7 @@ int CollectCommand::execute(){
                        delete order;
                        order = (input->getOrderVector(lastLabel));
                        
-                       cout << order->getLabel() << '\t' << count << endl;
+                       mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        
                        cCurve = new Collect(order, cDisplays);
                        cCurve->getCurve(freq);
@@ -296,13 +287,9 @@ int CollectCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index adb2aeab0fb827baa6b411c041630ebe0fe4d292..3fed1674f25c0d808060542a83803ce44167b255 100644 (file)
@@ -66,8 +66,8 @@ CollectSharedCommand::CollectSharedCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared command." << endl; abort = true; }
-                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared command." << endl; abort = true; }
+                               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; }
                        }
 
                        
@@ -88,7 +88,7 @@ CollectSharedCommand::CollectSharedCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -175,40 +175,31 @@ CollectSharedCommand::CollectSharedCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function CollectSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectSharedCommand class function CollectSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void CollectSharedCommand::help(){
        try {
-               cout << "The collect.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The collect.shared command parameters are label, line, freq, calc and groups.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The collect.shared command should be in the following format: " << "\n";
-               cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, calc=yourEstimators, groups=yourGroups)." << "\n";
-               cout << "Example collect.shared(label=unique-.01-.03, line=0-5-10, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
-               cout << "The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
+               mothurOut("The collect.shared command can only be executed after a successful read.otu command.\n");
+               mothurOut("The collect.shared command parameters are label, line, freq, calc and groups.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The collect.shared command should be in the following format: \n");
+               mothurOut("collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, calc=yourEstimators, groups=yourGroups).\n");
+               mothurOut("Example collect.shared(label=unique-.01-.03, line=0-5-10, 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");
                validCalculator->printCalc("shared", cout);
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "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";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               mothurOut("The label and line parameters are used to analyze specific lines 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. list), '=' and parameters (i.e.yourListfile).\n\n");
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectSharedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectSharedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -260,7 +251,7 @@ int CollectSharedCommand::execute(){
                                cCurve->getSharedCurve(freq);
                                delete cCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                                userLines.erase(count);
@@ -277,7 +268,7 @@ int CollectSharedCommand::execute(){
                                cCurve->getSharedCurve(freq);
                                delete cCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                        }
@@ -295,12 +286,12 @@ int CollectSharedCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -313,7 +304,7 @@ int CollectSharedCommand::execute(){
                        cCurve->getCurve(freq);
                        delete cCurve;
                        
-                       cout << order->getLabel() << '\t' << count << endl;
+                       mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        delete order;
                }
                
@@ -325,13 +316,9 @@ int CollectSharedCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CollectSharedCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CollectSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************/
index 7dd35fd673a7bc62e109a0095efe847d5b097588..db11f8c0dc890dff846787dee0fc48ea8930384a 100644 (file)
@@ -159,14 +159,9 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                return command;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CommandFactory", "getCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CommandFactory class function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /***********************************************************************/
@@ -177,21 +172,17 @@ bool CommandFactory::isValidCommand(string command) {
                if ((commands.find(command)) != (commands.end())) {
                        return true;
                }else{
-                       cout << command << " is not a valid command in Mothur.  Valid commands are ";
+                       mothurOut(command + " is not a valid command in Mothur.  Valid commands are ");
                        for (it = commands.begin(); it != commands.end(); it++) {
-                               cout << it->first << ", ";
+                               mothurOut(it->first + ", ");
                        }
-                       cout << endl;
+                       mothurOutEndLine();
                        return false;
                }
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the CommandFactory class function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CommandFactory", "isValidCommand");
                exit(1);
        }
 }
@@ -206,11 +197,7 @@ void CommandFactory::printCommands(ostream& out) {
                out << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the CommandFactory class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CommandFactory", "printCommands");
                exit(1);
        }
 }
index e4db11d1993f3ee257b36b010fb22944abc3b1cd..f013a25361366bfecbecdccf0dd1d00c7805d16e 100644 (file)
@@ -25,21 +25,16 @@ CommandOptionParser::CommandOptionParser(string input){
                        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) { cout << "You are missing (" << endl; }
-               else if (closeParen == -1) { cout << "You are missing )" << endl; }
+               else if (openParen == -1) { mothurOut("You are missing ("); mothurOutEndLine(); }
+               else if (closeParen == -1) { mothurOut("You are missing )"); mothurOutEndLine(); }
                                        
                //GlobalData* globaldata = GlobalData::getInstance();
                //globaldata->parseGlobalData(commandString, optionString);                     //parser to separate and check options
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CommandOptionParser class Function CommandOptionParser. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CommandOptionParser", "CommandOptionParser");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CommandOptionParser class function CommandOptionParser. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 //**********************************************************************************************************************
index 3c779b9344866cc4729e460cb3d7b6e6c68dc682..f69753b34a3ecdfb74fbd9e5fe068954c1cd493f 100644 (file)
@@ -58,14 +58,9 @@ void CompleteLinkage::update(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CompleteLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "CompleteLinkage", "update");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CompleteLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /***********************************************************************/
index 09e0f324268332e0f691d42b00f003aab9f9c9c9..30da32cfe05db5de942cebd213cf9cc9631cb717 100644 (file)
@@ -20,44 +20,36 @@ ConcensusCommand::ConcensusCommand(string option){
                if(option == "help") { help(); abort = true; }
                
                else {
-                       if (option != "") { cout << "There are no valid parameters for the concensus command." << endl; abort = true; }
+                       if (option != "") { mothurOut("There are no valid parameters for the concensus command."); mothurOutEndLine(); abort = true; }
                        
                        //no trees were read
-                       if (globaldata->gTree.size() == 0) {    cout << "You must execute the read.tree command, before you may use the concensus command." << endl; abort = true;  }
+                       if (globaldata->gTree.size() == 0) {  mothurOut("You must execute the read.tree command, before you may use the concensus command."); mothurOutEndLine(); abort = true;  }
                        else {  t = globaldata->gTree;  }
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function ConcensusCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "ConcensusCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function ConcensusCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void ConcensusCommand::help(){
        try {
-               cout << "The concensus command can only be executed after a successful read.tree command." << "\n";
-               cout << "The concensus command has no parameters." << "\n";
-               cout << "The concensus command should be in the following format: concensus()." << "\n";
-               cout << "The concensus command output two files: .concensus.tre and .concensuspairs." << "\n";
-               cout << "The .concensus.tre file contains the concensus tree of the trees in your input file." << "\n";
-               cout << "The branch lengths are the percentage of trees in your input file that had the given pair." << "\n";
-               cout << "The .concensuspairs file contains a list of the internal nodes in your tree.  For each node, the pair that was used in the concensus tree " << "\n";
-               cout << "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";         
+               mothurOut("The concensus command can only be executed after a successful read.tree command.\n");
+               mothurOut("The concensus command has no parameters.\n");
+               mothurOut("The concensus command should be in the following format: concensus().\n");
+               mothurOut("The concensus command output two files: .concensus.tre and .concensuspairs.\n");
+               mothurOut("The .concensus.tre file contains the concensus 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 .concensuspairs file contains a list of the internal nodes in your tree.  For each node, the pair that was used in the concensus 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");          
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -78,16 +70,6 @@ int ConcensusCommand::execute(){
                //get the possible pairings
                getSets();              
                
-               //print out pairings for testing
-               /*cout << "possible pairing " <<  endl;
-               for (it2 = nodePairs.begin(); it2 != nodePairs.end(); it2++) {
-                       for (int i = 0; i < it2->first.size(); i++) {
-                               cout << it2->first[i] << " ";
-                       }
-                       cout << '\t' << it2->second << endl;
-               }*/
-               
-               
                //open file for pairing not included in the tree
                notIncluded = getRootName(globaldata->inputFileName) + "concensuspairs";
                openOutputFile(notIncluded, out2);
@@ -170,13 +152,9 @@ int ConcensusCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
@@ -206,13 +184,9 @@ int ConcensusCommand::buildConcensusTree(vector<string> nodeSet) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function buildConcensusTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "buildConcensusTree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function buildConcensusTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
@@ -263,13 +237,9 @@ void ConcensusCommand::getSets() {
                sort(treeSet.begin(), treeSet.end());
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getSets. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "getSets");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function getSets. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
@@ -302,14 +272,9 @@ vector<string> ConcensusCommand::getNextAvailableSet(vector<string> bigset) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getNextAvailableSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "getNextAvailableSet");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function getNextAvailableSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
-
 }
 
 //**********************************************************************************************************************
@@ -337,14 +302,9 @@ vector<string> ConcensusCommand::getRestSet(vector<string> bigset, vector<string
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getRestSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "getRestSet");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function getRestSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
-
 }
 
 //**********************************************************************************************************************
@@ -366,13 +326,9 @@ bool ConcensusCommand::isSubset(vector<string> bigset, vector<string> subset) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function isSubset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "isSubset");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function isSubset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 //**********************************************************************************************************************
 int ConcensusCommand::findSpot(string node) {
@@ -388,13 +344,9 @@ int ConcensusCommand::findSpot(string node) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function findSpot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ConcensusCommand", "findSpot");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ConcensusCommand class function findSpot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 //**********************************************************************************************************************
 
index 441a029c264c913e420c4c81ac7d9d3191332709..16d2644242c5b360bd3fbc1e9a0719311f99f6fd 100644 (file)
@@ -20,13 +20,9 @@ EstOutput Coverage::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Coverage", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index 852e2d294a3887c747fa8a95bb56f36151d2890e..5fc9b676f128dd0a1d6999918b4fcb42357c407e 100644 (file)
@@ -18,8 +18,9 @@ Database::Database(string fastaFileName){             //      This assumes that the template dat
 
        ifstream fastaFile;
        openInputFile(fastaFileName, fastaFile);
-
-       cout << endl << "Reading in the " << fastaFileName << " template sequences...\t";       cout.flush();
+       
+       mothurOutEndLine();
+       mothurOut("Reading in the " + fastaFileName + " template sequences...\t");      cout.flush();
 
        //all of this is elsewhere already!
        numSeqs=count(istreambuf_iterator<char>(fastaFile),istreambuf_iterator<char>(), '>');   //      count the number of
@@ -48,26 +49,15 @@ Database::Database(string fastaFileName){           //      This assumes that the template dat
        fastaFile.close();
        //all of this is elsewhere already!
        
-       cout << "DONE." << endl;        cout.flush();
+       mothurOut("DONE.");
+       mothurOutEndLine();     cout.flush();
 
 }
 /**************************************************************************************************/
 
 Database::~Database(){                                                                                                         
-       try {
-               
-               //for (int i = 0; i < templateSequences.size(); i++) {  delete templateSequences[i];    }
-               templateSequences.clear();
 
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Database class Function ~Database. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Database class function ~Database. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
+               templateSequences.clear();
 }
 
 /**************************************************************************************************/
index fba2d27ebf470c968f50f64c71c54917f0e8f5df..a936c820b56f88609e621894565359892384224a 100644 (file)
@@ -35,7 +35,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) {
                        //check for required parameters
                        inFastaName = validParameter.validFile(parameters, "fasta", true);
                        if (inFastaName == "not open") { abort = true; }
-                       else if (inFastaName == "not found") { inFastaName = ""; cout << "fasta is a required parameter for the unique.seqs command." << endl; abort = true;  } 
+                       else if (inFastaName == "not found") { inFastaName = ""; mothurOut("fasta is a required parameter for the unique.seqs command."); mothurOutEndLine(); abort = true;  }  
                        
                        oldNameMapFName = validParameter.validFile(parameters, "name", true);
                        if (oldNameMapFName == "not open") { abort = true; }
@@ -44,11 +44,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DeconvoluteCommand class Function DeconvoluteCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the DeconvoluteCommand class function DeconvoluteCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
                exit(1);
        }
 }
@@ -56,21 +52,17 @@ DeconvoluteCommand::DeconvoluteCommand(string option) {
 
 void DeconvoluteCommand::help(){
        try {
-               cout << "The unique.seqs command reads a fastafile and creates a namesfile." << "\n";
-               cout << "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";
-               cout << "If the sequence is unique the second column will just contain its name. " << "\n";
-               cout << "The unique.seqs command parameter is fasta and it is required." << "\n";
-               cout << "The unique.seqs command should be in the following format: " << "\n";
-               cout << "unique.seqs(fasta=yourFastaFile) " << "\n";    
+               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");       
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DeconvoluteCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DeconvoluteCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DeconvoluteCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************/
@@ -94,11 +86,7 @@ int DeconvoluteCommand::execute() {
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DeconvoluteCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the DeconvoluteCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DeconvoluteCommand", "execute");
                exit(1);
        }
 }
index 67ad7beb77b69d72f11914579246eb35dfa707e4..f8a2a75220bef99557a896e34d8d8f5aa843687a 100644 (file)
@@ -41,7 +41,7 @@ DistanceCommand::DistanceCommand(string option){
                        
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { cout << "fasta is a required parameter for the dist.seqs command." << endl; abort = true; }
+                       if (fastafile == "not found") { mothurOut("fasta is a required parameter for the dist.seqs command."); mothurOutEndLine(); abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
                        else{
                                ifstream inFASTA;
@@ -96,13 +96,9 @@ DistanceCommand::DistanceCommand(string option){
                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function DistanceCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "DistanceCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function DistanceCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -119,29 +115,23 @@ DistanceCommand::~DistanceCommand(){
 
 void DistanceCommand::help(){
        try {
-               cout << "The dist.seqs command reads a file containing sequences and creates a distance file." << "\n";
-               cout << "The dist.seqs command parameters are fasta, calc, countends, cutoff and processors.  " << "\n";
-               cout << "The fasta parameter is required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0." << "\n";
-               cout << "The processors parameter allows you to specify number of processors to use.  The default is 1." << "\n";
-               cout << "The dist.seqs command should be in the following format: " << "\n";
-               cout << "dist.seqs(fasta=yourFastaFile, calc=yourCalc, countends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) " << "\n";
-               cout << "Example dist.seqs(fasta=amazon.fasta, calc=eachgap, countends=F, cutoff= 2.0, processors=3)." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc)." << "\n" << "\n";
+               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, 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 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
-
-
 //**********************************************************************************************************************
 
 int DistanceCommand::execute(){
@@ -206,13 +196,9 @@ int DistanceCommand::execute(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /**************************************************************************************************/
 void DistanceCommand::createProcesses(string filename) {
@@ -231,7 +217,7 @@ void DistanceCommand::createProcesses(string filename) {
                        }else if (pid == 0){
                                driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", cutoff);
                                exit(0);
-                       }else { cout << "unable to spawn the necessary processes." << endl; exit(0); }
+                       }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
                }
        
                //force parent to wait until all the processes are done
@@ -242,13 +228,9 @@ void DistanceCommand::createProcesses(string filename) {
 #endif
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function createProcesses. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "createProcesses");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function createProcesses. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************************/
@@ -280,25 +262,20 @@ int DistanceCommand::driver(int startLine, int endLine, string dFileName, float
                        if (isTrue(phylip) == true) { outFile << endl; }
                        
                        if(i % 100 == 0){
-                               cout << i << '\t' << time(NULL) - startTime << endl;
+                               mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); mothurOutEndLine();
                        }
                        
                }
-               cout << endLine-1 << '\t' << time(NULL) - startTime << endl;
+               mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); mothurOutEndLine();
                
                outFile.close();
                
                return 1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "driver");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /**************************************************************************************************/
@@ -320,12 +297,8 @@ void DistanceCommand::appendFiles(string temp, string filename) {
                output.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "DistanceCommand", "appendFiles");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the DistanceCommand class function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /**************************************************************************************************/
index 25c95c7a32a2523080bac92b41722ed1f1b91e6d..90b7724ed709ac27f510cad9c928a8b48fca9675 100644 (file)
@@ -33,7 +33,7 @@ DistanceDB::DistanceDB(string fastaFileName, string distanceFileName) : Database
 //             getline(inputData, junk);       
                mostSimSequenceVector[i] = closestMatch;
        }
-       cout << numCandSeqs << endl;
+       mothurOut(toString(numCandSeqs)); mothurOutEndLine();
        searchIndex = 0;
        inputData.close();
 }
index 62d924bb7a4641bc85de3802b6ca1f45d8b06a8f..9ddcdfa6307a4a40e27cb2281fe2fc70389371fd 100644 (file)
--- a/efron.cpp
+++ b/efron.cpp
@@ -8,7 +8,6 @@
  */
 
 #include "efron.h"
-#include <math.h>
 
 /***********************************************************************/
 EstOutput Efron::getValues(SAbundVector* rank){
@@ -28,13 +27,9 @@ EstOutput Efron::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Efron", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index 38429b972d1d04a6543330ae1d67c6f63bcc094c..f0fd05ab2f46d5f6ebbd680de70639d8599da5d5 100644 (file)
@@ -20,14 +20,10 @@ InteractEngine::InteractEngine(string path){
 
        globaldata = GlobalData::getInstance();
        globaldata->argv = path;
+       string logFileName = "mothur.logFile";
+       remove(logFileName.c_str());
        
        system("clear");
-//     char buffer = ' ';
-//     ifstream header("introtext.txt");
-//     while(!header.eof()){
-//             cout << buffer;
-//             buffer = header.get();
-//     }
 }
 
 /***********************************************************************/
@@ -44,32 +40,47 @@ bool InteractEngine::getInput(){
                string commandName = "";
                string options = "";
                int quitCommandCalled = 0;
-               //bool errorFree;
-               //ErrorCheck* errorCheckor = new ErrorCheck();
                
-               cout << "mothur v.1.4.1" << endl;
-               cout << "Last updated: 6/23/2009" << endl << endl;
-               cout << "by" << endl;
-               cout << "Patrick D. Schloss" << endl << endl;
-               cout << "Department of Microbiology" << endl;
-               cout << "The University of Massachusetts" << endl;
-               cout << "pschloss@micro.umass.edu" << endl;
-               cout << "http://schloss.micro.umass.edu/mothur" << endl << endl << endl;
-               cout << "Distributed under the GNU General Public License" << endl << endl;
-               cout << "Type 'help()' for information on the commands that are available" << endl << endl;
-               cout << "Type 'quit()' to exit program" << endl;
-
+               mothurOut("mothur v.1.4.1");
+               mothurOutEndLine();             
+               mothurOut("Last updated: 6/23/2009");
+               mothurOutEndLine();     
+               mothurOutEndLine();             
+               mothurOut("by");
+               mothurOutEndLine();             
+               mothurOut("Patrick D. Schloss");
+               mothurOutEndLine();
+               mothurOutEndLine();                     
+               mothurOut("Department of Microbiology");
+               mothurOutEndLine();             
+               mothurOut("pschloss@micro.umass.edu");
+               mothurOutEndLine();             
+               mothurOut("http://schloss.micro.umass.edu/mothur");
+               mothurOutEndLine();     
+               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();     
+               
                while(quitCommandCalled != 1){
-
-                       cout << endl << "mothur > ";
+                       
+                       mothurOutEndLine();
+                       mothurOut("mothur > ");
                        getline(cin, input);
                        if (cin.eof()) { input = "quit()"; }
                        
+                       mothurOutJustToLog(input);
+                       mothurOutEndLine();
+                       
                        //allow user to omit the () on the quit command
                        if (input == "quit") { input = "quit()"; }
                        
-                       //errorFree = errorCheckor->checkInput(input);
-                       //if (errorFree == true) {
                        CommandOptionParser parser(input);
                        commandName = parser.getCommandString();
                        options = parser.getOptionString();
@@ -82,20 +93,16 @@ bool InteractEngine::getInput(){
                                quitCommandCalled = command->execute();
                                
                        }else {
-                               cout << "Your input contains errors. Please try again." << endl;
+                               mothurOut("Your input contains errors. Please try again."); 
+                               mothurOutEndLine();
                        }
                }       
                return 1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InteractEngine class Function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the InteractEngine class function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InteractEngine", "getInput");
                exit(1);
        }
-
 }
 
 /***********************************************************************/
@@ -106,7 +113,9 @@ BatchEngine::BatchEngine(string path, string batchFileName){
        
                openedBatch = openInputFile(batchFileName, inputBatchFile);
                globaldata->argv = path;
-
+               string logFileName = "mothur.logFile";
+               remove(logFileName.c_str());
+               
                system("clear");
        
        //      char buffer = ' ';
@@ -117,11 +126,7 @@ BatchEngine::BatchEngine(string path, string batchFileName){
        //      }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BatchEngine class Function BatchEngine. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the BatchEngine class function BatchEngine. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BatchEngine", "BatchEngine");
                exit(1);
        }
 }
@@ -136,12 +141,15 @@ BatchEngine::~BatchEngine(){
 bool BatchEngine::getInput(){
        try {
                //check if this is a valid batchfile
-               if (openedBatch == 1) {  cout << "unable to open batchfile" << endl;  return 1; }
+               if (openedBatch == 1) {  
+                       mothurOut("unable to open batchfile");  
+                       mothurOutEndLine();
+                       return 1; 
+               }
        
                string input = "";
                string commandName = "";
                string options = "";
-               //int count = 1;
                
                //CommandFactory cFactory;
                int quitCommandCalled = 0;
@@ -151,11 +159,14 @@ bool BatchEngine::getInput(){
                        if (inputBatchFile.eof()) { input = "quit()"; }
                        else { getline(inputBatchFile, input); }
                        
-                       //cout << "command number" << count << endl; count++;
                        
-                       if (input[0] != '#') {
                        
-                               cout << endl << "mothur > " << input << endl;
+                       if (input[0] != '#') {
+                               
+                               mothurOutEndLine();
+                               mothurOut("mothur > " + input);
+                               mothurOutEndLine();
+                               
                                
                                //allow user to omit the () on the quit command
                                if (input == "quit") { input = "quit()"; }
@@ -170,7 +181,10 @@ bool BatchEngine::getInput(){
                                        CommandFactory cFactory;
                                        Command* command = cFactory.getCommand(commandName, options);
                                        quitCommandCalled = command->execute();
-                               }else {         cout << "Invalid." << endl;             }
+                               }else {         
+                                       mothurOut("Invalid."); 
+                                       mothurOutEndLine();
+                               }
                                
                        }
                        gobble(inputBatchFile);
@@ -180,11 +194,7 @@ bool BatchEngine::getInput(){
                return 1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BatchEngine class Function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the BatchEngine class function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BatchEngine", "getInput");
                exit(1);
        }
 }
@@ -201,16 +211,14 @@ ScriptEngine::ScriptEngine(string path, string commandString){
                listOfCommands = commandString.substr(1, (commandString.length()-1));
 
                globaldata->argv = path;
+               string logFileName = "mothur.logFile";
+               remove(logFileName.c_str());
 
                system("clear");
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScriptEngine class Function ScriptEngine. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScriptEngine class function ScriptEngine. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScriptEngine", "ScriptEngine");
                exit(1);
        }
 }
@@ -221,14 +229,14 @@ ScriptEngine::~ScriptEngine(){
        }
 
 /***********************************************************************/
-//This Function allows the user to run a batchfile containing several commands on Dotur
+//This Function allows the user to run a batchfile containing several commands on mothur
 bool ScriptEngine::getInput(){
        try {
                        
                string input = "";
                string commandName = "";
                string options = "";
-               //int count = 1;
+               
                
                //CommandFactory cFactory;
                int quitCommandCalled = 0;
@@ -238,9 +246,12 @@ bool ScriptEngine::getInput(){
                        input = getNextCommand(listOfCommands); 
                        
                        if (input == "") { input = "quit()"; }
-                       //cout << "command number" << count << endl; count++;
                        
-                       cout << endl << "mothur > " << input << endl;
+                       
+                       mothurOutEndLine();
+                       mothurOut("mothur > " + input);
+                       mothurOutEndLine();
+
                                
                        //allow user to omit the () on the quit command
                        if (input == "quit") { input = "quit()"; }
@@ -255,18 +266,17 @@ bool ScriptEngine::getInput(){
                                CommandFactory cFactory;
                                Command* command = cFactory.getCommand(commandName, options);
                                quitCommandCalled = command->execute();
-                       }else {         cout << "Invalid." << endl;             }
+                       }else {         
+                               mothurOut("Invalid."); 
+                               mothurOutEndLine();
+                       }
                        
                }
                
                return 1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScriptEngine class Function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScriptEngine class function getInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScriptEngine", "getInput");
                exit(1);
        }
 }
@@ -293,11 +303,7 @@ string ScriptEngine::getNextCommand(string& commandString) {
                return nextcommand;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScriptEngine class Function getNextCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScriptEngine class function getNextCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScriptEngine", "getNextCommand");
                exit(1);
        }
 }
index 9b2438f4e18986f7fc362c71f77c3e71caa448a3..57754667da593265618aa0d9e5c046e18b2b7203 100644 (file)
@@ -43,11 +43,7 @@ void FastaMap::readFastaFile(string inFileName) {
                in.close();             
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function readFastaFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FastaMap class function readFastaFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FastaMap", "readFastaFile");
                exit(1);
        }
 }
@@ -152,11 +148,7 @@ void FastaMap::printNamesFile(string outFileName){ //prints data
                outFile.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FastaMap class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FastaMap", "printNamesFile");
                exit(1);
        }
 }
@@ -175,11 +167,7 @@ void FastaMap::printCondensedFasta(string outFileName){ //prints data
                out.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FastaMap class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FastaMap", "printCondensedFasta");
                exit(1);
        }
 }
index 4347c127f844fd4132f97c361ffcc4b0cd0919ea..63130a83ba6c850bc8db4ea720ba51a15d80ff81 100644 (file)
@@ -40,11 +40,7 @@ void ThreeColumnFile::initFile(string label){
                outFile.setf(ios::showpoint);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ThreeColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ThreeColumnFile", "initFile");
                exit(1);
        }
 }
@@ -64,11 +60,7 @@ void ThreeColumnFile::output(int nSeqs, vector<double> data){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ThreeColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ThreeColumnFile", "output");
                exit(1);
        }
 }
@@ -90,17 +82,13 @@ void ThreeColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) {  cout << "Unable to rename necessary files." << endl; }
+               if ((renameOk != 0)) {  mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ThreeColumnFile", "resetFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ThreeColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -142,11 +130,7 @@ void ColumnFile::initFile(string label, vector<string> tags){
                outFile.setf(ios::showpoint);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ColumnFile", "initFile");
                exit(1);
        }
 }
@@ -176,11 +160,7 @@ void ColumnFile::output(vector<double> data){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ColumnFile", "output");
                exit(1);
        }
 }
@@ -202,17 +182,13 @@ void ColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; }
+               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ColumnFile", "resetFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -247,11 +223,7 @@ void SharedThreeColumnFile::initFile(string label){
                outFile.setf(ios::showpoint);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedThreeColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedThreeColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedThreeColumnFile", "initFile");
                exit(1);
        }
 }
@@ -272,11 +244,7 @@ void SharedThreeColumnFile::output(int nSeqs, vector<double> data){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedThreeColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedThreeColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedThreeColumnFile", "output");
                exit(1);
        }
 }
@@ -297,17 +265,13 @@ void SharedThreeColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; }
+               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedThreeColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedThreeColumnFile", "resetFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedThreeColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -343,13 +307,9 @@ void OneColumnFile::initFile(string label){
                outFile.setf(ios::showpoint);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OneColumnFile", "initFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -367,13 +327,9 @@ void OneColumnFile::output(int nSeqs, vector<double> data){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OneColumnFile", "output");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -392,17 +348,13 @@ void OneColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; }
+               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OneColumnFile", "resetFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -439,13 +391,9 @@ void SharedOneColumnFile::initFile(string label){
                outFile.setf(ios::showpoint);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOneColumnFile", "initFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -470,13 +418,9 @@ void SharedOneColumnFile::output(int nSeqs, vector<double> data){
                        }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOneColumnFile", "output");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -496,18 +440,14 @@ void SharedOneColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; }
+               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
 
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOneColumnFile", "resetFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OneColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index c38bfcb5f83eb3b607b42616174cf650b0de8952..ad491aa1252ccb28553b12daf0f353533428d531 100644 (file)
@@ -36,7 +36,7 @@ FilterSeqsCommand::FilterSeqsCommand(string option){
                        
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { cout << "fasta is a required parameter for the filter.seqs command." << endl; abort = true; }
+                       if (fastafile == "not found") { mothurOut("fasta is a required parameter for the filter.seqs command."); mothurOutEndLine(); abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
 
                        //check for optional parameter and set defaults
@@ -60,40 +60,32 @@ FilterSeqsCommand::FilterSeqsCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FilterSeqsCommand class Function FilterSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the FilterSeqsCommand class function FilterSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void FilterSeqsCommand::help(){
        try {
-               cout << "The filter.seqs command reads a file containing sequences and creates a .filter and .filter.fasta file." << "\n";
-               cout << "The filter.seqs command parameters are fasta, trump, soft, hard and vertical.  " << "\n";
-               cout << "The fasta parameter is required." << "\n";
-               cout << "The trump parameter .... The default is ..." << "\n";
-               cout << "The soft parameter .... The default is ...." << "\n";
-               cout << "The hard parameter .... The default is ...." << "\n";
-               cout << "The vertical parameter .... The default is T." << "\n";
-               cout << "The filter.seqs command should be in the following format: " << "\n";
-               cout << "filter.seqs(fasta=yourFastaFile, trump=yourTrump, soft=yourSoft, hard=yourHard, vertical=yourVertical) " << "\n";
-               cout << "Example filter.seqs(fasta=abrecovery.fasta, trump=..., soft=..., hard=..., vertical=T)." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta)." << "\n" << "\n";
+               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");
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FilterSeqsCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FilterSeqsCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the FilterSeqsCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************/
@@ -206,15 +198,15 @@ int FilterSeqsCommand::execute() {
                outFilter << filter << endl;
                outFilter.close();
                
-
-               openInputFile(fastafile, inFASTA);
+               ifstream inFasta2;
+               openInputFile(fastafile, inFasta2);
                string filteredFasta = getRootName(fastafile) + "filter.fasta";
                ofstream outFASTA;
                openOutputFile(filteredFasta, outFASTA);
 
                numSeqs = 0;
-               while(!inFASTA.eof()){
-                       Sequence seq(inFASTA);
+               while(!inFasta2.eof()){
+                       Sequence seq(inFasta2);
                        string align = seq.getAligned();
                        string filterSeq = "";
        
@@ -226,10 +218,10 @@ int FilterSeqsCommand::execute() {
 
                        outFASTA << '>' << seq.getName() << endl << filterSeq << endl;
                        numSeqs++;
-                       gobble(inFASTA);
+                       gobble(inFasta2);
                }
                outFASTA.close();
-               inFASTA.close();
+               inFasta2.close();
                
                
                int filteredLength = 0;
@@ -237,21 +229,17 @@ int FilterSeqsCommand::execute() {
                        if(filter[i] == '1'){   filteredLength++;       }
                }
                
-               cout << endl;
-               cout << "Length of filtered alignment: " << filteredLength << endl;
-               cout << "Number of columns removed: " << alignmentLength-filteredLength << endl;
-               cout << "Length of the original alignment: " << alignmentLength << endl;
-               cout << "Number of sequences used to construct filter: " << numSeqs << endl;
+               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();
                
                return 0;
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FilterSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FilterSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FilterSeqsCommand", "execute");
                exit(1);
        }
 }
index bc53b7db926cca543449fe58b5182d7d1ed6af67..5bb2d2336d6ea263a1b0596511abf5f66cb7a248 100644 (file)
@@ -27,7 +27,7 @@ FullMatrix::FullMatrix(ifstream& filehandle) {
                }
                
                group = groupmap->getGroup(name);
-               if(group == "not found") {      cout << "Error: Sequence '" << name << "' was not found in the group file, please correct." << endl; exit(1); }
+               if(group == "not found") {      mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
                index.resize(numSeqs);
                index[0].groupName = group; 
                index[0].seqName = name;
@@ -78,11 +78,7 @@ FullMatrix::FullMatrix(ifstream& filehandle) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function FullMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FullMatrix class function FullMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FullMatrix", "FullMatrix");
                exit(1);
        }
 }
@@ -104,7 +100,7 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) {
                        index[i].groupName = group;
                        index[i].seqName = name;
                        
-                       if(group == "not found") {      cout << "Error: Sequence '" << name << "' was not found in the group file, please correct." << endl; exit(1); }
+                       if(group == "not found") {      mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); }
                                
                        for(int j=0;j<numSeqs;j++){
                                filehandle >> matrix[i][j];
@@ -117,14 +113,9 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) {
                delete reading;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function readSquareMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FullMatrix class function readSquareMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FullMatrix", "readSquareMatrix");
                exit(1);
        }
-
 } 
 /**************************************************************************/
 void FullMatrix::readLTMatrix(ifstream& filehandle) {
@@ -144,7 +135,7 @@ void FullMatrix::readLTMatrix(ifstream& filehandle) {
                        index[i].groupName = group;
                        index[i].seqName = name;
        
-                       if(group == "not found") {      cout << "Error: Sequence '" << name << "' was not found in the group file, please correct." << endl;  exit(1); }
+                       if(group == "not found") {      mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                                
                        for(int j=0;j<i;j++){
                                filehandle >> distance;
@@ -159,14 +150,9 @@ void FullMatrix::readLTMatrix(ifstream& filehandle) {
                delete reading;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function readLTMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FullMatrix class function readLTMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FullMatrix", "readLTMatrix");
                exit(1);
        }
-
 }
 
 /**************************************************************************/
@@ -231,14 +217,9 @@ void FullMatrix::sortGroups(int low, int high){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function sortGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the FullMatrix class function sortGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FullMatrix", "sortGroups");
                exit(1);
        }
-
 }
 
 /**************************************************************************/   
@@ -274,14 +255,9 @@ void FullMatrix::printMatrix(ostream& out) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function printMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "FullMatrix", "printMatrix");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the FullMatrix class function printMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /**************************************************************************/
index a23352c0f11d588c6254e3b16c4d1932a381b37e..a52e64443a0ad1fa9a06ca77361eba8741ba97cb 100644 (file)
--- a/geom.cpp
+++ b/geom.cpp
@@ -74,17 +74,11 @@ EstOutput Geom::getValues(SAbundVector* rank){
                }
 
 
-               /*cout << "Geom:\n";
-               cout << "D-Statistic = " << DStatistic << "\n";
-               cout << "Critical value for 95% confidence interval = ";*/
-
                data[0] = maxDiff/numInd;
                data[1] = 0.886/sqrt(numSpec);
                data[2] = 1.031/sqrt(numSpec);
 
-               /*cout << critVal << "\n";
-               cout << "If D-Statistic is less than the critical value then the data fits the Geometric Series model w/ 95% confidence.\n\n";*/
-
+               
                if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
                if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
                if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
@@ -92,13 +86,9 @@ EstOutput Geom::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Geom class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Geom", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Geom class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 4fa84136001aefaeb051ee592a41e54b081b0885..95baec8e72a5ea9202261790279fc5080e0ca3ad 100644 (file)
@@ -19,9 +19,9 @@ GetgroupCommand::GetgroupCommand(string option){
                if(option == "help") { help(); abort = true; }
                
                else {
-                       if (option != "") { cout << "There are no valid parameters for the get.group command." << endl; abort = true; }
+                       if (option != "") { mothurOut("There are no valid parameters for the get.group command."); mothurOutEndLine(); abort = true; }
                        
-                       if ((globaldata->getSharedFile() == "")) { cout << "You must use the read.otu command to read a groupfile or a sharedfile before you can use the get.group command." << endl; abort = true; }
+                       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 (abort == false) {
                                //open shared file
@@ -36,35 +36,26 @@ GetgroupCommand::GetgroupCommand(string option){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetgroupCommand", "GetgroupCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetgroupCommand class function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void GetgroupCommand::help(){
        try {
-               cout << "The get.group command can only be executed after a successful read.otu command." << "\n";
-               //cout << "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 concensus command." << "\n";
-               cout << "You may not use any parameters with the get.group command." << "\n";
-               cout << "The get.group command should be in the following format: " << "\n";
-               cout << "get.group()" << "\n";
-               cout << "Example get.group()." << "\n";
+               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 concensus 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");
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetgroupCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetgroupCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -88,7 +79,7 @@ int GetgroupCommand::execute(){
                holdLabel = label;
                
                //output first group
-               cout << groupN << endl;
+               mothurOut(groupN); mothurOutEndLine();
                out << groupN << '\t' << groupN << endl;        
                        
                //get rest of line
@@ -104,7 +95,7 @@ int GetgroupCommand::execute(){
                        count++;
                        
                        //output next group
-                       cout << groupN << endl;
+                       mothurOut(groupN); mothurOutEndLine();
                        out << groupN << '\t' << groupN << endl;                                
                        
                        //fill vector.  
@@ -121,13 +112,9 @@ int GetgroupCommand::execute(){
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetgroupCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetgroupCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index 40c656bb0286122f013ec9dfe65a6da2ea42244a..be2a989d7a953be7b68a29ceca1a88c4d514bd20 100644 (file)
@@ -20,40 +20,31 @@ GetlabelCommand::GetlabelCommand(string option){
                if(option == "help") { help(); abort = true; }
                
                else {
-                       if (option != "") { cout << "There are no valid parameters for the get.label command." << endl; abort = true; }
+                       if (option != "") { mothurOut("There are no valid parameters for the get.label command."); mothurOutEndLine(); abort = true; }
                        
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the get.label command." << endl; abort = true; }                              
+                       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; }                               
                }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlabelCommand", "GetlabelCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlabelCommand class function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void GetlabelCommand::help(){
        try {
-               cout << "The get.label command can only be executed after a successful read.otu command." << "\n";
-               cout << "You may not use any parameters with the get.label command." << "\n";
-               cout << "The get.label command should be in the following format: " << "\n";
-               cout << "get.label()" << "\n";
-               cout << "Example get.label()." << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlabelCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlabelCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -78,7 +69,7 @@ int GetlabelCommand::execute(){
                        if(count > numBins)
                                count = 0;
                        if(count == 0) {
-                               cout << label << "\n";
+                               mothurOut(label); mothurOutEndLine();
                                in >> numBins;
                        }
                        in >> label;
@@ -90,12 +81,8 @@ int GetlabelCommand::execute(){
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlabelCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlabelCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
index 800f9d816eab2230d2f543321d0ddb5c97e1ee63..f1ec55cab12261a5b91f425553bf34bc71393727 100644 (file)
@@ -19,40 +19,31 @@ GetlineCommand::GetlineCommand(string option){
                if(option == "help") { help(); abort = true; }
                
                else {
-                       if (option != "") { cout << "There are no valid parameters for the get.line command." << endl; abort = true; }
+                       if (option != "") { mothurOut("There are no valid parameters for the get.line command."); mothurOutEndLine(); abort = true; }
                        
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the get.line command." << endl; abort = true; }                               
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the get.line command."); mothurOutEndLine(); abort = true; }                                
                }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlineCommand", "GetlineCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlineCommand class function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void GetlineCommand::help(){
        try {
-               cout << "The get.line command can only be executed after a successful read.otu command." << "\n";
-               cout << "You may not use any parameters with the get.line command." << "\n";
-               cout << "The get.line command should be in the following format: " << "\n";
-               cout << "get.line()" << "\n";
-               cout << "Example get.line()." << "\n";
+               mothurOut("The get.line command can only be executed after a successful read.otu command.\n");
+               mothurOut("You may not use any parameters with the get.line command.\n");
+               mothurOut("The get.line command should be in the following format: \n");
+               mothurOut("get.line()\n");
+               mothurOut("Example get.line().\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlineCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlineCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -77,7 +68,7 @@ int GetlineCommand::execute(){
                        if(count > numBins)
                                count = 0;
                        if(count == 0) {
-                               cout << line << "\n";
+                               mothurOut(toString(line)); mothurOutEndLine();
                                in >> numBins;
                                line++;
                        }
@@ -90,13 +81,9 @@ int GetlineCommand::execute(){
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlineCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlineCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index 1f5c02beab1630a2d5e8d39547fb967838ae0e29..92ba3ad5214cee119f9dcee08c256e1b1a2f79be 100644 (file)
@@ -19,9 +19,9 @@ GetOTURepCommand::GetOTURepCommand(string option){
                labels.clear();
                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
-               
-               else {
+               if (option == "help") { 
+                       help(); abort = true;
+               else {
                        //valid paramters for this command
                        string Array[] =  {"fasta","list","line","label","name", "group"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
@@ -38,22 +38,22 @@ GetOTURepCommand::GetOTURepCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
-                               cout << "Before you use the get.oturep command, you first need to read in a distance matrix." << endl
+                               mothurOut("Before you use the get.oturep command, you first need to read in a distance matrix."); mothurOutEndLine()
                                abort = true;
                        }
                        
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { cout << "fasta is a required parameter for the get.oturep command." << endl; abort = true; }
+                       if (fastafile == "not found") { mothurOut("fasta is a required parameter for the get.oturep command."); mothurOutEndLine(); abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
                
                        listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found") { cout << "list is a required parameter for the get.oturep command." << endl; abort = true; }
+                       if (listfile == "not found") { mothurOut("list is a required parameter for the get.oturep command."); mothurOutEndLine(); abort = true; }
                        else if (listfile == "not open") { abort = true; }      
 
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
-                       line = validParameter.validFile(parameters, "line", false);                             
+                       line = validParameter.validFile(parameters, "line", false);
                        if (line == "not found") { line = "";  }
                        else { 
                                if(line != "all") {  splitAtDash(line, lines);  allLines = 0;  }
@@ -68,7 +68,7 @@ GetOTURepCommand::GetOTURepCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if ((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -91,11 +91,12 @@ GetOTURepCommand::GetOTURepCommand(string option){
                
                        if (abort == false) {
                        
-                               if(globaldata->gSparseMatrix != NULL)   {       matrix = globaldata->gSparseMatrix;             }       
-                                       
+                               if(globaldata->gSparseMatrix != NULL)   {
+                                       matrix = globaldata->gSparseMatrix;
+                               }
+
                                //globaldata->gListVector bin 0 = first name read in distance matrix, globaldata->gListVector bin 1 = second name read in distance matrix
-                               if(globaldata->gListVector != NULL)             {
-               
+                               if (globaldata->gListVector != NULL) {
                                        vector<string> names;
                                        string binnames;
                                        //map names to rows in sparsematrix
@@ -108,23 +109,24 @@ GetOTURepCommand::GetOTURepCommand(string option){
                                                for (int j = 0; j < names.size(); j++) {
                                                        nameToIndex[names[j]] = i;
                                                }
-       
                                        }
-                               }else { cout << "error, no listvector." << endl; }
-                               
-//                             openInputFile(fastafile, in);
+                               } else { mothurOut("error, no listvector."); mothurOutEndLine(); }
+
+                               // Create a data structure to quickly access the distance information.
+                               // It consists of a vector of distance maps, where each map contains
+                               // all distances of a certain sequence. Vector and maps are accessed
+                               // via the index of a sequence in the distance matrix
+                               seqVec = vector<SeqMap>(globaldata->gListVector->size()); 
+                               for (MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++) {
+                                       seqVec[currentCell->row][currentCell->column] = currentCell->dist;
+                               }
+
                                fasta = new FastaMap();
                        }
-               
                }
-       
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function GetOTURepCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function GetOTURepCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
                exit(1);
        }
 }
@@ -133,24 +135,20 @@ GetOTURepCommand::GetOTURepCommand(string option){
 
 void GetOTURepCommand::help(){
        try {
-               cout << "The get.oturep command can only be executed after a successful read.dist command." << "\n";
-               cout << "The get.oturep command parameters are list, fasta, name, group, line and label.  The fasta and list parameters are required, and you may not use line and label at the same time." << "\n";
-               cout << "The line and label allow you to select what distance levels you would like a output files created for, and are separated by dashes." << "\n";
-               cout << "The get.oturep command should be in the following format: get.oturep(fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example get.oturep(fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups, line=1-3-5, name=amazon.names)." << "\n";
-               cout << "The default value for line and label are all lines in your inputfile." << "\n";
-               cout << "The get.oturep command outputs a .fastarep file for each distance you specify, selecting one OTU representative for each bin." << "\n";
-               cout << "If you provide a groupfile, then it also appends the names of the groups present in that bin." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n";
+               mothurOut("The get.oturep command can only be executed after a successful read.dist command.\n");
+               mothurOut("The get.oturep command parameters are list, fasta, name, group, line and label.  The fasta and list parameters are required, and you may not use line and label at the same time.\n");
+               mothurOut("The line and label allow you to select what distance levels you would like a output files created for, and are separated by dashes.\n");
+               mothurOut("The get.oturep command should be in the following format: get.oturep(fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example get.oturep(fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups, line=1-3-5, name=amazon.names).\n");
+               mothurOut("The default value for line and label are all lines in your inputfile.\n");
+               mothurOut("The get.oturep command outputs a .fastarep 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -172,7 +170,7 @@ int GetOTURepCommand::execute(){
        try {
        
                if (abort == true) { return 0; }
-               
+
                int count = 1;
                int error;
                
@@ -190,7 +188,7 @@ int GetOTURepCommand::execute(){
                }
                
                //read list file
-               read = new ReadOTUFile(listfile);       
+               read = new ReadOTUFile(listfile);
                read->read(&*globaldata); 
                
                input = globaldata->ginput;
@@ -205,8 +203,8 @@ int GetOTURepCommand::execute(){
                
                while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                        
-                       if(allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){
-                                       cout << list->getLabel() << '\t' << count << endl;
+                       if (allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){
+                                       mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine();
                                        error = process(list);
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
@@ -218,8 +216,7 @@ int GetOTURepCommand::execute(){
                        if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                        delete list;
                                        list = input->getListVector(lastLabel);
-                                       
-                                       cout << list->getLabel() << '\t' << count << endl;
+                                       mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine();
                                        error = process(list);
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
@@ -227,8 +224,7 @@ int GetOTURepCommand::execute(){
                                        userLabels.erase(list->getLabel());
                        }
                        
-                       
-                       lastLabel = list->getLabel();                   
+                       lastLabel = list->getLabel();
                        
                        delete list;
                        list = input->getListVector();
@@ -238,12 +234,12 @@ int GetOTURepCommand::execute(){
                //output error messages about any remaining user labels
                bool needToRun = false;
                for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
-                       if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                       mothurOut("Your file does not include the label " + *it)
+                       if (processedLabels.count(list->getLabel()) != 1) {
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -251,28 +247,23 @@ int GetOTURepCommand::execute(){
                if (needToRun == true)  {
                        delete list;
                        list = input->getListVector(lastLabel);
-
-                       cout << list->getLabel() << '\t' << count << endl;
+                       mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine();
                        error = process(list);
-                       if (error == 1) { return 0; } //there is an error in hte input files, abort command
                        delete list;
+                       if (error == 1) { return 0; } //there is an error in hte input files, abort command
                }
                
                delete matrix;
                globaldata->gSparseMatrix = NULL;
+               delete list;
                globaldata->gListVector = NULL;
 
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "execute");
                exit(1);
        }
-
 }
 
 //**********************************************************************************************************************
@@ -304,156 +295,131 @@ void GetOTURepCommand::readNamesFile() {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "readNamesFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function readNamesFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
-string GetOTURepCommand::FindRep(int bin, string& group, ListVector* thisList) {
+string GetOTURepCommand::findRep(int bin, string& group, ListVector* thisList, int& binsize) {
        try{
                vector<string> names;
-               map<string, float> sums;
-               map<int, string> binMap; //subset of namesToIndex - just member of this bin
-               string binnames;
-               float min = 10000;
-               string minName;
                map<string, string> groups;
                map<string, string>::iterator groupIt;
-               
-               binnames = thisList->get(bin);
-       
+
                //parse names into vector
+               string binnames = thisList->get(bin);
                splitAtComma(binnames, names);
-               
+               binsize = names.size();
+
                //if you have a groupfile
-               if(groupfile != "") {
+               if (groupfile != "") {
                        //find the groups that are in this bin
-                       for (int i = 0; i < names.size(); i++) {
+                       for (size_t i = 0; i < names.size(); i++) {
                                string groupName = groupMap->getGroup(names[i]);
                                if (groupName == "not found") {  
-                                       cout << names[i] << " is missing from your group file. Please correct. " << endl;
+                                       mothurOut(names[i] + " is missing from your group file. Please correct. "); mothurOutEndLine();
                                        groupError = true;
-                               }else{
+                               } else {
                                        groups[groupName] = groupName;
                                }
                        }
                        
                        //turn the groups into a string
-                       for(groupIt = groups.begin(); groupIt != groups.end(); groupIt++) { group += groupIt->first + "-"; }
-                       
+                       for (groupIt = groups.begin(); groupIt != groups.end(); groupIt++) {
+                               group += groupIt->first + "-";
+                       }
                        //rip off last dash
                        group = group.substr(0, group.length()-1);
                }
-               
-               //if only 1 sequence in bin then that's the rep
-               if (names.size() == 1) { return names[0]; }
-               else {
-                       //fill binMap
-                       for (int i = 0; i < names.size(); i++) {
-                               for (map<string, int>::iterator it = nameToIndex.begin(); it != nameToIndex.end(); it++) {
 
-                                       if (it->first == names[i]) {  
-                                               binMap[it->second] = it->first;
+               // if only 1 sequence in bin or processing the "unique" line, then 
+               // the first sequence of the OTU is the representative one
+               if ((names.size() == 1) || (list->getLabel() == "unique")) {
+                       return names[0];
+               } else {
+                       vector<int> seqIndex(names.size());
+                       vector<float> max_dist(names.size());
 
-                                               //initialize sums map
-                                               sums[it->first] = 0.0;
-                                               break;
-                                       }
-                               }
+                       //fill seqIndex and initialize sums
+                       for (size_t i = 0; i < names.size(); i++) {
+                               seqIndex[i] = nameToIndex[names[i]];
+                               max_dist[i] = 0.0;
                        }
                        
-                       //go through each cell in the sparsematrix
-                       for(MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++){
-                               //is this a distance between 2 members of this bin
-                               map<int, string>::iterator it = binMap.find(currentCell->row);
-                               map<int, string>::iterator it2 = binMap.find(currentCell->column);
-                               
-                               //sum the distance of the sequences in the bin to eachother
-                               if ((it != binMap.end()) && (it2 != binMap.end())) {
-                                       //this is a cell that repesents the distance between to of this bins members
-                                       sums[it->second] += currentCell->dist;
-                                       sums[it2->second] += currentCell->dist;
+                       // loop through all entries in seqIndex
+                       SeqMap::iterator it;
+                       SeqMap currMap;
+                       for (size_t i=0; i < seqIndex.size(); i++) {
+                               currMap = seqVec[seqIndex[i]];
+                               for (size_t j=0; j < seqIndex.size(); j++) {
+                                       it = currMap.find(seqIndex[j]);         
+                                       if (it != currMap.end()) {
+                                               max_dist[i] = max(max_dist[i], it->second);
+                                               max_dist[j] = max(max_dist[j], it->second);
+                                       }
                                }
                        }
                        
-                       //smallest sum is the representative
-                       for (map<string, float>::iterator it4 = sums.begin(); it4 != sums.end(); it4++) {
-                               if (it4->second < min) {
-                                       min = it4->second;
-                                       minName = it4->first;
+                       // sequence with the smallest maximum distance is the representative
+                       float min = 10000;
+                       int minIndex;
+                       for (size_t i=0; i < max_dist.size(); i++) {
+                               if (max_dist[i] < min) {
+                                       min = max_dist[i];
+                                       minIndex = i;
                                }
-
                        }
-                       
-                       return minName;
+
+                       return(names[minIndex]);
                }
-       
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function FindRep. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "FindRep");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function FindRep. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 int GetOTURepCommand::process(ListVector* processList) {
        try{
-                               string nameRep, name, sequence;
+               string nameRep, name, sequence;
 
-                               //create output file
-                               string outputFileName = getRootName(listfile) + processList->getLabel() + ".rep.fasta";
-                               openOutputFile(outputFileName, out);
-                               
-                               //for each bin in the list vector
-                               for (int i = 0; i < processList->size(); i++) {
-                                       string groups;
-                                       nameRep = FindRep(i, groups, processList);
-                                       
-                                       //print out name and sequence for that bin
-                                       sequence = fasta->getSequence(nameRep);
+               //create output file
+               string outputFileName = getRootName(listfile) + processList->getLabel() + ".rep.fasta";
+               openOutputFile(outputFileName, out);
 
-                                       if (sequence != "not found") {
-                                               if (groupfile == "") {
-                                                       nameRep = nameRep + "|" + toString(i+1);
-                                                       out << ">" << nameRep << endl;
-                                                       out << sequence << endl;
-                                               }else {
-                                                       nameRep = nameRep + "|" + groups + "|" + toString(i+1);
-                                                       out << ">" << nameRep << endl;
-                                                       out << sequence << endl;
-                                               }
-                                       }else { 
-                                               cout << nameRep << " is missing from your fasta or name file. Please correct. " << endl; 
-                                               remove(outputFileName.c_str());
-                                               return 1;
-                                       }
+               //for each bin in the list vector
+               for (int i = 0; i < processList->size(); i++) {
+                       string groups;
+                       int binsize;
+                       nameRep = findRep(i, groups, processList, binsize);
+
+                       //print out name and sequence for that bin
+                       sequence = fasta->getSequence(nameRep);
+
+                       if (sequence != "not found") {
+                               nameRep = nameRep + "|" + toString(i+1);
+                               nameRep = nameRep + "|" + toString(binsize);
+                               if (groupfile != "") {
+                                       nameRep = nameRep + "|" + groups;
                                }
-                               
-                               out.close();
-                               return 0;
-       
+                               out << ">" << nameRep << endl;
+                               out << sequence << endl;
+                       } else { 
+                               mothurOut(nameRep + " is missing from your fasta or name file. Please correct. "); mothurOutEndLine(); 
+                               remove(outputFileName.c_str());
+                               return 1;
+                       }
+               }
+
+               out.close();
+               return 0;
+
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetOTURepCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetOTURepCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetOTURepCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
-
-
-
-
-
index 37c4194a8c16e0664d7cb834b4777c054b61268d..4f755d0fccfe68dd1e03b5b36d57ce4b76287df9 100644 (file)
 #include "fastamap.h"
 #include "groupmap.h"
 
-class GlobalData;
-
 typedef list<PCell>::iterator MatData;
+typedef map<int, float> SeqMap;
 
 class GetOTURepCommand : public Command {
-       
+
 public:
-       GetOTURepCommand(string);       
+       GetOTURepCommand(string);
        ~GetOTURepCommand();
        int execute();
-       void help();    
-       
+       void help();
+
 private:
        GlobalData* globaldata;
        SparseMatrix* matrix;
@@ -44,15 +43,21 @@ private:
        ofstream out;
        ifstream in, inNames;
        bool groupError;
-       
+
        bool abort, allLines;
        set<int> lines; //hold lines to be used
        set<string> labels; //holds labels to be used
        map<string, int> nameToIndex;  //maps sequence name to index in sparsematrix
-       
+
+       vector<SeqMap> seqVec;                  // contains maps with sequence index and distance
+                                                                       // for all distances related to a certain sequence
+
+
        void readNamesFile();
        int process(ListVector*);
-       string FindRep(int, string&, ListVector*); // returns name of "representative" sequence of given bin. //and fill a string containing the groups in that bin if a groupfile is given
+       string findRep(int, string&, ListVector*, int&);        // returns the name of the "representative" sequence of given bin, 
+                                                                       // fills a string containing the groups in that bin if a groupfile is given,
+                                                                       // and returns the number of sequences in the given bin
 
 };
 
index b8c692bf7f64b4566311a3f9232f933aec100800..73862a85eda66077fdc51b9bbebc1dc579c8da02 100644 (file)
@@ -3,7 +3,7 @@
  *  Mothur
  *
  *  Created by Sarah Westcott on 6/2/09.
- *  Copyright 2009 __MyCompanyName__. All rights reserved.
+ *  Copyright 2009 Schloss Lab Umass Amherst. All rights reserved.
  *
  */
 
@@ -38,7 +38,7 @@ GetRAbundCommand::GetRAbundCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if (globaldata->getListFile() == "") { cout << "You must read a listfile before you can use the get.rabund command." << endl; abort = true; }
+                       if (globaldata->getListFile() == "") { mothurOut("You must read a listfile before you can use the get.rabund command."); mothurOutEndLine(); abort = true; }
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -57,7 +57,7 @@ GetRAbundCommand::GetRAbundCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -73,36 +73,27 @@ GetRAbundCommand::GetRAbundCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetRAbundCommand class Function GetRAbundCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
                exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetRAbundCommand class function GetRAbundCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
+       }                       
 }
 //**********************************************************************************************************************
 
 void GetRAbundCommand::help(){
        try {
-               cout << "The get.rabund command can only be executed after a successful read.otu of a listfile." << "\n";
-               cout << "The get.rabund command parameters are line and label.  No parameters are required, and you may not use line and label at the same time." << "\n";
-               cout << "The line and label allow you to select what distance levels you would like included in your .rabund file, and are separated by dashes." << "\n";
-               cout << "The get.rabund command should be in the following format: get.rabund(line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example get.rabund(line=1-3-5)." << "\n";
-               cout << "The default value for line and label are all lines in your inputfile." << "\n";
-               cout << "The get.rabund command outputs a .rabund file containing the lines you selected." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
+               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 line and label.  No parameters are required, and you may not use line and label at the same time.\n");
+               mothurOut("The line and label allow you to select what distance levels you would like included in your .rabund file, and are separated by dashes.\n");
+               mothurOut("The get.rabund command should be in the following format: get.rabund(line=yourLines, label=yourLabels).\n");
+               mothurOut("Example get.rabund(line=1-3-5).\n");
+               mothurOut("The default value for line and label are all lines 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. line), '=' and parameters (i.e.yourLines).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetRAbundCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetRAbundCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetRAbundCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -137,7 +128,7 @@ int GetRAbundCommand::execute(){
                while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                        
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){
-                                       cout << list->getLabel() << '\t' << count << endl;
+                                       mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        rabund = new RAbundVector();
                                        *rabund = (list->getRAbundVector());
                                        rabund->print(out);
@@ -152,7 +143,7 @@ int GetRAbundCommand::execute(){
                                        delete list;
                                        list = input->getListVector(lastLabel);
                                        
-                                       cout << list->getLabel() << '\t' << count << endl;
+                                       mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        rabund = new RAbundVector();
                                        *rabund = (list->getRAbundVector());
                                        rabund->print(out);
@@ -173,12 +164,12 @@ int GetRAbundCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -187,7 +178,7 @@ int GetRAbundCommand::execute(){
                        delete list;
                        list = input->getListVector(lastLabel);
                        
-                       cout << list->getLabel() << '\t' << count << endl;
+                       mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        rabund = new RAbundVector();
                        *rabund = (list->getRAbundVector());
                        rabund->print(out);
@@ -200,13 +191,9 @@ int GetRAbundCommand::execute(){
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetRAbundCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetRAbundCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetRAbundCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index f5beb32b6a8296411dcd66afa18efc6b3be24577..0be26ce1855e5137668b9e4dabc49af9f230ad77 100644 (file)
@@ -38,7 +38,7 @@ GetSAbundCommand::GetSAbundCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "")) { cout << "You must read a list or rabund before you can use the get.sabund command." << endl; abort = true; }
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "")) { mothurOut("You must read a list or rabund before you can use the get.sabund command."); mothurOutEndLine(); abort = true; }
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -57,7 +57,7 @@ GetSAbundCommand::GetSAbundCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -73,36 +73,27 @@ GetSAbundCommand::GetSAbundCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetSAbundCommand class Function GetSAbundCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetSAbundCommand class function GetSAbundCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void GetSAbundCommand::help(){
        try {
-               cout << "The get.sabund command can only be executed after a successful read.otu of a listfile." << "\n";
-               cout << "The get.sabund command parameters are line and label.  No parameters are required, and you may not use line and label at the same time." << "\n";
-               cout << "The line and label allow you to select what distance levels you would like included in your .sabund file, and are separated by dashes." << "\n";
-               cout << "The get.sabund command should be in the following format: get.sabund(line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example get.sabund(line=1-3-5)." << "\n";
-               cout << "The default value for line and label are all lines in your inputfile." << "\n";
-               cout << "The get.sabund command outputs a .sabund file containing the lines you selected." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
+               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 are line and label.  No parameters are required, and you may not use line and label at the same time.\n");
+               mothurOut("The line and label allow 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(line=yourLines, label=yourLabels).\n");
+               mothurOut("Example get.sabund(line=1-3-5).\n");
+               mothurOut("The default value for line and label are all lines in your inputfile.\n");
+               mothurOut("The get.sabund command outputs a .sabund file containing the lines you selected.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetSAbundCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetSAbundCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetSAbundCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -136,7 +127,7 @@ int GetSAbundCommand::execute(){
                while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                        
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(order->getLabel()) == 1){
-                                       cout << order->getLabel() << '\t' << count << endl;
+                                       mothurOut(order->getLabel() + "\t" + toString(count));  mothurOutEndLine();
                                        sabund = new SAbundVector();
                                        *sabund = (order->getSAbundVector());
                                        sabund->print(out);
@@ -151,7 +142,7 @@ int GetSAbundCommand::execute(){
                                        delete order;           
                                        order = (input->getOrderVector(lastLabel));
                                        
-                                       cout << order->getLabel() << '\t' << count << endl;
+                                       mothurOut(order->getLabel() + "\t" + toString(count));  mothurOutEndLine();
                                        sabund = new SAbundVector();
                                        *sabund = (order->getSAbundVector());
                                        sabund->print(out);
@@ -173,12 +164,12 @@ int GetSAbundCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + ".");  mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + ".");  mothurOutEndLine();
                        }
                }
                
@@ -187,7 +178,7 @@ int GetSAbundCommand::execute(){
                        delete order;           
                        order = (input->getOrderVector(lastLabel));
                        
-                       cout << order->getLabel() << '\t' << count << endl;
+                       mothurOut(order->getLabel() + "\t" + toString(count));  mothurOutEndLine();
                        sabund = new SAbundVector();
                        *sabund = (order->getSAbundVector());
                        sabund->print(out);
@@ -201,13 +192,9 @@ int GetSAbundCommand::execute(){
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetSAbundCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetSAbundCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetSAbundCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index 0d728a128bd8fc43f0314c21894faf813533c7e2..cdf819baa6badc6e89c65bb6c6428e01be41d40d 100644 (file)
@@ -112,11 +112,7 @@ void GlobalData::newRead() {
                        runParse = true;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GlobalData", "newRead");
                exit(1);
        }
 }
@@ -141,11 +137,7 @@ GlobalData::~GlobalData() {
                if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function ~GlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function ~GlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GlobalData", "~GlobalData");
                exit(1);
        }
 }
index 6f66cbe8bbd09577ff0ce709e7fc882d79eb8874..ff09a36c31727bb6d04e3b2dbe50b50574a2a19f 100644 (file)
@@ -48,6 +48,7 @@ public:
        set<string> labels; //holds labels to be used
        vector<string> Treenames;
        
+       
        string getPhylipFile();
        string getColumnFile();
        string getListFile();
index 61ffe418f1380ddb4d02fa216a5f6b6ada8b9d58..8e823e4c8c3ed513ab2f7e90e44cb6c2de875b08 100644 (file)
@@ -26,13 +26,9 @@ EstOutput GoodsCoverage::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GoodsCoverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GoodsCoverage", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GoodsCoverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 38addc92f41487c3b715c7c7cbb7f03443dda24a..dd6f924ccdf661f4c376020e7f5459bc840cf895 100644 (file)
@@ -81,11 +81,7 @@ bool GroupMap::isValidGroup(string groupname) {
                return false;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GroupMap class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GroupMap class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GroupMap", "isValidGroup");
                exit(1);
        }
 }
index 3ed606f17be79024c72cf9834f499128a06d6a2e..6fd68614ce5e9ed4a28bcdc7c679e2f6d3d5f939 100644 (file)
@@ -18,11 +18,7 @@ HeatMap::HeatMap(string sort, string scale){
                scaler = scale;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMap", "HeatMap");
                exit(1);
        }
 }
@@ -91,11 +87,7 @@ void HeatMap::getPic(RAbundVector* rabund) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMap", "getPic");
                exit(1);
        }
 }
@@ -179,11 +171,7 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMap", "getPic");
                exit(1);
        }
 }
@@ -263,14 +251,9 @@ void HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function sortSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMap", "sortSharedVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function sortSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 //**********************************************************************************************************************
@@ -308,14 +291,9 @@ void HeatMap::printLegend(int y, float maxbin) {
        }
        
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMap", "printLegend");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 
index 413889ea1f1a1028420f4181cf17485266cb73b7..0ee34f9432deedc6cfe9a914efc84f4b3cf8c91f 100644 (file)
@@ -40,7 +40,7 @@ HeatMapCommand::HeatMapCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
-                                cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap.bin command." << endl; abort = true; 
+                                mothurOut("You must read a list, or a list and a group, or a shared before you can use the heatmap.bin command."); mothurOutEndLine(); abort = true; 
                        }
 
                        //check for optional parameter and set defaults
@@ -60,7 +60,7 @@ HeatMapCommand::HeatMapCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if ((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -87,42 +87,34 @@ HeatMapCommand::HeatMapCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapCommand", "HeatMapCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapCommand class function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void HeatMapCommand::help(){
        try {
-               cout << "The heatmap.bin command can only be executed after a successful read.otu command." << "\n";
-               cout << "The heatmap.bin command parameters are groups, sorted, scale, line and label.  No parameters are required, but you may not use line and label at the same time." << "\n";
-               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n";
-               cout << "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";
-               cout << "The scale parameter allows you to choose the range of color your bin information will be displayed with." << "\n";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n";
-               cout << "The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example heatmap.bin(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n";
-               cout << "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";
-               cout << "The default value for scale is log10; your other options are log2 and linear." << "\n";
-               cout << "The heatmap.bin command outputs a .svg file for each line or label you specify." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               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, line and label.  No parameters are required, but you may not use line and label at the same time.\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 line and label allow 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, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example heatmap.bin(groups=A-B-C, line=1-3-5, sorted=F, scale=log10).\n");
+               mothurOut("The default value for groups is all the groups in your groupfile, and all lines 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 line or label you specify.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -174,7 +166,7 @@ int HeatMapCommand::execute(){
                
                                if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
        
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        heatmap->getPic(lookup);
                                        
                                        processedLabels.insert(lookup[0]->getLabel());
@@ -183,9 +175,9 @@ int HeatMapCommand::execute(){
                                }
                                
                                if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       cout << lastLabel << '\t' << count << endl;
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
                                        lookup = input->getSharedRAbundVectors(lastLabel);
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        
                                        heatmap->getPic(lookup);
                                        
@@ -206,21 +198,21 @@ int HeatMapCommand::execute(){
                        set<string>::iterator it;
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               cout << "Your file does not include the label "<< *it
+                               mothurOut("Your file does not include the label " + *it)
                                if (processedLabels.count(lastLabel) != 1) {
-                                       cout << ". I will use " << lastLabel << "." << endl;
+                                       mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLabel << "." << endl;
+                                       mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastLabel << '\t' << count << endl;
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
                                lookup = input->getSharedRAbundVectors(lastLabel);
-
+                               
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                heatmap->getPic(lookup);
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                        }
@@ -236,7 +228,7 @@ int HeatMapCommand::execute(){
 
                                if(allLines == 1 || lines.count(count) == 1 || labels.count(rabund->getLabel()) == 1){                  
        
-                                       cout << rabund->getLabel() << '\t' << count << endl;
+                                       mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        heatmap->getPic(rabund);
                                        
                                        processedLabels.insert(rabund->getLabel());
@@ -246,9 +238,9 @@ int HeatMapCommand::execute(){
                                
                                if ((anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
 
-                                       cout << lastLabel << '\t' << count << endl;
                                        delete rabund;
                                        rabund = input->getRAbundVector(lastLabel);
+                                       mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        
                                        heatmap->getPic(rabund);
                                        
@@ -268,20 +260,21 @@ int HeatMapCommand::execute(){
                        set<string>::iterator it;
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               cout << "Your file does not include the label "<< *it
+                               mothurOut("Your file does not include the label " + *it)
                                if (processedLabels.count(lastLabel) != 1) {
-                                       cout << ". I will use " << lastLabel << "." << endl;
+                                       mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLabel << "." << endl;
+                                       mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastLabel << '\t' << count << endl;
+               
                                delete rabund;
                                rabund = input->getRAbundVector(lastLabel);
+                               mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        
                                heatmap->getPic(rabund);
                                delete rabund; globaldata->rabund = NULL;
@@ -293,13 +286,9 @@ int HeatMapCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
index 33588e671ac16a36b175dcdfc0291dc25a19e72c..ea0130453c9b2a155f2af66c5ffe2d4a1729bc33 100644 (file)
 
 //**********************************************************************************************************************
 HeatMapSim::HeatMapSim(){
-       try {
                globaldata = GlobalData::getInstance();
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
 }
 //**********************************************************************************************************************
 
@@ -107,11 +97,7 @@ void HeatMapSim::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*>
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapSim class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapSim", "getPic");
                exit(1);
        }
 }
@@ -148,14 +134,9 @@ void HeatMapSim::printLegend(int y, float maxSim) {
        }
        
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapSim", "printLegend");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapSim class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 //**********************************************************************************************************************
index 331ff7963460ef9d952a71382615bdf54e195677..b9216e4a990e7818c4ed5ce8759c706a44530c26 100644 (file)
@@ -52,7 +52,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                                cout << "You must read a list and a group, or a shared before you can use the heatmap.sim command." << endl; abort = true; 
+                                mothurOut("You must read a list and a group, or a shared before you can use the heatmap.sim command."); mothurOutEndLine(); abort = true; 
                        }
 
                        //check for optional parameter and set defaults
@@ -72,7 +72,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if ((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -132,40 +132,32 @@ HeatMapSimCommand::HeatMapSimCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapSimCommand class function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void HeatMapSimCommand::help(){
        try {
-               cout << "The heatmap.sim command can only be executed after a successful read.otu command." << "\n";
-               cout << "The heatmap.sim command parameters are groups, calc, line and label.  No parameters are required, but you may not use line and label at the same time." << "\n";
-               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n";
-               cout << "The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example heatmap.sim(groups=A-B-C, line=1-3-5, calc=jabund)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n";
+               mothurOut("The heatmap.sim command can only be executed after a successful read.otu command.\n");
+               mothurOut("The heatmap.sim command parameters are groups, calc, line and label.  No parameters are required, but you may not use line and label at the same time.\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 line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes.\n");
+               mothurOut("The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example heatmap.sim(groups=A-B-C, line=1-3-5, calc=jabund).\n");
+               mothurOut("The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used.\n");
                validCalculator->printCalc("heat", cout);
-               cout << "The default value for calc is jclass-thetayc." << "\n";
-               cout << "The heatmap.sim command outputs a .svg file for each calculator you choose at each line or label you specify." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               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 line or label you specify.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapSimCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapSimCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -189,7 +181,7 @@ int HeatMapSimCommand::execute(){
                int count = 1;  
                
                //if the users entered no valid calculators don't execute command
-               if (heatCalculators.size() == 0) { cout << "No valid calculators." << endl; return 0; }
+               if (heatCalculators.size() == 0) { mothurOut("No valid calculators."); mothurOutEndLine(); return 0; }
                
                //you have groups
                read = new ReadOTUFile(globaldata->inputFileName);      
@@ -199,7 +191,7 @@ int HeatMapSimCommand::execute(){
                lookup = input->getSharedRAbundVectors();
                string lastLabel = lookup[0]->getLabel();
                
-               if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0;}
+               if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups.  I cannot run the command."); 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;
@@ -212,7 +204,7 @@ int HeatMapSimCommand::execute(){
                
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
        
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                heatmap->getPic(lookup, heatCalculators);
                                        
                                processedLabels.insert(lookup[0]->getLabel());
@@ -225,7 +217,7 @@ int HeatMapSimCommand::execute(){
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                lookup = input->getSharedRAbundVectors(lastLabel);                              
 
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                heatmap->getPic(lookup, heatCalculators);
                                        
                                processedLabels.insert(lookup[0]->getLabel());
@@ -246,12 +238,12 @@ int HeatMapSimCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel<< "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -260,7 +252,7 @@ int HeatMapSimCommand::execute(){
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors(lastLabel);                              
 
-                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        heatmap->getPic(lookup, heatCalculators);
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
@@ -272,13 +264,9 @@ int HeatMapSimCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "HeatMapSimCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the HeatMapSimCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
index 93def59137b8ecadb3e45b26ff3fac35bc976405..47fb72ad6e561f35b74e210c3a715561dc78a398 100644 (file)
@@ -14,7 +14,7 @@
 HelpCommand::HelpCommand(string option){
 
        
-       if (option != "") { cout << "There are no valid parameters for the help() command." << endl;  }
+       if (option != "") { mothurOut("There are no valid parameters for the help() command."); mothurOutEndLine();  }
        
        validCommands = new CommandFactory();
 }
@@ -28,11 +28,11 @@ HelpCommand::~HelpCommand(){}
 int HelpCommand::execute(){
 
        validCommands->printCommands(cout);
-       cout << "For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'" << endl;
+       mothurOut("For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'"); mothurOutEndLine();
        
        delete validCommands;
        
-       cout << endl << "For further assistance please refer to the Mothur manual on our wiki at http://schloss.micro.umass.edu/mothur/, or contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+       mothurOutEndLine(); mothurOut("For further assistance please refer to the Mothur manual on our wiki at http://schloss.micro.umass.edu/mothur/, or contact Pat Schloss at pschloss@microbio.umass.edu.\n");
        return 0;
 }
 
index c2f4e4e63347ce62b818617fd4e05da629a84972..cbf44ed11a96a03c251fcc3025b185c2020c2830 100644 (file)
@@ -52,13 +52,9 @@ InputData::InputData(string fName, string orderFileName, string f) : format(f){
                openInputFile(fName, fileHandle);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "InputData");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -77,13 +73,9 @@ ListVector* InputData::getListVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -119,13 +111,9 @@ ListVector* InputData::getListVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -146,13 +134,9 @@ SharedListVector* InputData::getSharedListVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -188,13 +172,9 @@ SharedListVector* InputData::getSharedListVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -216,13 +196,9 @@ SharedOrderVector* InputData::getSharedOrderVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -259,13 +235,9 @@ SharedOrderVector* InputData::getSharedOrderVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -302,13 +274,9 @@ OrderVector* InputData::getOrderVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -409,13 +377,9 @@ OrderVector* InputData::getOrderVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -443,13 +407,9 @@ vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedRAbundVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
@@ -505,13 +465,9 @@ vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSharedRAbundVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -548,13 +504,9 @@ SAbundVector* InputData::getSAbundVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 SAbundVector* InputData::getSAbundVector(string label){
@@ -654,13 +606,9 @@ SAbundVector* InputData::getSAbundVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -695,13 +643,9 @@ RAbundVector* InputData::getRAbundVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 RAbundVector* InputData::getRAbundVector(string label){
@@ -800,13 +744,9 @@ RAbundVector* InputData::getRAbundVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "InputData", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index a166eb4785984d23a6c5949b93db2d3d73cbe3a1..1082465756916c6bebca1e74114f6989ed14ac33 100644 (file)
@@ -25,13 +25,9 @@ void Jackknife::getAMatrix(void){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Jackknife class Function getAMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Jackknife", "getAMatrix");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Jackknife class function getAMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /**************************************************************************************************/
@@ -57,13 +53,9 @@ double Jackknife::CN(double z){
                return n;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Jackknife class Function CN. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Jackknife", "CN");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Jackknife class function CN. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -152,13 +144,9 @@ EstOutput Jackknife::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Jackknife class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Jackknife", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Jackknife class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 40cc1f6612504aef61f24dff4830611fa770727a..0ec822f763feb3869a3afe63fecd78a71dec3e82 100644 (file)
@@ -40,14 +40,14 @@ KmerDB::KmerDB(string fastaFileName, int kSize) : Database(fastaFileName), kmerS
        kmerLocations.resize(maxKmer+1);
        
        if(!kmerFileTest){              //      if we can open the kmer db file, then read it in...
-               cout << "Generating the " << kmerDBName << " database...\t";    cout.flush();
+               mothurOut("Generating the " + kmerDBName + " database...\t");   cout.flush();
                generateKmerDB(kmerDBName);     
        }
        else{                                   //      ...otherwise generate it.
-               cout << "Reading in the " << kmerDBName << " database...\t";    cout.flush();
+               mothurOut("Reading in the " + kmerDBName + " database...\t");   cout.flush();
                readKmerDB(kmerDBName, kmerFileTest);
        }
-       cout << "DONE." << endl << endl;        cout.flush();
+       mothurOut("DONE."); mothurOutEndLine(); mothurOutEndLine(); cout.flush();
 
 }
 /**************************************************************************************************/
index b7e5f27007f4fe33fd2e4d43ff8ea50a2399c130..002cd52d2aff36d8ac70d4ed9b919d8a8d0a2033 100644 (file)
@@ -24,14 +24,9 @@ Libshuff::Libshuff(FullMatrix* D, int it, float step, float co) : matrix(D), ite
                initializeGroups(matrix);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Libshuff class Function Libshuff. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Libshuff", "Libshuff");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Libshuff class function Libshuff. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /***********************************************************************/
@@ -54,14 +49,9 @@ void Libshuff::initializeGroups(FullMatrix* matrix){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Libshuff class Function initializeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Libshuff", "initializeGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Libshuff class function initializeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /***********************************************************************/
@@ -87,14 +77,9 @@ vector<double> Libshuff::getMinX(int x){
                return minX;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Libshuff class Function getMinX. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Libshuff", "getMinX");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Libshuff class function getMinX. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /***********************************************************************/
@@ -113,13 +98,9 @@ vector<double> Libshuff::getMinXY(int x, int y){
                return minXY;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Libshuff class Function getMinXY. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Libshuff", "getMinXY");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Libshuff class function getMinXY. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -143,13 +124,9 @@ void Libshuff::randomizeGroups(int x, int y){
                for(int k=0;k<groupSizes[y];k++)        {       groups[y][k]=v[index++];        }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Libshuff class Function randomizeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Libshuff", "randomizeGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Libshuff class function randomizeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index fd4139100bf3155fd3d9bfb1020e03d5c9056b7c..73c0a74f050a99a42f41dcce4ad18594e8621cc4 100644 (file)
@@ -48,7 +48,7 @@ LibShuffCommand::LibShuffCommand(string option){
                        
                        //make sure the user has already run the read.dist command
                        if ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL)) {
-                               cout << "You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. " << endl; abort = true;; 
+                               mothurOut("You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. "); mothurOutEndLine(); abort = true;; 
                        }
                                                
                        //check for optional parameter and set defaults
@@ -90,39 +90,30 @@ LibShuffCommand::LibShuffCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function LibShuffCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "LibShuffCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function LibShuffCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void LibShuffCommand::help(){
        try {
-               cout << "The libshuff command can only be executed after a successful read.dist command including a groupfile." << "\n";
-               cout << "The libshuff command parameters are groups, iters, step, form and cutoff.  No parameters are required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The step parameter allows you to specify change in distance you would like between each output if you are using the discrete form." << "\n";
-               cout << "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";
-               cout << "The libshuff command should be in the following format: libshuff(groups=yourGroups, iters=yourIters, cutOff=yourCutOff, form=yourForm, step=yourStep)." << "\n";
-               cout << "Example libshuff(groups=A-B-C, iters=500, form=discrete, step=0.01, cutOff=2.0)." << "\n";
-               cout << "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";
-               cout << "The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -158,7 +149,7 @@ int LibShuffCommand::execute(){
                reading->finish();
                delete reading;
 
-               cout << endl;
+               mothurOutEndLine();
                printSummaryFile();
                printCoverageFile();
                
@@ -172,13 +163,9 @@ int LibShuffCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -190,7 +177,7 @@ void LibShuffCommand::printCoverageFile() {
                summaryFile = getRootName(globaldata->getPhylipFile()) + "libshuff.coverage";
                openOutputFile(summaryFile, outCov);
                outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
+               //cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
                
                map<double,vector<int> > allDistances;
                map<double,vector<int> >::iterator it;
@@ -216,7 +203,7 @@ void LibShuffCommand::printCoverageFile() {
                }
                it=allDistances.begin();
                
-               cout << setprecision(8);
+               //cout << setprecision(8);
 
                vector<int> prevRow = it->second;
                it++;
@@ -259,13 +246,9 @@ void LibShuffCommand::printCoverageFile() {
                outCov.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function printCoverageFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "printCoverageFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function printCoverageFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 } 
 
 //**********************************************************************************************************************
@@ -281,6 +264,7 @@ void LibShuffCommand::printSummaryFile() {
                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();
                outSum << setw(20) << left << "Comparison" << '\t' << setprecision(8) << "dCXYScore" << '\t' << "Significance" << endl;
        
                int precision = (int)log10(iters);
@@ -288,18 +272,22 @@ void LibShuffCommand::printSummaryFile() {
                        for(int j=i+1;j<numGroups;j++){
                                if(pValueCounts[i][j]){
                                        cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[i][j] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
+                                       mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[i][j]) + "\t" + toString((pValueCounts[i][j]/(float)iters))); mothurOutEndLine();
                                        outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[i][j] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
                                }
                                else{
                                        cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[i][j] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
+                                       mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[i][j]) + "\t" + toString((1/(float)iters))); mothurOutEndLine();
                                        outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[i][j] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
                                }
                                if(pValueCounts[j][i]){
                                        cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[j][i] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
+                                       mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[j][i]) + "\t" + toString((pValueCounts[j][i]/(float)iters))); mothurOutEndLine();
                                        outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[j][i] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
                                }
                                else{
                                        cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[j][i] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
+                                       mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[j][i]) + "\t" + toString((1/(float)iters))); mothurOutEndLine();
                                        outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[j][i] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
                                }
                        }
@@ -308,13 +296,9 @@ void LibShuffCommand::printSummaryFile() {
                outSum.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function printSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "printSummaryFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function printSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 } 
 
 //**********************************************************************************************************************
@@ -332,7 +316,7 @@ void LibShuffCommand::setGroups() {
                                //check that groups are valid
                                for (int i = 0; i < globaldata->Groups.size(); i++) {
                                        if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
-                                               cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
+                                               mothurOut(globaldata->Groups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
                                                // erase the invalid group from globaldata->Groups
                                                globaldata->Groups.erase(globaldata->Groups.begin()+i);
                                        }
@@ -344,7 +328,7 @@ void LibShuffCommand::setGroups() {
                                        for (int i=0; i < numGroups; i++) { 
                                                globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
                                        }
-                                       cout << "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." << endl; 
+                                       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();
                                } else { numGroups = globaldata->Groups.size(); }
                        } else { //users wants all groups
                                numGroups = globaldata->gGroupmap->getNumGroups();
@@ -363,20 +347,9 @@ void LibShuffCommand::setGroups() {
 
                groupNames = globaldata->Groups;
 
-               // number of comparisons i.e. with groups A,B,C = AA, AB, AC, BA, BB, BC...;
-//             for (int i=0; i<numGroups; i++) { 
-//                     for (int l = 0; l < numGroups; l++) {
-//                             //set group comparison labels
-//                             groupComb.push_back(globaldata->Groups[i] + "-" + globaldata->Groups[l]);
-//                     }
-//             }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the LibShuffCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LibShuffCommand", "setGroups");
                exit(1);
        }
 }
index 4b21d5f40fbda188902c85380a8509554e419de8..6e008074a86dd849261401e45deb26fbcb506bc7 100644 (file)
@@ -36,11 +36,7 @@ ListVector::ListVector(string id, vector<string> lv) : DataVector(id), data(lv){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function ListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function ListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "ListVector");
                exit(1);
        }
 }
@@ -61,11 +57,7 @@ ListVector::ListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numS
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function ListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function ListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "ListVector");
                exit(1);
        }
 }
@@ -85,11 +77,7 @@ void ListVector::set(int binNumber, string seqNames){
                numSeqs += (nNames_new - nNames_old);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "set");
                exit(1);
        }
 }
@@ -114,11 +102,7 @@ void ListVector::push_back(string seqNames){
                numSeqs += nNames;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "push_back");
                exit(1);
        }
 }
@@ -158,11 +142,7 @@ void ListVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "print");
                exit(1);
        }
 }
@@ -193,11 +173,7 @@ RAbundVector ListVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "getRAbundVector");
                exit(1);
        }
 }
@@ -218,11 +194,7 @@ SAbundVector ListVector::getSAbundVector(){
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "getSAbundVector");
                exit(1);
        }
 }
@@ -264,7 +236,7 @@ OrderVector ListVector::getOrderVector(map<string,int>* orderMap = NULL){
                                        }
                                        else{
                                                if(orderMap->count(seqName) == 0){
-                                                       cerr << seqName << " not found, check *.names file\n";
+                                                       mothurOut(seqName + " not found, check *.names file\n");
                                                        exit(1);
                                                }
                                        
@@ -274,7 +246,7 @@ OrderVector ListVector::getOrderVector(map<string,int>* orderMap = NULL){
                                }
                        
                                if(orderMap->count(seqName) == 0){
-                                       cerr << seqName << " not found, check *.names file\n";
+                                       mothurOut(seqName + " not found, check *.names file\n");
                                        exit(1);
                                }
                                ov.set((*orderMap)[seqName], i);        
@@ -287,11 +259,7 @@ OrderVector ListVector::getOrderVector(map<string,int>* orderMap = NULL){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ListVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ListVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ListVector", "getOrderVector");
                exit(1);
        }
 }
index 782af2a5dc0514c838a0be217d44fab1ceffdecd..62faf8eab68c726f9499451ec3207fc66ae2cbd2 100644 (file)
--- a/logsd.cpp
+++ b/logsd.cpp
@@ -74,13 +74,6 @@ EstOutput LogSD::getValues(SAbundVector* rank){
                                maxDiff = diff;
                }
 
-
-               /*cout << "LogSD:\n";
-               cout << "D Test Statistic = " << DStatistic << "\n";
-               cout << ".05 confidence value = " << .89196/sqrt(numSpec) << "\n";
-               cout << "If D Test Statistic is greater than the critical value then the data fits the Log Series Distribution model w/ 95% confidence.\n\n";*/
-               
-
                data[0] = (maxDiff + .5)/numSpec;
                data[1] = 0.886/sqrt(numSpec);
                data[2] = 1.031/sqrt(numSpec);
@@ -92,13 +85,9 @@ EstOutput LogSD::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LogSD class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "LogSD", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the LogSD class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index e8fb553e42a3ca655b2e8b063c359d7cad4968f9..64ec2a5f6440f23f7beef0e11c0be73560523114 100644 (file)
@@ -52,8 +52,8 @@ MatrixOutputCommand::MatrixOutputCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the dist.shared command." << endl; abort = true; }
-                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the dist.shared command." << endl; abort = true; }
+                               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; }
                        }
                        
                        //check for optional parameter and set defaults
@@ -73,7 +73,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -131,39 +131,31 @@ MatrixOutputCommand::MatrixOutputCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MatrixOutputCommand class Function MatrixOutputCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MatrixOutputCommand class function MatrixOutputCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void MatrixOutputCommand::help(){
        try {
-               cout << "The dist.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The dist.shared command parameters are groups, calc, line and label.  The calc parameter is required, and you may not use line and label at the same time." << "\n";
-               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like distance matrices created for, and are also separated by dashes." << "\n";
-               cout << "The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example dist.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorabund)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
-               cout << "The default value for calc is jclass and thetayc." << "\n";
+               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, line and label.  The calc parameter is required, and you may not use line and label at the same time.\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 line and label allow you to select what distance levels you would like distance matrices created for, and are also separated by dashes.\n");
+               mothurOut("The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example dist.shared(groups=A-B-C, line=1-3-5, 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");
                validCalculator->printCalc("matrix", cout);
-               cout << "The dist.shared command outputs a .dist file for each calculator you specify at each distance you choose." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MatrixOutputCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MatrixOutputCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MatrixOutputCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -187,7 +179,7 @@ int MatrixOutputCommand::execute(){
                int count = 1;  
                                
                //if the users entered no valid calculators don't execute command
-               if (matrixCalculators.size() == 0) { cout << "No valid calculators." << endl; return 0; }
+               if (matrixCalculators.size() == 0) { mothurOut("No valid calculators."); mothurOutEndLine();  return 0; }
 
                //you have groups
                read = new ReadOTUFile(globaldata->inputFileName);      
@@ -202,7 +194,7 @@ int MatrixOutputCommand::execute(){
                set<string> userLabels = labels;
                set<int> userLines = lines;
                                
-               if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0;}
+               if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups.  I cannot run the command."); mothurOutEndLine(); return 0;}
                
                numGroups = lookup.size();
                                
@@ -210,7 +202,7 @@ int MatrixOutputCommand::execute(){
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -223,7 +215,7 @@ int MatrixOutputCommand::execute(){
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                lookup = input->getSharedRAbundVectors(lastLabel);
 
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -243,12 +235,12 @@ int MatrixOutputCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it; 
+                       mothurOut("Your file does not include the label " + *it);  
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -257,7 +249,7 @@ int MatrixOutputCommand::execute(){
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        process(lookup);
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
@@ -269,13 +261,9 @@ int MatrixOutputCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MatrixOutputCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MatrixOutputCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MatrixOutputCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 void MatrixOutputCommand::printSims(ostream& out) {
@@ -294,13 +282,9 @@ void MatrixOutputCommand::printSims(ostream& out) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MatrixOutputCommand class Function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MatrixOutputCommand", "printSims");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MatrixOutputCommand class function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 void MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
@@ -349,13 +333,9 @@ void MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MatrixOutputCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MatrixOutputCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MatrixOutputCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 
index 497d535e4810fac221b6ae399d59a7b1ff457d46..44cb03d64a3593aed5b408455be46e0b20da4a4f 100644 (file)
@@ -35,13 +35,13 @@ MergeFileCommand::MergeFileCommand(string option){
                        }
                        
                        string fileList = validParameter.validFile(parameters, "input", false);                 
-                       if(fileList == "not found") { cout << "you must enter two or more file names" << endl;  abort=true;  }
+                       if(fileList == "not found") { mothurOut("you must enter two or more file names"); mothurOutEndLine();  abort=true;  }
                        else{   splitAtDash(fileList, fileNames);       }
                        
                        numInputFiles = fileNames.size();
                        ifstream testFile;
                        if(numInputFiles == 0){
-                               cout << "you must enter two or more file names and you entered " << fileNames.size() <<  " file names" << endl;
+                               mothurOut("you must enter two or more file names and you entered " + toString(fileNames.size()) +  " file names"); mothurOutEndLine();
                                abort=true;  
                        }
                        else{
@@ -52,18 +52,14 @@ MergeFileCommand::MergeFileCommand(string option){
                        }   
                        
                        outputFileName = validParameter.validFile(parameters, "output", false);                 
-                       if (outputFileName == "not found") { cout << "you must enter an output file name" << endl;  abort=true;  }
+                       if (outputFileName == "not found") { mothurOut("you must enter an output file name"); mothurOutEndLine();  abort=true;  }
                }
                        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MergeFileCommand class Function MergeFileCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MergeFileCommand", "MergeFileCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MergeFileCommand class function MergeFileCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -93,31 +89,21 @@ int MergeFileCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BinSeqCommand class Function BinSeqCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MergeFileCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BinSeqCommand class function BinSeqCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 //**********************************************************************************************************************
 
 void MergeFileCommand::help(){
        try {
-               cout << "The merge.file command..." << endl;
+               mothurOut("The merge.file command..."); mothurOutEndLine();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MergeFileCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MergeFileCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MergeFileCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 //**********************************************************************************************************************
index 59837dd72d7dc8dbe76ee3125052461a9e7b580a..0314331287f0de7c466dc5cb4aacedece62fd56a 100644 (file)
@@ -44,11 +44,7 @@ int main(int argc, char *argv[]){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the dotur class Function main. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the dotur class function main. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "main");
                exit(1);
        }
 }
index e5d1113790decbacf45913e7d6ce11d2826de598..20d3b4b64725d0428248b47b22a3146a0a3a52c9 100644 (file)
--- a/mothur.h
+++ b/mothur.h
@@ -117,7 +117,7 @@ inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
        char c;
        if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
        {
-               cout << "'" << s << "' is unable to be converted into an integer.\n";
+               cout << "unable to be converted into an integer.\n" << endl;
                return false;
        } 
        return true;
@@ -154,6 +154,90 @@ string toString(const T&x, int i){
     return output.str();
 }
 
+/***********************************************************************/
+
+inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
+       
+       fileHandle.open(fileName.c_str(), ios::app);
+       if(!fileHandle) {
+               cerr << "Error: Could not open " << fileName << endl;
+               return 1;
+       }
+       else {
+               return 0;
+       }
+
+}
+
+
+/**************************************************************************************************/
+
+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 pschloss@microbio.umass.edu, and be sure to include the mothur.logFile with your inquiry.");
+               mothurOutEndLine();
+       
+}
+
 
 /***********************************************************************/
 
@@ -333,21 +417,6 @@ inline int openOutputFile(string fileName, ofstream& fileHandle){
        }
 
 }
-/***********************************************************************/
-
-inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
-       
-       fileHandle.open(fileName.c_str(), ios::app);
-       if(!fileHandle) {
-               cerr << "Error: Could not open " << fileName << endl;
-               return 1;
-       }
-       else {
-               return 0;
-       }
-
-}
-
 
 /***********************************************************************/
 
@@ -377,14 +446,9 @@ inline void splitAtDash(string& estim, vector<string>& container) {
                container.push_back(estim);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtDash");
                exit(1);
        }
-
 }
 
 /***********************************************************************/
@@ -404,14 +468,9 @@ inline void splitAtDash(string& estim, set<string>& container) {
                container.insert(estim);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtDash");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 /***********************************************************************/
 //This function parses the line options and puts them in a set
@@ -433,14 +492,9 @@ inline void splitAtDash(string& estim, set<int>& container) {
                container.insert(lineNum);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtDash");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 /***********************************************************************/
 //This function parses the a string and puts peices in a vector
@@ -459,11 +513,7 @@ inline void splitAtComma(string& estim, vector<string>& container) {
                container.push_back(estim);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtComma");
                exit(1);
        }
 }
@@ -482,14 +532,9 @@ inline void splitAtComma(string& prefix, string& suffix){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtComma");
                exit(1);
        }
-
 }
 /***********************************************************************/
 
@@ -507,14 +552,9 @@ inline void splitAtEquals(string& key, string& value){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "splitAtEquals");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 /**************************************************************************************************/
 
@@ -526,11 +566,62 @@ inline bool inUsersGroups(string groupname, vector<string> Groups) {
                return false;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "inUsersGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+
+/**************************************************************************************************/
+
+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");
+               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);
        }
 }
@@ -564,7 +655,7 @@ inline bool anyLabelsToProcess(string label, set<string>& userLabels, string err
                                orderFloat.push_back(-1.0);
                                userMap["unique"] = -1.0;
                        }else {
-                               if (errorOff == "") {  cout << *it << " is not a valid label." << endl;  }
+                               if (errorOff == "") {  mothurOut(*it + " is not a valid label."); mothurOutEndLine();  }
                                userLabels.erase(*it); 
                                it--;
                        }
@@ -582,11 +673,11 @@ inline bool anyLabelsToProcess(string label, set<string>& userLabels, string err
                        if (orderFloat[i] < labelFloat) {
                                smaller = true;
                                if (orderFloat[i] == -1) { 
-                                       if (errorOff == "") { cout << "Your file does not include the label unique." <<  endl; }
+                                       if (errorOff == "") { mothurOut("Your file does not include the label unique."); mothurOutEndLine(); }
                                        userLabels.erase("unique");
                                }
                                else {  
-                                       if (errorOff == "") { cout << "Your file does not include the label "; }
+                                       if (errorOff == "") { mothurOut("Your file does not include the label "); mothurOutEndLine(); }
                                        string s = "";
                                        for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {  
                                                if (it2->second == orderFloat[i]) {  
@@ -596,7 +687,7 @@ inline bool anyLabelsToProcess(string label, set<string>& userLabels, string err
                                                        break;
                                                }
                                        }
-                                       if (errorOff == "") { cout << s << ". I will use the next smallest distance. "  <<  endl; }
+                                       if (errorOff == "") { mothurOut(s + ". I will use the next smallest distance. "); mothurOutEndLine(); }
                                }
                        //since they are sorted once you find a bigger one stop looking
                        }else { break; }
@@ -606,14 +697,9 @@ inline bool anyLabelsToProcess(string label, set<string>& userLabels, string err
                                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function anyLabelsToProcess. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "anyLabelsToProcess");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the mothur class function anyLabelsToProcess. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /**************************************************************************************************/
index cf4e6774c32706d506d472963bda6f9ac86df7f1..3bcf6f9a968762adede9a4bd434320855b1e2398 100644 (file)
@@ -33,19 +33,9 @@ void NameAssignment::readMap(){
                }
                fileHandle.close();
        
-//             map<string, string>::iterator it = data.begin();
-//             for(it;it!=data.end();it++){
-//                     cout << it->first << endl;
-//                     (*this)[it->first] = rowIndex;
-//                     rowIndex++;
-//             }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the NameAssignment class Function readMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the NameAssignment class function readMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "NameAssignment", "readMap");
                exit(1);
        }
 }
@@ -64,15 +54,11 @@ void NameAssignment::print(void){
        try {
                map<string,int>::iterator it = (*this).begin();
                for(it;it!=(*this).end();it++){
-                       cout << it->first << '\t' << it->second << endl;  //prints out keys and values of the map this.
+                       mothurOut(it->first + "\t" + toString(it->second)); mothurOutEndLine();  //prints out keys and values of the map this.
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the NameAssignment class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the NameAssignment class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "NameAssignment", "print");
                exit(1);
        }
 }
index 2d3db22b08c66de9798128292dfe7be149bdc50f..0741ccd7ad444a250fa1dec5b23790771142a99c 100644 (file)
--- a/nast.cpp
+++ b/nast.cpp
@@ -82,7 +82,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                //      Part C of Fig. 2 from DeSantis et al.
                if((isalpha(newTemplateAlign[i]) != isalpha(tempAln[i]))){      //if there is a discrepancy between the regapped
                        
-//                     cout << i << '\t';cout.flush();
+
                        
                        //      Part D of Fig. 2 from DeSantis et al.           //      template sequence and the official template sequence
                        for(leftIndex=i-1;leftIndex>=0;leftIndex--){    //      then we've got problems...
@@ -92,7 +92,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                        break;
                                }
                        }
-//                     cout << leftIndex << '\t' << leftRoom << endl;
+
                        
                        for(rightIndex=i+1;rightIndex<longAlignmentLength;rightIndex++){
                                if(!isalpha(candAln[rightIndex])){
@@ -173,7 +173,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                        i -= insertLength;
                } 
        }
-//     cout << candAln << endl << tempAln << endl << newTemplateAlign << endl;
+
 }
 
 /**************************************************************************************************/
@@ -273,14 +273,14 @@ void Nast::regapSequences(){      //This is essentially part B in Fig 2. of DeSantis
                        //      would skip the gaps and not progress through full alignment sequence
                        //      not tested yet
                        
-                       cout << "We're into D" << ' ' << fullAlignIndex << ' ' << pairwiseAlignIndex <<  endl;
+                       mothurOut("We're into D " + toString(fullAlignIndex) + " " +  toString(pairwiseAlignIndex)); mothurOutEndLine();
                        pairwiseAlignIndex++;
                }
                else{
                        //      everything has a gap - not possible
                        //      not tested yet
                        
-                       cout << "We're into F" << ' ' << fullAlignIndex << ' ' << pairwiseAlignIndex <<  endl;
+                       mothurOut("We're into F " +  toString(fullAlignIndex) + " " +  toString(pairwiseAlignIndex)); mothurOutEndLine();
                        pairwiseAlignIndex++;
                        fullAlignIndex++;                       
                }               
@@ -306,17 +306,11 @@ void Nast::regapSequences(){      //This is essentially part B in Fig 2. of DeSantis
                candAln[i] = toupper(candAln[i]);                       //      everything is upper case
        }
 
-//     cout << candAln << endl;
-//     cout << tempAln << endl;
-//     cout << newTemplateAlign << endl;
 
        if(candAln.length() != tempAln.length()){               //      if the regapped candidate sequence is longer than the official
                removeExtraGaps(candAln, tempAln, newTemplateAlign);//  template alignment then we need to do steps C-F in Fig.
        }                                                                                               //      2 of Desantis et al.
        
-//     cout << candAln << endl;
-//     cout << tempAln << endl;
-//     cout << newTemplateAlign << endl;
 
        candidateSeq->setAligned(candAln);
 }
index 18a294801c961b7294bcf3985e733798cfe4d77a..5cf5a56f8161da1fa81fa3c371900fb2d806b626 100644 (file)
@@ -21,7 +21,7 @@ NoCommand::~NoCommand(){}
 
 int NoCommand::execute(){
        //Could choose to give more help here?fdsah
-       cout << "Invalid command." << "\n";
+       mothurOut("Invalid command.\n");
        
        CommandFactory* valid = new CommandFactory();
        valid->printCommands(cout);
index 73dd834748cedde6b6c12333f02f682b487bc7e5..fda649cda2ecd9b6d4c00e4baab3c0f052bd80ad 100644 (file)
@@ -28,7 +28,6 @@ EstOutput NPShannon::getValues(SAbundVector* rank){
                                double ChatPi = Chat*pi;
                                if(ChatPi>0){
                                        npShannon += rank->get(i) * ChatPi*log(ChatPi)/(1-pow(1-ChatPi,(double)sampled));
-                                       //cout << ChatPi << '\t' << rank->get(i) * ChatPi*log(ChatPi)/(1-pow(1-ChatPi,(double)sampled)) << endl;
                                }
                        }
                        npShannon = -npShannon;
@@ -44,13 +43,9 @@ EstOutput NPShannon::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the NPShannon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "NPShannon", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the NPShannon class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 2de1621bcb9a73ac9c17b02384ee6d9b0f3f5d49..8f0e29d2deee52f5996da965f12e58dc66572d95 100644 (file)
@@ -30,11 +30,7 @@ OptionParser::OptionParser(string option) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OptionParser class Function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the OptionParser class function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OptionParser", "parse");
                exit(1);
        }
 }
index e3062059acef0678300a8642f7432a34d7410879..360c898259f8742446c3488289cf4231221c0703 100644 (file)
@@ -47,11 +47,7 @@ OrderVector::OrderVector(ifstream& f) : DataVector() {
                updateStats();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OrderVector class Function OrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the OrderVector class function OrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OrderVector", "OrderVector");
                exit(1);
        }
 }
@@ -116,11 +112,7 @@ void OrderVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OrderVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the OrderVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OrderVector", "print");
                exit(1);
        }
 }
@@ -137,19 +129,15 @@ void OrderVector::print(string prefix, ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OrderVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OrderVector", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OrderVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
 
 void OrderVector::resize(int){
-       cout << "resize() did nothing in class OrderVector";
+       mothurOut("resize() did nothing in class OrderVector");
 }
 
 /***********************************************************************/
@@ -191,13 +179,9 @@ RAbundVector OrderVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OrderVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OrderVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OrderVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -244,13 +228,9 @@ void OrderVector::updateStats(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the OrderVector class Function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "OrderVector", "updateStats");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the OrderVector class function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 8173bdc3086ccd5cc88da03aabef294411d98f07..0fdcf9ad2dd3e76ed04630096895cf9c81385d81 100644 (file)
@@ -35,20 +35,15 @@ ParseListCommand::ParseListCommand(){
                
                //clears file before we start to write to it below
                for (int i=0; i<groupMap->getNumGroups(); i++) {
-                       openOutputFile(fileroot + groupMap->namesOfGroups[i] + ".list", *(filehandles[groupMap->namesOfGroups[i]]));
-                       (*(filehandles[groupMap->namesOfGroups[i]])).close();
+                       remove((fileroot + groupMap->namesOfGroups[i] + ".list").c_str());
                }
-
-               
+       
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParseListCommand class Function ParseListCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParseListCommand class function ParseListCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParseListCommand", "ParseListCommand");
                exit(1);
        }
+       
 }
 /***********************************************************************/
 void ParseListCommand::parse(int index, SharedListVector* list) {
@@ -66,7 +61,7 @@ void ParseListCommand::parse(int index, SharedListVector* list) {
                        if (groupName != "not found") {
                                listGroups[groupName] = listGroups[groupName] + "," + member; //adds prefix to the correct group.
                        }else {
-                               cerr << "Error: Sequence '" << member << "' was not found in the group file, please correct\n";
+                               mothurOut("Error: Sequence '" + toString(member) + "' was not found in the group file, please correct\n");
                        }
                }
                
@@ -75,15 +70,11 @@ void ParseListCommand::parse(int index, SharedListVector* list) {
                if (groupName != "not found") {
                        listGroups[groupName] = listGroups[groupName] + "," + bin; //adds prefix to the correct group.
                }else {
-                       cerr << "Error: Sequence '" << bin << "' was not found in the group file, please correct\n";
+                       mothurOut("Error: Sequence '" + toString(bin) + "' was not found in the group file, please correct\n");
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParseListCommand class Function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParseListCommand class function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParseListCommand", "parse");
                exit(1);
        }
 }
@@ -100,19 +91,19 @@ int ParseListCommand::execute(){
                        read->read(&*globaldata); 
                        input = globaldata->ginput;
                        list = globaldata->gSharedList;
-                       SharedListVector* lastList = list;
+                       string lastLabel = list->getLabel();
                
                        //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                        set<string> processedLabels;
                        set<string> userLabels = globaldata->labels;
                        set<int> userLines = globaldata->lines;
-                       
+               
                        //parses and sets each groups listvector
                        //as long as you are not at the end of the file or done wih the lines you want
                        while((list != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                                                                
-                               if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(list->getLabel()) == 1){
-                                       cout << list->getLabel() << '\t' << count << endl;
+                               if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lastLabel) == 1){
+                                       mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        process(list);
                                        
                                        processedLabels.insert(list->getLabel());
@@ -120,17 +111,21 @@ int ParseListCommand::execute(){
                                        userLines.erase(count);
                                }
                                
-                               if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
-                                       cout << lastList->getLabel() << '\t' << count << endl;
-                                       process(lastList);
+                               if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete list;
+                                       list = input->getSharedListVector(lastLabel);
                                        
-                                       processedLabels.insert(lastList->getLabel());
-                                       userLabels.erase(lastList->getLabel());
+                                       mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
+                                       process(list);
+                                       
+                                       processedLabels.insert(list->getLabel());
+                                       userLabels.erase(list->getLabel());
                                }
 
-                               if (count != 1) { delete lastList; }
-                               lastList = list;                        
-
+                               
+                               lastLabel = list->getLabel();                   
+                               
+                               delete list;
                                list = input->getSharedListVector();
                                count++;
                        }
@@ -139,22 +134,26 @@ int ParseListCommand::execute(){
                        set<string>::iterator it;
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               cout << "Your file does not include the label "<< *it
-                               if (processedLabels.count(lastList->getLabel()) != 1) {
-                                       cout << ". I will use " << lastList->getLabel() << "." << endl;
+                               mothurOut("Your file does not include the label " + *it)
+                               if (processedLabels.count(lastLabel) != 1) {
+                                       mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastList->getLabel() << "." << endl;
+                                       mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastList->getLabel() << '\t' << count << endl;
-                               process(lastList);
+                               delete list;
+                               list = input->getSharedListVector(lastLabel);
+                                       
+                               mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
+                               process(list);
+                               delete list;
                        }
                        
-                       delete lastList;  globaldata->gSharedList = NULL;
+                       globaldata->gSharedList = NULL;
                        //delete list vectors to fill with parsed data
                        for (it2 = mapOfLists.begin(); it2 != mapOfLists.end(); it2++) {
                                delete it2->second;
@@ -170,14 +169,9 @@ int ParseListCommand::execute(){
                        return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParseListCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParseListCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParseListCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 //**********************************************************************************************************************
 
@@ -210,11 +204,7 @@ void ParseListCommand::process(SharedListVector* thisList) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParseListCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParseListCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParseListCommand", "process");
                exit(1);
        }
 }
index 9a8706e82499fb80f9c2a55d61bc92c7b2399839..db6ed1d862d4ee3d9a4037b672ee63cdcacd03a6 100644 (file)
@@ -91,7 +91,6 @@ EstOutput Parsimony::getValues(Tree* t) {
                
                        //create pgroups that reflect the groups the user want to use
                        for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
-//                             cout << i << "..." << endl;
                                copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
                        }
                
@@ -105,13 +104,6 @@ EstOutput Parsimony::getValues(Tree* t) {
                                int rcSize = copyTree->tree[rc].pGroups.size();
                                int lcSize = copyTree->tree[lc].pGroups.size();
                                
-//                             cout << i+1 << '\t' << lc+1 << '\t' << rc+1 << ":\t";
-                               
-//                             for(it=copyTree->tree[i].pGroups.begin();it!=copyTree->tree[i].pGroups.end();it++){
-//                                     cout << it->first << '\t';
-//                             }
-                               
-//                             cout << " : " << iSize << '\t' << rcSize << '\t' << lcSize << '\t';
                                        
                                //if isize are 0 then that branch is to be ignored
                                if (iSize == 0) { }
@@ -120,12 +112,10 @@ EstOutput Parsimony::getValues(Tree* t) {
                                else if(iSize > rcSize || iSize > lcSize){
                                        score++;
                                }
-//                             cout << score << endl;
                        } 
                
                        data[count] = score;
-                       string hold;
-//                     cin >> hold;
+
                }
                
                delete copyTree;
@@ -133,14 +123,9 @@ EstOutput Parsimony::getValues(Tree* t) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Parsimony class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Parsimony", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Parsimony class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /**************************************************************************************************/
index 266dd3b9a2ad5c3e7730ac6950e7077164b12bb2..6df2debe877bc0d594949ad3f62249f3912f76eb 100644 (file)
@@ -39,7 +39,7 @@ ParsimonyCommand::ParsimonyCommand(string option) {
                        //are you trying to use parsimony without reading a tree or saying you want random distribution
                        if (randomtree == "")  {
                                if (globaldata->gTree.size() == 0) {
-                                       cout << "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." << endl; abort = true;  }
+                                       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;  }
                        }
                                                
                        //check for optional parameter and set defaults
@@ -85,11 +85,7 @@ ParsimonyCommand::ParsimonyCommand(string option) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function ParsimonyCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function ParsimonyCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
                exit(1);
        }
 }
@@ -98,24 +94,20 @@ ParsimonyCommand::ParsimonyCommand(string option) {
 
 void ParsimonyCommand::help(){
        try {
-               cout << "The parsimony command can only be executed after a successful read.tree command, unless you use the random parameter." << "\n";
-               cout << "The parsimony command parameters are random, groups and iters.  No parameters are required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The parsimony command should be in the following format: parsimony(random=yourOutputFilename, groups=yourGroups, iters=yourIters)." << "\n";
-               cout << "Example parsimony(random=out, iters=500)." << "\n";
-               cout << "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";
-               cout << "and iters is 1000.  The parsimony command output two files: .parsimony and .psummary their descriptions are in the manual." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. random), '=' and parameters (i.e.yourOutputFilename)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -272,11 +264,7 @@ int ParsimonyCommand::execute() {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "execute");
                exit(1);
        }
 }
@@ -309,11 +297,7 @@ void ParsimonyCommand::printParsimonyFile() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function printParsimonyFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function printParsimonyFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "printParsimonyFile");
                exit(1);
        }
 }
@@ -322,7 +306,7 @@ void ParsimonyCommand::printUSummaryFile() {
        try {
                //column headers
                outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "ParsScore" << '\t' << "ParsSig" <<  endl;
-               cout << "Tree#" << '\t' << "Groups" << '\t'  <<  "ParsScore" << '\t' << "ParsSig" <<  endl;
+               mothurOut("Tree#\tGroups\tParsScore\tParsSig"); mothurOutEndLine();
                
                //format output
                outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
@@ -334,9 +318,11 @@ void ParsimonyCommand::printUSummaryFile() {
                                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();
                                }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();
                                }
                        }
                }
@@ -344,11 +330,7 @@ void ParsimonyCommand::printUSummaryFile() {
                outSum.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function printUSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function printUSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "printUSummaryFile");
                exit(1);
        }
 }
@@ -360,16 +342,18 @@ void ParsimonyCommand::getUserInput() {
                //create treemap
                tmap = new TreeMap();
 
-               cout << "Please enter the number of groups you would like to analyze: ";
+               mothurOut("Please enter the number of groups you would like to analyze: ");
                cin >> numGroups;
-                       
+               mothurOutJustToLog(toString(numGroups)); mothurOutEndLine();
+                               
                int num, count;
                count = 1;
                numEachGroup.resize(numGroups, 0);  
                
                for (int i = 1; i <= numGroups; i++) {
-                       cout << "Please enter the number of sequences in group " << i <<  ": ";
+                       mothurOut("Please enter the number of sequences in group " + toString(i) +  ": ");
                        cin >> num;
+                       mothurOutJustToLog(toString(num)); mothurOutEndLine();
                                
                        //set tmaps seqsPerGroup
                        tmap->seqsPerGroup[toString(i)] = num;
@@ -395,11 +379,7 @@ void ParsimonyCommand::getUserInput() {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function getUserInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ParsimonyCommand class function getUserInput. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ParsimonyCommand", "getUserInput");
                exit(1);
        }
 }
index 65c01b934ada20c9a3a294ce2351d515d0eafe5f..6899e76e1940e2408567ce0e7212a7315266f143 100644 (file)
@@ -18,17 +18,13 @@ const char marker = '|';
 
 Progress::Progress(){
        try {
-               cout << "********************#****#****#****#****#****#****#****#****#****#****#";
+               mothurOut("********************#****#****#****#****#****#****#****#****#****#****#");
                
                nTicks = 0;
                finalPos = 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Progress", "Progress");
                exit(1);
        }
 }
@@ -37,19 +33,17 @@ Progress::Progress(){
 
 Progress::Progress(string job, int end){
        try {
-               cout << "********************#****#****#****#****#****#****#****#****#****#****#\n";
+               mothurOut("********************#****#****#****#****#****#****#****#****#****#****#\n");
                cout << setw(20) << left << job << setw(1) << marker;
+               mothurOutJustToLog(job);
+               mothurOut(toString(marker));
                cout.flush();
 
                nTicks = 0;
                finalPos = end;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Progress", "Progress");
                exit(1);
        }
 }
@@ -58,19 +52,17 @@ Progress::Progress(string job, int end){
 
 void Progress::newLine(string job, int end){
        try {
-               cout << endl;
+               mothurOutEndLine();
                cout << setw(20) << left << job << setw(1) << marker;
+               mothurOutJustToLog(job);
+               mothurOut(toString(marker));
                cout.flush();
                
                nTicks = 0;
                finalPos = end;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function newline. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Progress class function newline. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Progress", "newLine");
                exit(1);
        }
 }
@@ -83,18 +75,14 @@ void Progress::update(const int currentPos){
        
                if(ratio > nTicks){
                        for(int i=nTicks;i<ratio;i++){
-                               cout << marker;
+                               mothurOut(toString(marker));
                                cout.flush();
                        }
                        nTicks = ratio;
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Progress class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Progress", "update");
                exit(1);
        }
 }
@@ -104,21 +92,17 @@ void Progress::update(const int currentPos){
 void Progress::finish(){
        try {
                for(int i=nTicks;i<totalTicks;i++){
-                       cout << marker;
+                       mothurOut(toString(marker));
                        cout.flush();
                }
        
        
-               cout << endl;
-               cout << "***********************************************************************\n";
+               mothurOutEndLine();
+               mothurOut("***********************************************************************\n");
                cout.flush();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Progress class function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Progress", "finish");
                exit(1);
        }
 }
index ed4471a8d18b983294bd3824832d093316fe40fa..60e6629b96e1c501a8f3fa2ffabde3fd14fefbb9 100644 (file)
--- a/qstat.cpp
+++ b/qstat.cpp
@@ -52,7 +52,6 @@ EstOutput QStat::getValues(SAbundVector* rank){
                }
                
                double qstat = (.5*r1 + iqSum + .5*r3)/log((double)r3Ind/r1Ind);
-               //cout << "QStat:\nQStatistic = " << qstat << "\n\n";
                
                data[0] = qstat;
                if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
@@ -60,13 +59,9 @@ EstOutput QStat::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the QStat class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "QStat", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the QStat class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 87c2fa0672478e9899c60887ff0aa459f79551ee..99dc46be30ca9c282d82474e5021bdf4fc7f3c33 100644 (file)
@@ -17,24 +17,20 @@ QuitCommand::QuitCommand(string option){
                //allow user to run help
                if(option == "help") { help(); abort = true; }
                
-               else if (option != "") { cout << "There are no valid parameters for the quit command." << endl;  abort = true;  }
+               else if (option != "") { mothurOut("There are no valid parameters for the quit command."); mothurOutEndLine();  abort = true;  }
 
 }
 //**********************************************************************************************************************
 
 void QuitCommand::help(){
        try {
-               cout << "The quit command will terminate mothur and should be in the following format: " << "\n";
-               cout << "quit() or quit" << "\n" << "\n";
+                mothurOut("The quit command will terminate mothur and should be in the following format: \n"); 
+                mothurOut("quit() or quit\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the QuitCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "QuitCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the QuitCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index 471c7e26fa587f5e18dd8a903a31c30c6efc0192..ce04df11ccd769a233ce30bfdf0554f34377d6cd 100644 (file)
@@ -41,11 +41,7 @@ RAbundVector::RAbundVector(string id, vector<int> rav) : DataVector(id), data(ra
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "RAbundVector");
                exit(1);
        }
 }
@@ -60,17 +56,11 @@ RAbundVector::RAbundVector(vector<int> rav, int mr, int nb, int ns) {
                data = rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "RAbundVector");
                exit(1);
        }
 }
 
-
-
 /***********************************************************************/
 
 
@@ -88,11 +78,7 @@ RAbundVector::RAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0),
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "RAbundVector");
                exit(1);
        }
 }
@@ -117,11 +103,7 @@ void RAbundVector::set(int binNumber, int newBinSize){
                numSeqs += (newBinSize - oldBinSize);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "set");
                exit(1);
        }
 }
@@ -147,11 +129,7 @@ void RAbundVector::push_back(int binSize){
                numSeqs += binSize;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "push_back");
                exit(1);
        }
 }
@@ -227,11 +205,7 @@ void RAbundVector::print(string prefix, ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "print");
                exit(1);
        }
 }
@@ -248,11 +222,7 @@ void RAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "print");
                exit(1);
        }
 }
@@ -295,11 +265,7 @@ SAbundVector RAbundVector::getSAbundVector() {
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "getSAbundVector");
                exit(1);
        }
 }
@@ -321,11 +287,7 @@ OrderVector RAbundVector::getOrderVector(map<string,int>* nameMap = NULL) {
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RAbundVector", "getOrderVector");
                exit(1);
        }
 }
index 88c704adfdf01d575ad835e9e04805845b1cf6ff..8f1d3073cf93ace3e42f2f4e3eb7a8515890ea61 100644 (file)
@@ -45,13 +45,9 @@ EstOutput RareCalc::getValues(int n){
                return output;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareCalc class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareCalc", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareCalc class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 61362c78515b1ebaf3e0b006782960bfb33ebb91..b86312bc4411e8cdd2faca9934aab3abf5c96c52 100644 (file)
@@ -24,11 +24,7 @@ void RareDisplay::init(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function init. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareDisplay class function init. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareDisplay", "init");
                exit(1);
        }
 }
@@ -59,11 +55,7 @@ void RareDisplay::update(SAbundVector* rank){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareDisplay class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareDisplay", "update");
                exit(1);
        }
 }
@@ -92,11 +84,7 @@ void RareDisplay::update(vector<SharedRAbundVector*> shared, int numSeqs, int nu
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareDisplay class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareDisplay", "update");
                exit(1);
        }
 }
@@ -119,14 +107,10 @@ void RareDisplay::reset(){
                renameOk = rename(tempOutName.c_str(), tempInName.c_str());     
                
                //checks to make sure user was able to rename and remove successfully
-               if (renameOk != 0) { cout << "Unable to rename the necessary temp files." << endl; }
+               if (renameOk != 0) { mothurOut("Unable to rename the necessary temp files."); mothurOutEndLine(); }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function reset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareDisplay class function reset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareDisplay", "reset");
                exit(1);
        }
 }
@@ -167,11 +151,7 @@ void RareDisplay::close(){
                output->resetFile();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function close. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareDisplay class function close. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareDisplay", "close");
                exit(1);
        }
 }
index 67662496618d427c12363ea5ec120f21578e3f12..f1b43fc26553cd739d32d2baeff36bc457df006a 100644 (file)
@@ -63,11 +63,7 @@ void Rarefact::getCurve(int increment = 1, int nIters = 1000){
                delete rcd;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Rarefact class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Rarefact", "getCurve");
                exit(1);
        }
 }
@@ -128,14 +124,9 @@ try {
                delete rcd;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Rarefact class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Rarefact", "getSharedCurve");
                exit(1);
        }
-
 }
 
 /**************************************************************************************/
@@ -147,12 +138,8 @@ void Rarefact::mergeVectors(SharedRAbundVector* shared1, SharedRAbundVector* sha
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function mergeVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Rarefact", "mergeVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Rarefact class function mergeVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
index 9bb3daa7462368c4fbf9f889847cc4ae1e44c399..ee0c38f4d05de762222c284fb6e94c74569a95e5 100644 (file)
@@ -50,7 +50,7 @@ RareFactCommand::RareFactCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the rarefaction.single command." << endl; abort = true; }
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the rarefaction.single command."); mothurOutEndLine(); abort = true; }
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -69,7 +69,7 @@ RareFactCommand::RareFactCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -134,38 +134,29 @@ RareFactCommand::RareFactCommand(string option){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactCommand", "RareFactCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactCommand class function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 //**********************************************************************************************************************
 
 void RareFactCommand::help(){
        try {
-               cout << "The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
-               cout << "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";
-               cout << "The rarefaction.single command parameters are label, line, iters, freq, calc and abund.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The rarefaction.single command should be in the following format: " << "\n";
-               cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
-               cout << "Example rarefaction.single(label=unique-.01-.03, line=0-5-10, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
-               cout << "The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
+               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, line, iters, freq, calc and abund.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The rarefaction.single command should be in the following format: \n");
+               mothurOut("rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
+               mothurOut("Example rarefaction.single(label=unique-.01-.03, line=0-5-10, 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");
                validCalculator->printCalc("rarefaction", cout);
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
+               mothurOut("The label and line parameters are used to analyze specific lines in your input.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -212,7 +203,7 @@ int RareFactCommand::execute(){
                                rCurve->getCurve(freq, nIters);
                                delete rCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                                userLines.erase(count);
@@ -226,7 +217,7 @@ int RareFactCommand::execute(){
                                rCurve->getCurve(freq, nIters);
                                delete rCurve;
                        
-                               cout << order->getLabel() << '\t' << count << endl;
+                               mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                        }
@@ -242,12 +233,12 @@ int RareFactCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it; 
+                       mothurOut("Your file does not include the label " + *it);
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -260,7 +251,7 @@ int RareFactCommand::execute(){
                        rCurve->getCurve(freq, nIters);
                        delete rCurve;
                        
-                       cout << order->getLabel() << '\t' << count << endl;
+                       mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        delete order;
                }
                
@@ -269,13 +260,9 @@ int RareFactCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
index d527f8b87af8ab1b29537af212d7229d2e70a75b..71bfaf1d0f79b4866cebe71309e058a61bd2535e 100644 (file)
@@ -44,8 +44,8 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared command." << endl; abort = true; }
-                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared command." << endl; abort = true; }
+                               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; }
                        }
 
                        
@@ -66,7 +66,7 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -115,40 +115,31 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactSharedCommand class function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-                       
 }
 
 //**********************************************************************************************************************
 
 void RareFactSharedCommand::help(){
        try {
-               cout << "The rarefaction.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The rarefaction.shared command parameters are label, line, iters, groups and calc.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The rarefaction command should be in the following format: " << "\n";
-               cout << "rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, calc=yourEstimators, groups=yourGroups)." << "\n";
-               cout << "Example rarefaction.shared(label=unique-.01-.03, line=0-5-10, iters=10000, groups=B-C, calc=sharedobserved)." << "\n";
-               cout << "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";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
+               mothurOut("The rarefaction.shared command can only be executed after a successful read.otu command.\n");
+               mothurOut("The rarefaction.shared command parameters are label, line, iters, groups and calc.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The rarefaction command should be in the following format: \n");
+               mothurOut("rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, calc=yourEstimators, groups=yourGroups).\n");
+               mothurOut("Example rarefaction.shared(label=unique-.01-.03, line=0-5-10, iters=10000, groups=B-C, 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.\n");
                validCalculator->printCalc("sharedrarefaction", cout);
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "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";
-               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
+               mothurOut("The label and line parameters are used to analyze specific lines 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactSharedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactSharedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -181,7 +172,7 @@ int RareFactSharedCommand::execute(){
                string lastLabel = lookup[0]->getLabel();
 
                if (lookup.size() < 2) { 
-                       cout << "I cannot run the command without at least 2 valid groups."
+                       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;
                }
@@ -200,7 +191,7 @@ int RareFactSharedCommand::execute(){
                                rCurve->getSharedCurve(freq, nIters);
                                delete rCurve;
                        
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
                                userLines.erase(count);
@@ -210,7 +201,7 @@ int RareFactSharedCommand::execute(){
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        rCurve = new Rarefact(lookup, rDisplays);
                                        rCurve->getSharedCurve(freq, nIters);
                                        delete rCurve;
@@ -232,12 +223,12 @@ int RareFactSharedCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -246,7 +237,7 @@ int RareFactSharedCommand::execute(){
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        rCurve = new Rarefact(lookup, rDisplays);
                        rCurve->getSharedCurve(freq, nIters);
                        delete rCurve;
@@ -261,13 +252,9 @@ int RareFactSharedCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "RareFactSharedCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the RareFactSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index c03c37f1feeb888c341ca4daa01c644069c155a5..29c967e0cbed51e375d21e0e755f14b7d1c7bd0d 100644 (file)
@@ -127,14 +127,9 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadColumnMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadColumnMatrix", "read");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadColumnMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /***********************************************************************/
index 744a35d6715867e64697461d88d648982479f0f5..088f711e0d6dd6f191493bbaf802db3a7bae1fbb 100644 (file)
@@ -66,11 +66,11 @@ ReadDistCommand::ReadDistCommand(string option){
                        if ((phylipfile != "") && (groupfile != "")) { 
                        globaldata->setFormat("matrix"); }
                        
-                       if ((phylipfile == "") && (columnfile == "")) { cout << "When executing a read.dist command you must enter a phylip or a column." << endl; abort = true; }
-                       else if ((phylipfile != "") && (columnfile != "")) { cout << "When executing a read.dist command you must enter ONLY ONE of the following: phylip or column." << endl; abort = true; }
+                       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 (columnfile != "") {
-                               if (namefile == "") {  cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
+                               if (namefile == "") {  mothurOut("You need to provide a namefile if you are going to use the column format."); mothurOutEndLine(); abort = true; }
                        }
                
                        //check for optional parameter and set defaults
@@ -113,11 +113,7 @@ ReadDistCommand::ReadDistCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadDistCommand class function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadDistCommand", "ReadDistCommand");
                exit(1);
        }
 }
@@ -125,33 +121,26 @@ ReadDistCommand::ReadDistCommand(string option){
 
 void ReadDistCommand::help(){
        try {
-               cout << "The read.dist command parameter options are phylip or column, group, name, cutoff and precision" << "\n";
-               cout << "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";
-               cout << "For this use the read.dist command should be in the following format: " << "\n";
-               cout << "read.dist(phylip=yourDistFile, name=yourNameFile, cutoff=yourCutoff, precision=yourPrecision) " << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "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";
-               cout << "For this use the read.dist command should be in the following format: " << "\n";
-               cout << "read.dist(phylip=yourPhylipfile, group=yourGroupFile). The cutoff and precision parameters are not valid with this use.  " << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. phylip), '=' and parameters (i.e.yourPhylipfile)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadDistCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadDistCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 ReadDistCommand::~ReadDistCommand(){
-       if (abort == false) {
-               if (format != "matrix") { delete read; delete nameMap; }
-       }
 }
 
 //**********************************************************************************************************************
@@ -177,16 +166,13 @@ int ReadDistCommand::execute(){
 
                        if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix;  }
                        globaldata->gSparseMatrix = read->getMatrix();
+                       delete read; delete nameMap;
 
                }
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadDistCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadDistCommand", "execute");
                exit(1);
        }
 }
index a99f343c83e35cd42724ddef6b32d26f4d0c88a6..d16dab9477d4c02ce89ad42de0be4c46228588b4 100644 (file)
@@ -31,11 +31,11 @@ void ReadOTUFile::read(GlobalData* globaldata){
                }else {//there is an orderfile
                        input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
                }
-//cout << "made it here"       << endl;        
+       
                //memory leak prevention
                //if (globaldata->ginput != NULL) { delete globaldata->ginput;  }
                globaldata->ginput = input;     //saving to be used by collector and rarefact commands.
-//cout << "after input" << endl;               
+               
                if ((globaldata->getFormat() == "list") || (globaldata->getFormat() == "rabund") || (globaldata->getFormat() == "sabund")) {//you are reading a list, rabund or sabund file for collect, rarefaction or summary.
                        order = input->getOrderVector();
                        //memory leak prevention
@@ -62,11 +62,7 @@ void ReadOTUFile::read(GlobalData* globaldata){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadOTUFile class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadOTUFile class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadOTUFile", "read");
                exit(1);
        }
 }
index 50ee5c103c00a144159b52a8c1779b7627e46079..07fe251d1d6e8414dfe54785c5dea8cbe500ab3e 100644 (file)
@@ -72,7 +72,7 @@ ReadOtuCommand::ReadOtuCommand(string option){
                        
                        //you have not given a file
                        if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "")) {
-                               cout << "You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. " << endl; abort = true; 
+                               mothurOut("You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. "); mothurOutEndLine(); abort = true; 
                        }
                
                        //check for optional parameter and set defaults
@@ -96,7 +96,7 @@ ReadOtuCommand::ReadOtuCommand(string option){
                        globaldata->allLines = allLines;
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        
                        orderfile = validParameter.validFile(parameters, "order", true);
                        if (orderfile == "not open") { abort = true; }  
@@ -113,11 +113,7 @@ ReadOtuCommand::ReadOtuCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function ReadOtuCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadOtuCommand class function ReadOtuCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
                exit(1);
        }
 }
@@ -125,29 +121,25 @@ ReadOtuCommand::ReadOtuCommand(string option){
 
 void ReadOtuCommand::help(){
        try {
-               cout << "The read.otu command must be run before you execute a collect.single, rarefaction.single, summary.single, " << "\n";
-               cout << "collect.shared, rarefaction.shared or summary.shared command.   Mothur will generate a .list, .rabund and .sabund upon completion of the cluster command " << "\n";
-               cout << "or you may use your own. The read.otu command parameter options are list, rabund, sabund, shared, group, order, line and label." << "\n";
-               cout << "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";
-               cout << "For this use the read.otu command should be in the following format: read.otu(list=yourListFile, order=yourOrderFile, label=yourLabels)." << "\n";
-               cout << "The list, rabund or sabund parameter is required, but you may only use one of them." << "\n";
-               cout << "The line and label parameters are optional but you may not use both the line and label parameters at the same time." << "\n";
-               cout << "The label and line parameters are used to read specific lines in your input." << "\n";
-               cout << "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";
-               cout << "In this case the read.otu command should be in the following format: read.otu(list=yourListFile, group=yourGroupFile, line=yourLines) or read.otu(shared=yourSharedFile).  " << "\n";
-               cout << "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";
-               cout << "and separates it into groups.  It outputs a .shared file containing the OTU information for each group. The read.otu command also outputs a .list file for each group. " << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               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, line and label.\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 line and label parameters are optional but you may not use both the line and label parameters at the same time.\n");
+               mothurOut("The label and line parameters are used to read specific lines 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, line=yourLines) 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 .list file for each group. \n");
+               mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadOtuCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadOtuCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -173,7 +165,7 @@ int ReadOtuCommand::execute(){
                        shared = new SharedCommand();
                        shared->execute();
                        delete shared;
-                       
+                               
                        //change format to shared  to speed up commands
                        globaldata->setFormat("sharedfile");
                        globaldata->setListFile("");
@@ -183,11 +175,7 @@ int ReadOtuCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadOtuCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadOtuCommand", "execute");
                exit(1);
        }
 }
index a1063e94d3d94f241f172bfe33a39ae54d5da7cb..fe278ab14856f085a9a61bfc09e40522dcf96d03 100644 (file)
@@ -38,7 +38,7 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
                         }
                         else{
                                 list = new ListVector(nameMap->getListVector());
-                                if(nameMap->count(name)==0){        cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                                if(nameMap->count(name)==0){        mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
                         }
         
                         char d;
@@ -89,7 +89,7 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
                                 
                                         }
                                         else{
-                                                if(nameMap->count(name)==0){        cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                                                if(nameMap->count(name)==0){        mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
                                 
                                                 for(int j=0;j<i;j++){
                                                         fileHandle >> distance;
@@ -133,7 +133,7 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
                                         
                                         }
                                         else{
-                                                if(nameMap->count(name)==0){        cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                                                if(nameMap->count(name)==0){        mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); mothurOutEndLine(); }
                                 
                                                 for(int j=0;j<nseqs;j++){
                                                         fileHandle >> distance;
@@ -162,20 +162,16 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
                                 }
                                 if(nameMap->size() > 0){
                                         //should probably tell them what is missing if we missed something
-                                        cout << "missed something" << '\t' << nameMap->size() << endl;
+                                        mothurOut("missed something\t" + toString(nameMap->size())); mothurOutEndLine();
                                 }
                         }
 
                 }
         catch(exception& e) {
-                cout << "Standard Error: " << e.what() << " has occurred in the ReadPhylipMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadPhylipMatrix", "read");
                 exit(1);
         }
-        catch(...) {
-                cout << "An unknown error has occurred in the ReadPhylipMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-                exit(1);
-        }
-}
+       }
 
 /***********************************************************************/
 
index 670c6e0a3126ba73370d2520be2b7ac9e1728dd3..5e909e620d237ed063d9a64bd191f707ddea1daa 100644 (file)
@@ -16,13 +16,9 @@ ReadTree::ReadTree() {
                globaldata->gTree.clear();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTree", "ReadTree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTree class function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 int ReadTree::readSpecialChar(istream& f, char c, string name) {
@@ -32,11 +28,11 @@ int ReadTree::readSpecialChar(istream& f, char c, string name) {
                char d = f.get();
        
                if(d == EOF){
-                       cerr << "Error: Input file ends prematurely, expecting a " << name << "\n";
+                       mothurOut("Error: Input file ends prematurely, expecting a " + name + "\n");
                        exit(1);
                }
                if(d != c){
-                       cerr << "Error: Expected " << name << " in input file.  Found " << d << ".\n";
+                       mothurOut("Error: Expected " + name + " in input file.  Found " + toString(d) + ".\n");
                        exit(1);
                }
                if(d == ')' && f.peek() == '\n'){
@@ -45,13 +41,9 @@ int ReadTree::readSpecialChar(istream& f, char c, string name) {
                return d;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function readSpecialChar. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTree", "readSpecialChar");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTree class function readSpecialChar. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 
@@ -62,19 +54,15 @@ int ReadTree::readNodeChar(istream& f) {
                char d = f.get();
 
                if(d == EOF){
-                       cerr << "Error: Input file ends prematurely, expecting a left parenthesis\n";
+                       mothurOut("Error: Input file ends prematurely, expecting a left parenthesis\n");
                        exit(1);
                }
                return d;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function readNodeChar. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTree", "readNodeChar");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTree class function readNodeChar. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /**************************************************************************************************/
@@ -84,20 +72,16 @@ float ReadTree::readBranchLength(istream& f) {
                float b;
        
                if(!(f >> b)){
-                       cerr << "Error: Missing branch length in input tree.\n";
+                       mothurOut("Error: Missing branch length in input tree.\n");
                        exit(1);
                }
                gobble(f);
                return b;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function readBranchLength. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTree", "readBranchLength");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTree class function readBranchLength. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -182,13 +166,9 @@ int ReadNewickTree::read() {
                return readOk;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadNewickTree class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadNewickTree", "read");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadNewickTree class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 //This function read the file through the translation of the sequences names and updates treemap.
@@ -227,13 +207,9 @@ void ReadNewickTree::nexusTranslation() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadNewickTree class Function nexus. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadNewickTree", "nexusTranslation");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadNewickTree class function nexus. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /**************************************************************************************************/
@@ -251,7 +227,7 @@ int ReadNewickTree::readTreeString() {
                        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) { cout << "error with lc" << endl; return -1; } //reports an error in reading
+                       if (lc == -1) { mothurOut("error with lc"); mothurOutEndLine(); return -1; } //reports an error in reading
                
                        if(filehandle.peek()==','){                                                     
                                readSpecialChar(filehandle,',',"comma");
@@ -262,7 +238,7 @@ int ReadNewickTree::readTreeString() {
                        }                                                                                               
                        if(rooted != 1){                                                                
                                rc = readNewickInt(filehandle, n, T);
-                               if (rc == -1) { cout << "error with rc" << endl; return -1; } //reports an error in reading
+                               if (rc == -1) { mothurOut("error with rc"); mothurOutEndLine(); return -1; } //reports an error in reading
                                if(filehandle.peek() == ')'){                                   
                                        readSpecialChar(filehandle,')',"right parenthesis");
                                }                                                                                       
@@ -278,14 +254,14 @@ int ReadNewickTree::readTreeString() {
                        n = T->getIndex(name);
 
                        if(n!=0){
-                               cerr << "Internal error: The only taxon is not taxon 0.\n";
+                               mothurOut("Internal error: The only taxon is not taxon 0.\n");
                                //exit(1);
                                readOk = -1; return -1;
                        }
                        lc = rc = -1;
                } 
                
-               while((ch=filehandle.get())!=';'){;}                                            
+               while(((ch=filehandle.get())!=';') && (filehandle.eof() != true)){;}                                            
                if(rooted != 1){                                                                        
                        T->tree[n].setChildren(lc,rc);
                        T->tree[n].setBranchLength(0);
@@ -297,14 +273,9 @@ int ReadNewickTree::readTreeString() {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadNewickTree class Function readTreeString. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadNewickTree", "readTreeString");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadNewickTree class function readTreeString. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
-
 }
 /**************************************************************************************************/
 
@@ -321,15 +292,22 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                        if (rc == -1) { return -1; }  //reports an error in reading     
                        if(f.peek()==')'){      
                                readSpecialChar(f,')',"right parenthesis");     
+                               //to pass over labels in trees
+                               c=filehandle.get();
+                               while((c!=',') && (c != -1) && (c!= ':') && (c!=';')){ c=filehandle.get(); }
+                               filehandle.putback(c);
+
                        }                       
                
                        if(f.peek() == ':'){                                                                          
                                readSpecialChar(f,':',"colon"); 
                                                                                
-                               if(n >= numNodes){      cerr << "Error: Too many nodes in input tree\n";  readOk = -1; return -1; }
+                               if(n >= numNodes){      mothurOut("Error: Too many nodes in input tree\n");  readOk = -1; return -1; }
                                
                                T->tree[n].setBranchLength(readBranchLength(f));
-                       }else{T->tree[n].setBranchLength(0.0); }                                                
+                       }else{
+                               T->tree[n].setBranchLength(0.0); 
+                       }                                               
                
                        T->tree[n].setChildren(lc,rc);
                        T->tree[lc].setParent(n);
@@ -358,7 +336,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                        
                        //adds sequence names that are not in group file to the "xxx" group
                        if(group == "not found") {
-                               cout << "Name: " << name << " is not in your groupfile, and will be disregarded. \n";  //readOk = -1; return n1;
+                               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";
@@ -392,13 +370,9 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadNewickTree class Function readNewickInt. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadNewickTree", "readNewickInt");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadNewickTree class function readNewickInt. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 /**************************************************************************************************/
index d301b1366d5f8965a2c84151940d5773b5d71854..2a3c5d0cdf264ce0c4ecf614b4c3fd46d0ffe51c 100644 (file)
@@ -38,12 +38,12 @@ ReadTreeCommand::ReadTreeCommand(string option){
                        //check for required parameters
                        treefile = validParameter.validFile(parameters, "tree", true);
                        if (treefile == "not open") { abort = true; }
-                       else if (treefile == "not found") { treefile = ""; cout << "tree is a required parameter for the read.tree command." << endl; abort = true;  }  
+                       else if (treefile == "not found") { treefile = ""; mothurOut("tree is a required parameter for the read.tree command."); 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 = ""; cout << "group is a required parameter for the read.tree command." << endl; abort = true;  }
+                       else if (groupfile == "not found") { groupfile = ""; mothurOut("group is a required parameter for the read.tree command."); mothurOutEndLine(); abort = true;   }
                        else {  
                                globaldata->setGroupFile(groupfile); 
                                //read in group map info.
@@ -60,11 +60,7 @@ ReadTreeCommand::ReadTreeCommand(string option){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTreeCommand class function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTreeCommand", "ReadTreeCommand");              
                exit(1);
        }
 }
@@ -72,26 +68,22 @@ ReadTreeCommand::ReadTreeCommand(string option){
 
 void ReadTreeCommand::help(){
        try {
-               cout << "The read.tree command must be run before you execute a unifrac.weighted, unifrac.unweighted. " << "\n";
-               cout << "It also must be run before using the parsimony command, unless you are using the randomtree parameter." << "\n";
-               cout << "The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile)." << "\n";
-               cout << "The tree and group parameters are both required." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTreeCommand", "help"); 
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTreeCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 ReadTreeCommand::~ReadTreeCommand(){
-       delete read;
+       if (abort == false) { delete read; }
 }
 
 //**********************************************************************************************************************
@@ -105,10 +97,10 @@ int ReadTreeCommand::execute(){
                
                readOk = read->read(); 
                
-               if (readOk != 0) { cout << "Read Terminated." << endl; globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
+               if (readOk != 0) { mothurOut("Read Terminated."); mothurOutEndLine(); globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
                
                vector<Tree*> T = globaldata->gTree;
-               
+
                //assemble users trees
                for (int i = 0; i < T.size(); i++) {
                        T[i]->assembleTree();
@@ -126,7 +118,7 @@ int ReadTreeCommand::execute(){
                                
                                //then you did not find it so report it 
                                if (count == globaldata->Treenames.size()) { 
-                                       cout << treeMap->namesOfSeqs[i] << " is in your namefile and not in your tree. It will be disregarded." << endl;
+                                       mothurOut(treeMap->namesOfSeqs[i] + " is in your namefile and not in your tree. It will be disregarded."); mothurOutEndLine();
                                }
                        }
                }
@@ -134,11 +126,7 @@ int ReadTreeCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadTreeCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReadTreeCommand", "execute");      
                exit(1);
        }
 }
index 9e2a08b2a493fec7ed717505d7d02112a8530b49..7a87a99a9720f3f5c8bc04e77bac39d5eabf5ea0 100644 (file)
@@ -38,36 +38,28 @@ ReverseSeqsCommand::ReverseSeqsCommand(string option){
                        //check for required parameters
                        fasta = validParameter.validFile(parameters, "fasta", true);
                        if (fasta == "not open") { abort = true; }
-                       else if (fasta == "not found") { fasta = ""; cout << "fasta is a required parameter for the reverse.seqs command." << endl; abort = true;  }    
+                       else if (fasta == "not found") { fasta = ""; mothurOut("fasta is a required parameter for the reverse.seqs command."); mothurOutEndLine(); abort = true;  }     
                        
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function ReverseSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function ReverseSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void ReverseSeqsCommand::help(){
        try {
-               cout << "The reverse.seqs command reads a fastafile and ...." << "\n";
-               cout << "The reverse.seqs command parameter is fasta and it is required." << "\n";
-               cout << "The reverse.seqs command should be in the following format: " << "\n";
-               cout << "reverse.seqs(fasta=yourFastaFile) " << "\n";   
+               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");      
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //***************************************************************************************************************
@@ -101,11 +93,7 @@ int ReverseSeqsCommand::execute(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "execute");
                exit(1);
        }
 }
index c1997d5d91bc3cbd8fffb240909aa3dae791f646..b70c642643cfd746e63c236e328feb8e37d74a44 100644 (file)
@@ -29,11 +29,7 @@ SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sa
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -48,11 +44,7 @@ SAbundVector::SAbundVector(vector <int> dataVec, int mr, int nb, int ns) {
                numSeqs = ns;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -72,11 +64,7 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -99,13 +87,9 @@ void SAbundVector::set(int sabund, int abundance){
                if(sabund > maxRank)    {       maxRank = sabund;               }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "set");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -128,13 +112,9 @@ void SAbundVector::push_back(int abundance){
                numSeqs += (maxRank * abundance);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "push_back");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 
@@ -183,13 +163,9 @@ void SAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /**********************************************************************/
@@ -227,13 +203,9 @@ RAbundVector SAbundVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -266,13 +238,9 @@ OrderVector SAbundVector::getOrderVector(map<string,int>* hold = NULL){
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SAbundVector", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
index d0f0af0976bd9e2feba32f8757b6b22067eebbc8..4b267b532ae1a19be791c380339b928212477edd 100644 (file)
@@ -37,7 +37,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option){
                        
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { cout << "fasta is a required parameter for the screen.seqs command." << endl; abort = true; }
+                       if (fastafile == "not found") { mothurOut("fasta is a required parameter for the screen.seqs command."); mothurOutEndLine(); abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
        
                        groupfile = validParameter.validFile(parameters, "group", true);
@@ -76,43 +76,35 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScreenSeqsCommand class Function ScreenSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScreenSeqsCommand class function ScreenSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void ScreenSeqsCommand::help(){
        try {
-               cout << "The screen.seqs command reads a fastafile and creates ....." << "\n";
-               cout << "The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, and group." << "\n";
-               cout << "The fasta parameter is required." << "\n";
-               cout << "The start parameter .... The default is -1." << "\n";
-               cout << "The end parameter .... The default is -1." << "\n";
-               cout << "The maxambig parameter .... The default is -1." << "\n";
-               cout << "The maxhomop parameter .... The default is -1." << "\n";
-               cout << "The minlength parameter .... The default is -1." << "\n";
-               cout << "The maxlength parameter .... The default is -1." << "\n";
-               cout << "The name parameter allows you to provide a namesfile, and the group parameter allows you to provide a groupfile." << "\n";
-               cout << "The screen.seqs command should be in the following format: " << "\n";
-               cout << "screen.seqs(fasta=yourFastaFile, name=youNameFile, group=yourGroupFIle, start=yourStart, end=yourEnd, maxambig=yourMaxambig,  " << "\n";
-               cout << "maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength)  " << "\n";    
-               cout << "Example screen.seqs(fasta=abrecovery.fasta, name=abrecovery.names, group=abrecovery.groups, start=..., end=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...)." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta)." << "\n" << "\n";
+               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");
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScreenSeqsCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScreenSeqsCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScreenSeqsCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //***************************************************************************************************************
@@ -166,14 +158,9 @@ int ScreenSeqsCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ScreenSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ScreenSeqsCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ScreenSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 //***************************************************************************************************************
index 3259931a1fe04dfeaca2c6d981af48018e9f377d..82a1d2473a0bc35282abd46a5998ae65fbcce1bf 100644 (file)
@@ -37,37 +37,29 @@ SeqSummaryCommand::SeqSummaryCommand(string option){
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
                        if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") { fastafile = ""; cout << "fasta is a required parameter for the summary.seqs command." << endl; abort = true;  }    
+                       else if (fastafile == "not found") { fastafile = ""; mothurOut("fasta is a required parameter for the summary.seqs command."); mothurOutEndLine(); abort = true;  }     
                        
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SeqSummaryCommand class Function SeqSummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SeqSummaryCommand class function SeqSummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void SeqSummaryCommand::help(){
        try {
-               cout << "The summary.seqs command reads a fastafile and ...." << "\n";
-               cout << "The summary.seqs command parameter is fasta and it is required." << "\n";
-               cout << "The summary.seqs command should be in the following format: " << "\n";
-               cout << "summary.seqs(fasta=yourFastaFile) " << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n";       
+               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");        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SeqSummaryCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SeqSummaryCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SeqSummaryCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //***************************************************************************************************************
@@ -128,29 +120,24 @@ int SeqSummaryCommand::execute(){
                int ptile97_5   = int(numSeqs * 0.975);
                int ptile100    = numSeqs - 1;
                
-               cout << endl;
-               cout << "\t\tStart\tEnd\tNBases\tAmbigs\tPolymer" << endl;
-               cout << "Minimum:\t" << startPosition[0] << '\t' << endPosition[0] << '\t' << seqLength[0] << '\t' << ambigBases[0] << '\t' << longHomoPolymer[0] << endl;
-               cout << "2.5%-tile:\t" << startPosition[ptile0_25] << '\t' << endPosition[ptile0_25] << '\t' << seqLength[ptile0_25] << '\t' << ambigBases[ptile0_25] << '\t' << longHomoPolymer[ptile0_25] << endl;
-               cout << "25%-tile:\t" << startPosition[ptile25] << '\t' << endPosition[ptile25] << '\t' << seqLength[ptile25] << '\t' << ambigBases[ptile25] << '\t' << longHomoPolymer[ptile25] << endl;
-               cout << "Median: \t" << startPosition[ptile50] << '\t' << endPosition[ptile50] << '\t' << seqLength[ptile50] << '\t' << ambigBases[ptile50] << '\t' << longHomoPolymer[ptile50] << endl;
-               cout << "75%-tile:\t" << startPosition[ptile75] << '\t' << endPosition[ptile75] << '\t' << seqLength[ptile75] << '\t' << ambigBases[ptile75] << '\t' << longHomoPolymer[ptile75] << endl;
-               cout << "97.5%-tile:\t" << startPosition[ptile97_5] << '\t' << endPosition[ptile97_5] << '\t' << seqLength[ptile97_5] << '\t' << ambigBases[ptile97_5] << '\t' << longHomoPolymer[ptile97_5] << endl;
-               cout << "Maximum:\t" << startPosition[ptile100] << '\t' << endPosition[ptile100] << '\t' << seqLength[ptile100] << '\t' << ambigBases[ptile100] << '\t' << longHomoPolymer[ptile100] << endl;
-               cout << "# of Seqs:\t" << numSeqs << endl;
+               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();
                
                outSummary.close();
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SeqSummaryCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SeqSummaryCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SeqSummaryCommand", "execute");
                exit(1);
        }
-       
 }
 
 //***************************************************************************************************************
index bc8523aa78b5d217fd5cfd12c8bade6bbb630721..ca201d5a211695138540fe585314773fe4020f90 100644 (file)
@@ -43,7 +43,7 @@ SequenceDB::SequenceDB(ifstream& filehandle) {
                        if (c == '>') { 
                                name = readName(filehandle); 
                                sequence = readSequence(filehandle); 
-                       }else {  cout << "Error fasta in your file. Please correct." << endl; }
+                       }else {  mothurOut("Error fasta in your file. Please correct."); mothurOutEndLine(); }
 
                        //input sequence info into sequencedb
                        Sequence newSequence(name, sequence);
@@ -57,11 +57,7 @@ SequenceDB::SequenceDB(ifstream& filehandle) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function SequenceDB. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function SequenceDB. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "SequenceDB");
                exit(1);
        }
 }
@@ -82,11 +78,7 @@ string SequenceDB::readName(ifstream& in) {
                return name;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function readName. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function readName. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "readName");
                exit(1);
        }
 }
@@ -115,11 +107,7 @@ string SequenceDB::readSequence(ifstream& in) {
                return sequence;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function readSequence. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function readSequence. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "readSequence");
                exit(1);
        }
 }
@@ -137,11 +125,7 @@ void SequenceDB::set(int index, string newUnaligned) {
                data[index] = Sequence(data[index].getName(), newUnaligned);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "set");
                exit(1);
        }
 }
@@ -153,11 +137,7 @@ void SequenceDB::set(int index, Sequence newSeq) {
                data[index] = newSeq;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "set");
                exit(1);
        }
 }
@@ -175,11 +155,7 @@ void SequenceDB::resize(int newSize) {
                data.resize(newSize);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function resize. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function resize. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "resize");
                exit(1);
        }
 }
@@ -191,11 +167,7 @@ void SequenceDB::clear() {
                data.clear();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function clear. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function clear. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "clear");
                exit(1);
        }
 }
@@ -215,11 +187,7 @@ void SequenceDB::print(ostream& out) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "print");
                exit(1);
        }
 }
@@ -231,11 +199,7 @@ void SequenceDB::push_back(Sequence newSequence) {
                data.push_back(newSequence);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SequenceDB class Function add. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SequenceDB class function add. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SequenceDB", "push_back");
                exit(1);
        }
 }
index 0d54b7b138d4cf861318126840f4208c2e842bca..1807375066daa52db405b7253d82ff30a5951a4b 100644 (file)
@@ -52,13 +52,9 @@ EstOutput Shannon::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Shannon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Shannon", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Shannon class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 34ad28bec83ffd580e29aca410a3c2afb0a554d9..61a7c74e8b36496ee213d7eb26ee3ef277f1b686 100644 (file)
@@ -100,14 +100,9 @@ EstOutput SharedAce::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedAce class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedAce", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedAce class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
 }
 /***********************************************************************/
 
index 0a113abebd30c758eeda592bab4e86981373a9a6..d55a016257436ddc22ca1a885f14a81fb4006689 100644 (file)
@@ -40,13 +40,9 @@ EstOutput Anderberg::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Anderberg class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Anderberg", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Anderberg class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 9a63cdf9c0a3cbf37fd2ef179ef5bd8ff3229bc7..299939dbfd156d1e5d9724fb112a4c5e3292c5a1 100644 (file)
@@ -44,15 +44,9 @@ EstOutput BrayCurtis::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the BrayCurtis class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "BrayCurtis", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the BrayCurtis class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
-
 }
 
 /***********************************************************************/
index 8dff314b2b7ab3d913d73d4437cd3b82cefd863c..402e0d9f1911bb0b19d27fc0aeac661826c1683d 100644 (file)
@@ -41,15 +41,12 @@ EstOutput SharedChao1::getValues(vector<SharedRAbundVector*> shared){
                        
                        //they are shared
                        if (sharedByAll == true) { 
-                               // cout << "temp = ";
-                               // for (int h = 0; h < temp.size(); h++) { cout << temp[h] << " "; } cout << endl;
                                //find f1 and f2values
                                updateTree(temp);
                        }
                }
 
                        
-               //cout << "Entering " << endl;
                //calculate chao1, (numleaves-1) because numleaves contains the ++ values.
                bool bias;
                for(int i=0;i<numLeaves;i++){
@@ -87,18 +84,14 @@ EstOutput SharedChao1::getValues(vector<SharedRAbundVector*> shared){
                        delete f2leaves[i];
                }
                
-       //      cout << "exiting " << endl;
+
                data[0] = Chao;
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -153,13 +146,9 @@ void SharedChao1::initialTree(int n) {
                setCoef(f2root, 0);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function initialTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "initialTree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function initialTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -170,13 +159,9 @@ void SharedChao1::updateTree(vector<int> bin) {
                updateBranchf2(f2root, bin, 0); 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "updateTree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function updateTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -196,13 +181,9 @@ void SharedChao1::updateBranchf1(IntNode* node, vector<int> bin, int index) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateBranchf1. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "updateBranchf1");           
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function updateBranchf1. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -222,13 +203,9 @@ void SharedChao1::updateBranchf2(IntNode* node, vector<int> bin, int index) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateBranchf2. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "updateBranchf2");   
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function updateBranchf2. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -243,23 +220,19 @@ void SharedChao1::setCoef(IntNode* node, int coef) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function getCoef. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "setCoef");  
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedChao1 class function getCoef. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
 //for debugging purposes
 void SharedChao1::printTree() {
        
-       cout << "F1 leaves" << endl;
+       mothurOut("F1 leaves"); mothurOutEndLine();
        printBranch(f1root);
        
-       cout << "F2 leaves" << endl;
+       mothurOut("F2 leaves"); mothurOutEndLine();
        printBranch(f2root);
 
 
@@ -273,19 +246,15 @@ void SharedChao1::printBranch(IntNode* node) {
                        printBranch(node->left);
                        printBranch(node->right);
                }else { //you are a leaf
-                       cout << node->lvalue << endl;
-                       cout << node->rvalue << endl;
+                       mothurOut(toString(node->lvalue)); mothurOutEndLine();
+                       mothurOut(toString(node->rvalue)); mothurOutEndLine();
                }
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedChao1", "printBranch");      
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
index 6ca1ed63585463d92ac8dc7aa65f921ca1070308..4857a3482737a2b305b5a9ad381e228328289c19 100644 (file)
@@ -22,21 +22,16 @@ SharedCommand::SharedCommand(){
                openOutputFile(filename, out);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function SharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedCommand", "SharedCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedCommand class function SharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 //**********************************************************************************************************************
 
 int SharedCommand::execute(){
        try {
                
-               cout << "creating sharedfile...";
+               mothurOut("creating sharedfile..."); mothurOutEndLine();
                //lookup.clear();
                int count = 1;
                string errorOff = "no error";
@@ -94,12 +89,8 @@ int SharedCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       //cout << "Your file does not include the label "<< *it; 
                        if (processedLabels.count(lastLabel) != 1) {
-                               //cout << ". I will use " << lastList->getLabel() << "." << endl;
                                needToRun = true;
-                       }else {
-                               //cout << ". Please refer to " << lastList->getLabel() << "." << endl;
                        }
                }
                
@@ -119,18 +110,13 @@ int SharedCommand::execute(){
                
                out.close();
                
-               cout << "complete." << endl;
+               mothurOut("complete."); mothurOutEndLine();
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedCommand", "execute");
                exit(1);
        }
-
 }
 //**********************************************************************************************************************
 void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup) {
@@ -144,14 +130,9 @@ void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup) {
  
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function printSharedData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedCommand class function printSharedData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedCommand", "printSharedData");
                exit(1);
        }
-       
 }
 
 //**********************************************************************************************************************
index bedec32843323ac0a19248010060e430a7c097da..d07076aaaad4247d73970f26d470ca0d01990adb 100644 (file)
@@ -27,13 +27,9 @@ EstOutput JAbund::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the JAbund class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "JAbund", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the JAbund class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index c1e5ff4ec4c56a1f5eddad239a9b21f6e0deb72c..012d2067ab94e7026a9673e77287c1629beafc8d 100644 (file)
@@ -116,17 +116,11 @@ EstOutput SharedJackknife::getValues(vector<SharedRAbundVector*> vectorShared){
                        data[0] = rdata[0];
                        data[1] = rdata[1];
                        data[2] = rdata[2];
-                       
-                       //cout << "sT = " << data[0] << "    lower confLimit = " << data[1] << "     upper confLimit = " << data[2] << "\n";
+               
                        if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
                        if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
                        if (isnan(data[2]) || isinf(data[0])) { data[2] = 0; }
                        
-                       /*for(int i = 0; i < groups.size(); i++)
-                               cout << groups.at(i)->getGroup() << " ";
-                       cout << "\n";
-                       cout << groups.size() << "     " << data[0] << "    " << data[1] << "     " << data[2] << "\n\n";*/
-                       
                        return data;
                }
                
@@ -142,13 +136,9 @@ EstOutput SharedJackknife::getValues(vector<SharedRAbundVector*> vectorShared){
        }
                
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedJackknife class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedJackknife", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedJackknife class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index a0ccc8925654335230b32a38858e4fd7d2756788..051f05ef9e8ecee0416694285cf8d598d01db9f4 100644 (file)
@@ -41,13 +41,9 @@ EstOutput Jclass::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Jclass class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Jclass", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Jclass class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 1ca64b438036d40e2e75e70cde735f8637a53c6b..0396f476d75acdfbfe44957dbaecbfa4e2f85594 100644 (file)
@@ -52,13 +52,9 @@ EstOutput Jest::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Jest class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Jest", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Jest class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index f65f271abbf39224b6eb052a3d83d2142968d141..567b3458b5486b8e1f3fa601eb44631a946c24e9 100644 (file)
@@ -43,17 +43,6 @@ EstOutput KSTest::getValues(vector<SharedRAbundVector*> shared){
                //double pVal = exp(-2*pow(maxDiff/a,2));
                double critVal = 1.36*a*numNZ1*numNZ2;
                
-               /*cout << "Kolmogorov-Smirnov 2-sample test:\n";
-               if(numNZ1 > 25 && numNZ2 > 25) //If the sample sizes are both bigger than 25.
-                       cout << "P-Value = " << pVal << "\nP-Value is the probability that the data sets are significantly different.\n";
-               else
-               {       
-                       //cout << "90% Confidence Critical Value = " << 1.22*a*numNZ1*numNZ2 << "\n";
-                       cout << "D-Statistic = " << DStatistic << "\n";
-                       cout << "95% Confidence Critical Value = " << critVal << "\n";
-                       cout << "If D-Statistic is greater than the critical value then the data sets are significantly different at the 95% confidence level.\n\n";
-               }*/
-               
                shared[0]->setData(initData1);
                shared[1]->setData(initData2);
                
@@ -67,13 +56,9 @@ EstOutput KSTest::getValues(vector<SharedRAbundVector*> shared){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the KSTest class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "KSTest", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the KSTest class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 5eadd16691e770453f0ed0053aa3a42ffa3e7b73..cd09063fdf6143d683217dbdfc3ea67e3c409438 100644 (file)
@@ -40,13 +40,9 @@ EstOutput Kulczynski::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Kulczynski class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Kulczynski", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Kulczynski class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 7ae67003cce980fe676f2648887ea4fcea23e554..dbb3c45d5a24ce9a594440e955e434147d72ffce 100644 (file)
@@ -40,13 +40,9 @@ EstOutput KulczynskiCody::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the KulczynskiCody class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "KulczynskiCody", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the KulczynskiCody class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 4846e20935757e2ed062bf95d56bd229c101fc28..514f2b90e502e468132d0a72e27273f05396a219 100644 (file)
@@ -46,13 +46,9 @@ EstOutput Lennon::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Lennon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Lennon", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Lennon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 3cb3e9e57c4da06f0589272cff4b3e97bd92eea4..ba2ac1f54082a44cc188611994ff4f5c61b65ad3 100644 (file)
@@ -44,11 +44,7 @@ SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numB
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "SharedListVector");
                exit(1);
        }
 }
@@ -67,11 +63,7 @@ void SharedListVector::set(int binNumber, string seqNames){
                numSeqs += (nNames_new - nNames_old);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "set");
                exit(1);
        }
 }
@@ -96,11 +88,7 @@ void SharedListVector::push_back(string seqNames){
                numSeqs += nNames;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "push_back");
                exit(1);
        }
 }
@@ -140,11 +128,7 @@ void SharedListVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "print");
                exit(1);
        }
 }
@@ -175,11 +159,7 @@ RAbundVector SharedListVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getRAbundVector");
                exit(1);
        }
 }
@@ -200,11 +180,7 @@ SAbundVector SharedListVector::getSAbundVector(){
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getSAbundVector");
                exit(1);
        }
 }
@@ -237,14 +213,9 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){
                return order;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 /***********************************************************************/
 SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
@@ -277,11 +248,7 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getSharedRAbundVector");
                exit(1);
        }
 }
@@ -326,14 +293,9 @@ vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
                return lookup;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getSharedRAbundVector");
                exit(1);
        }
-       
 }
 
 /***********************************************************************/
@@ -348,11 +310,7 @@ SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getSharedSAbundVector");
                exit(1);
        }
 }
@@ -393,7 +351,7 @@ OrderVector SharedListVector::getOrderVector(map<string,int>* orderMap = NULL){
                                        }
                                        else{
                                                if(orderMap->count(seqName) == 0){
-                                                       cerr << seqName << " not found, check *.names file\n";
+                                                       mothurOut(seqName + " not found, check *.names file\n");
                                                        exit(1);
                                                }
                                        
@@ -403,7 +361,7 @@ OrderVector SharedListVector::getOrderVector(map<string,int>* orderMap = NULL){
                                }
                        
                                if(orderMap->count(seqName) == 0){
-                                       cerr << seqName << " not found, check *.names file\n";
+                                       mothurOut(seqName + " not found, check *.names file\n");
                                        exit(1);
                                }
                                ov.set((*orderMap)[seqName], i);        
@@ -416,11 +374,7 @@ OrderVector SharedListVector::getOrderVector(map<string,int>* orderMap = NULL){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedListVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedListVector", "getOrderVector");
                exit(1);
        }
 }
index d382f9b5d7b186fd8559bf2bfb1288f8b6991eb5..e4b80bec5eb22b0e513e556a5445bc0a755306b9 100644 (file)
@@ -38,13 +38,9 @@ EstOutput SharedMarczewski::getValues(vector<SharedRAbundVector*> vectorShared){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedMarczewski class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedMarczewski", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedMarczewski class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 28ff4fec9f2e2ee3c8e99b0f167630152acca802..f9c1b6be1035ef85e6ea0e2c25be118cd99b9c97 100644 (file)
@@ -50,13 +50,9 @@ EstOutput MorHorn::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the MorHorn class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "MorHorn", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the MorHorn class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 744fb1c2a4b119561bd4756b98ed39483b2c89d1..1d0828ebf5f9b3f46b63bae40504bd041de2735a 100644 (file)
@@ -40,13 +40,9 @@ EstOutput Ochiai::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Ochiai class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Ochiai", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Ochiai class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 218ed8709dd6ce4b624c233c4d60aa8c3cb4a27f..76eeafa4b519c02b25c8364e19d3d0397ffdcd96 100644 (file)
@@ -93,11 +93,7 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "SharedOrderVector");
                exit(1);
        }
 }
@@ -167,11 +163,7 @@ void SharedOrderVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "print");
                exit(1);
        }
 }
@@ -180,7 +172,7 @@ void SharedOrderVector::print(ostream& output){
 /***********************************************************************/
 
 void SharedOrderVector::resize(int){
-       cout << "resize() did nothing in class SharedOrderVector";
+       mothurOut("resize() did nothing in class SharedOrderVector");
 }
 
 /***********************************************************************/
@@ -223,13 +215,9 @@ RAbundVector SharedOrderVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -247,11 +235,7 @@ OrderVector SharedOrderVector::getOrderVector(map<string,int>* nameMap = NULL) {
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "getOrderVector");
                exit(1);
        }
 }
@@ -281,14 +265,9 @@ SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) {
                return sharedRav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
                exit(1);
        }
-       
 }
 /***********************************************************************/
 vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
@@ -303,14 +282,9 @@ vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
                return lookup;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
                exit(1);
        }
-       
 }
 /***********************************************************************/
 SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
@@ -321,14 +295,9 @@ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "getSharedSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 /***********************************************************************/
@@ -361,13 +330,9 @@ void SharedOrderVector::updateStats(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedOrderVector", "updateStats");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 246712824907240690d86c07632ed1cc58966182..0a69e4c37849171e01544da40f2c09bbd86d40b0 100644 (file)
@@ -51,11 +51,7 @@ SharedRAbundVector::SharedRAbundVector(string id, vector<individual> rav) : Data
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function SharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function SharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
                exit(1);
        }
 }
@@ -141,11 +137,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function SharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function SharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
                exit(1);
        }
 }
@@ -163,11 +155,7 @@ void SharedRAbundVector::set(int binNumber, int newBinSize, string groupname){
                numSeqs += (newBinSize - oldBinSize);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "set");
                exit(1);
        }
 }
@@ -228,11 +216,7 @@ void SharedRAbundVector::push_back(int binSize, int otu, string groupName){
                numSeqs += binSize;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "push_back");
                exit(1);
        }
 }
@@ -256,11 +240,7 @@ void SharedRAbundVector::insert(int binSize, int otu, string groupName){
                numSeqs += binSize;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function insert. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function insert. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "insert");
                exit(1);
        }
 }
@@ -284,11 +264,7 @@ void SharedRAbundVector::push_front(int binSize, int otu, string groupName){
                numSeqs += binSize;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function push_front. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function push_front. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "push_front");
                exit(1);
        }
 }
@@ -334,11 +310,7 @@ void SharedRAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "print");
                exit(1);
        }
 }
@@ -399,11 +371,7 @@ vector<SharedRAbundVector*> SharedRAbundVector::getSharedRAbundVectors(){
                return lookup;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getSharedRAbundVectors");
                exit(1);
        }
 }
@@ -420,11 +388,7 @@ RAbundVector SharedRAbundVector::getRAbundVector() {
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getRAbundVector");
                exit(1);
        }
 }
@@ -439,11 +403,7 @@ RAbundVector SharedRAbundVector::getRAbundVector2() {
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getRAbundVector2");
                exit(1);
        }
 }
@@ -465,11 +425,7 @@ SharedSAbundVector SharedRAbundVector::getSharedSAbundVector(){
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getSharedSAbundVector");
                exit(1);
        }
 }
@@ -488,11 +444,7 @@ SAbundVector SharedRAbundVector::getSAbundVector() {
                return sav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getSAbundVector");           
                exit(1);
        }
 }
@@ -516,11 +468,7 @@ SharedOrderVector SharedRAbundVector::getSharedOrderVector() {
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getSharedOrderVector");
                exit(1);
        }
 }
@@ -541,11 +489,7 @@ OrderVector SharedRAbundVector::getOrderVector(map<string,int>* nameMap = NULL)
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedRAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedRAbundVector", "getOrderVector");
                exit(1);
        }
 }
index 51058cf585fb511655a97d9b1a15d108dab99df5..8282f66878e9f29324b136b243956c5a33f07243 100644 (file)
@@ -45,13 +45,9 @@ void SharedSAbundVector::set(int bin, int abundance, string groupName){
                if(bin > maxRank)       {       maxRank = bin;          }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "set");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -83,13 +79,9 @@ void SharedSAbundVector::push_back(int abundance, int bin, string groupName){
                numSeqs += (maxRank * abundance);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "push_back");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -115,13 +107,9 @@ void SharedSAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 string SharedSAbundVector::getGroup(){
@@ -166,13 +154,9 @@ RAbundVector SharedSAbundVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 SAbundVector SharedSAbundVector::getSAbundVector(){
@@ -186,13 +170,9 @@ SAbundVector SharedSAbundVector::getSAbundVector(){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -226,13 +206,9 @@ SharedRAbundVector SharedSAbundVector::getSharedRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSharedVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "getSharedRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSharedVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 
@@ -256,13 +232,9 @@ SharedOrderVector SharedSAbundVector::getSharedOrderVector() {
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
@@ -287,13 +259,9 @@ OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSAbundVector", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
index 388356ea927c02cee168918026115c010c6d705f..b65a8781db509ab48c77ea20f0341c47e2ad1d62 100644 (file)
@@ -29,13 +29,9 @@ EstOutput SharedSobs::getValues(vector<SharedRAbundVector*> shared){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSobs class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSobs", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSobs class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index c0cc50700d9f9fc38523991a1c08cf287fb1fc29..0096303d03cd8282e8732046ddc36205a15a1633 100644 (file)
@@ -34,13 +34,9 @@ EstOutput SharedSobsCS::getValues(vector<SharedRAbundVector*> shared){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSobsCS class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedSobsCS", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSobsCS class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 6748bfe86af75f13a5c206577ed5a7f0d51fa6ae..7b472a7b263cfc3863720ccfcf97ba754eeaa043 100644 (file)
@@ -27,13 +27,9 @@ EstOutput SorAbund::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SorAbund class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SorAbund", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SorAbund class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index f4757a83ea28a0fff342f4521469a6a43bae44b4..3bb22198303465ed5038464e32e8f3e168f16cc9 100644 (file)
@@ -41,13 +41,9 @@ EstOutput SorClass::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SorClass class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SorClass", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SorClass class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 91191d5e9ec85c7b8b1f918148c9a9dfba69fa44..680c4adcf380369ef0ab0bcfe85438666adceffe 100644 (file)
@@ -51,13 +51,9 @@ EstOutput SorEst::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SorEst class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SorEst", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SorEst class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 0d7405cec5db7c6fd142b4b98619235a2ed74981..6396d1dd667ff348b9d9d281a762d986726538d3 100644 (file)
@@ -51,13 +51,9 @@ EstOutput ThetaN::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ThetaN class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ThetaN", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ThetaN class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 59cea4df6a8835210a33c2d1c815eb50550c6dbc..abb30e5a4608b9db863619f52141259bf00ba8b1 100644 (file)
@@ -48,13 +48,9 @@ EstOutput ThetaYC::getValues(vector<SharedRAbundVector*> shared) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ThetaYC class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ThetaYC", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ThetaYC class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index de627c643c9ff277854a1d8b8ffcb595004d0a85..7d85c4cbbf3e989b4e92ac400b22ab274b60c548 100644 (file)
@@ -49,11 +49,7 @@ void SharedUtil::getSharedVectors(vector<string> Groups, vector<SharedRAbundVect
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "getSharedVectors");
                exit(1);
        }
 }
@@ -97,11 +93,7 @@ void SharedUtil::getSharedVectorswithReplacement(vector<string> Groups, vector<S
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getSharedVectorswithReplacement. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function getSharedVectorswithReplacement. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "getSharedVectorswithReplacement");
                exit(1);
        }
 }
@@ -115,7 +107,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                //check that groups are valid
                                for (int i = 0; i < userGroups.size(); i++) {
                                        if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl;
+                                               mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
                                                // erase the invalid group from userGroups
                                                userGroups.erase(userGroups.begin()+i);
                                                i--;
@@ -124,7 +116,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                
                                //if the user only entered invalid groups
                                if (userGroups.size() == 0) { 
-                                       cout << "You provided no valid groups. I will run the command using all the groups in your groupfile." << endl; 
+                                       mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); mothurOutEndLine();
                                        for (int i = 0; i < allGroups.size(); i++) {
                                                userGroups.push_back(allGroups[i]);
                                        }
@@ -144,14 +136,9 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "setGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 /**************************************************************************************************/
 //need to have mode because different commands require different number of valid groups
@@ -162,7 +149,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                //check that groups are valid
                                for (int i = 0; i < userGroups.size(); i++) {
                                        if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl;
+                                               mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
                                                // erase the invalid group from userGroups
                                                userGroups.erase(userGroups.begin()+i);
                                                i--;
@@ -184,7 +171,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) {
                                //if the user only entered invalid groups
                                if ((userGroups.size() == 0) || (userGroups.size() == 1)) { 
-                                       cout << "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." << endl; 
+                                       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();
                                        for (int i = 0; i < allGroups.size(); i++) {
                                                userGroups.push_back(allGroups[i]);
                                        }
@@ -193,14 +180,9 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "setGroups");
                exit(1);
        }
-
 }
 
 
@@ -217,7 +199,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                //check that groups are valid
                                for (int i = 0; i < userGroups.size(); i++) {
                                        if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl;
+                                               mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); mothurOutEndLine();
                                                // erase the invalid group from globaldata->Groups
                                                userGroups.erase(userGroups.begin()+i);
                                                i--;
@@ -254,9 +236,9 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                                userGroups.push_back(allGroups[i]);
                                        }
                                }
-                               cout << "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." << endl; 
+                               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();
                        }else if (userGroups.size() == 1) { 
-                               cout << "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." << endl;
+                               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();
                                userGroups.clear();
                                for (int i=0; i < allGroups.size(); i++) { 
                                        if (allGroups[i] != "xxx") {
@@ -269,7 +251,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                }else if ((mode == "unweighted") || (mode == "parsimony")) {
                                //if the user only entered invalid groups
                                if ((userGroups.size() == 0) && (numGroups == 0)) { 
-                                       cout << "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." << endl; 
+                                       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();
                                        for (int i = 0; i < allGroups.size(); i++) {
                                                if (allGroups[i] != "xxx") {
                                                        userGroups.push_back(allGroups[i]);
@@ -281,11 +263,7 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "setGroups");
                exit(1);
        }
 }
@@ -303,11 +281,7 @@ void SharedUtil::getCombos(vector<string>& groupComb, vector<string> userGroups,
                } 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "getCombos");
                exit(1);
        }
 }
@@ -321,11 +295,7 @@ bool SharedUtil::isValidGroup(string groupname, vector<string> groups) {
                return false;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "isValidGroup");
                exit(1);
        }
 }
@@ -339,11 +309,7 @@ void SharedUtil::updateGroupIndex(vector<string>& userGroups, map<string, int>&
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedUtil class function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SharedUtil", "updateGroupIndex");
                exit(1);
        }
 }
index 3d1c2778387a0beec550a0c6086b9fb06281338d..2be566caa5232006cc073e9d59798dbbea43915b 100644 (file)
--- a/shen.cpp
+++ b/shen.cpp
@@ -33,13 +33,9 @@ EstOutput Shen::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Shen", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 };
 
 
index 758c4a39b8d7638b2abf07b37539b71e56de7ed2..d260800a9f80368295c2c1a099dd0a3dd3af8a30 100644 (file)
@@ -58,13 +58,9 @@ EstOutput Simpson::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Simpson class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Simpson", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Simpson class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index a024453cf43f5a999703b9e649a99913f5f4d27f..5332e907d27b86d13f40c411baa4a96cbf879f40 100644 (file)
@@ -59,13 +59,9 @@ void SingleLinkage::update(){
                dMatrix->rmCell(rowCells[0]);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SingleLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SingleLinkage", "update");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SingleLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index a9710ded9303b2f93373216bf2d22ba3c81c527c..219c7094390ec43767806a0255e033774d31ab4d 100644 (file)
@@ -45,14 +45,9 @@ vector<vector<double> > SLibshuff::evaluateAll(){
                return dCXYValues;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SLibshuff class Function evaluateAll. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SLibshuff", "evaluateAll");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SLibshuff class function evaluateAll. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /***********************************************************************/
@@ -103,14 +98,9 @@ double SLibshuff::sCalculate(int x, int y){
                return sum;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SLibshuff class Function sCalculate. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SLibshuff", "sCalculate");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SLibshuff class function sCalculate. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-       
 }
 
 /***********************************************************************/
index e227a9d2207c0f280c9840965a22789b7fe413cf..d29b9c9a7967d8683a1199609e06bae123cec632 100644 (file)
--- a/solow.cpp
+++ b/solow.cpp
@@ -26,13 +26,9 @@ EstOutput Solow::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Solow", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
index c4120f49d679ffc497ba72e7e0da8fc0fc22c00a..7f1c3c8564d29c6b1c551f7ee9bd16b58636af0a 100644 (file)
@@ -35,13 +35,9 @@ void SparseMatrix::rmCell(MatData data){
        //  clustering and the clustering algorithm updates smallDist
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function rmCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "rmCell");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function rmCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -55,13 +51,9 @@ void SparseMatrix::addCell(PCell value){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function addCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "addCell");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function addCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -75,13 +67,9 @@ void SparseMatrix::clear(){
                smallDist = 1e6;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function clear. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "clear");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function clear. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -101,22 +89,20 @@ MatData SparseMatrix::end(){
 void SparseMatrix::print(){
        try {
                int index = 0;
-       
-               cout << endl << "Index\tRow\tColumn\tDistance" << endl;
+               
+               mothurOutEndLine();
+               mothurOut("Index\tRow\tColumn\tDistance");
+               mothurOutEndLine();
        
                for(MatData currentCell=matrix.begin();currentCell!=matrix.end();currentCell++){
-                       cout << index << '\t' << currentCell->row  << '\t' << currentCell->column << '\t' << currentCell->dist << endl;
+                       mothurOut(toString(index) + "\t" + toString(currentCell->row)  + "\t" + toString(currentCell->column) + "\t" + toString(currentCell->dist)); mothurOutEndLine();
                        index++;
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -125,21 +111,20 @@ void SparseMatrix::print(ListVector* list){
        try {
                int index = 0;
        
-               cout << endl << "Index\tRow\tColumn\tDistance" << endl;
+               mothurOutEndLine();
+               mothurOut("Index\tRow\tColumn\tDistance");
+               mothurOutEndLine();
+
        
                for(MatData currentCell=matrix.begin();currentCell!=matrix.end();currentCell++){
-                       cout << index << '\t' << list->get(currentCell->row)  << '\t' << list->get(currentCell->column) << '\t' << currentCell->dist << endl;
+                       mothurOut(toString(index) + "\t" + toString(list->get(currentCell->row))  + "\t" + toString(list->get(currentCell->column)) + "\t" + toString(currentCell->dist)); mothurOutEndLine();
                        index++;
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -189,13 +174,9 @@ PCell* SparseMatrix::getSmallestCell(){
                return smallCell;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SparseMatrix class Function getSmallestCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SparseMatrix", "getSmallestCell");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SparseMatrix class function getSmallestCell. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
index 5e6fd10455ce5557033234a470d7bd68fed37c41..5bcd8e96c0be725ee978ba74a4d32bb36b3aa4e0 100644 (file)
 SuffixDB::SuffixDB(string fastaFileName) : Database(fastaFileName) {
 
        suffixForest.resize(numSeqs);
-       cout << "Generating the suffix tree database...\t";     cout.flush();
+       mothurOut("Generating the suffix tree database...\t");  cout.flush();
        for(int i=0;i<numSeqs;i++){                                                             //      The parent class' constructor generates the vector of
                suffixForest[i].loadSequence(templateSequences[i]);     //      template Sequence objects.  Here each of these objects
        }                                                                                                               //      is used to generate a suffix tree, aka the suffix forest
-       cout << "DONE." << endl << endl;        cout.flush();
+       mothurOut("DONE."); mothurOutEndLine(); mothurOutEndLine(); cout.flush();
 
 }
 
index 81346953d6de431b00b57dad5b8c3681a15e153e..1e5d7056edb318813f8e699288810a31c096006b 100644 (file)
@@ -57,14 +57,14 @@ SuffixLeaf::SuffixLeaf(int parent, int start, int end) : SuffixNode(parent, star
 
 void SuffixLeaf::print(string sequence, int nodeNumber){
        
-       cout << this << '\t' << parentNode << '\t' << nodeNumber << '\t' <<
-       -1 << '\t' << startCharPosition << '\t' << endCharPosition << '\t';
+       mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" +
+       toString(-1) + "\t" + toString(startCharPosition) + "\t" + toString(endCharPosition) + "\t");
        
-       cout << '\'';
+       mothurOut("/");
        for(int i=startCharPosition;i<=endCharPosition;i++){
-               cout << deCodeSequence(sequence[i]);
+               mothurOut(toString(deCodeSequence(sequence[i])));
        }
-       cout << '\'' << endl;
+       mothurOut("/");  mothurOutEndLine();
 }
 
 //********************************************************************************************************************
@@ -74,14 +74,14 @@ SuffixBranch::SuffixBranch(int parent, int start, int end) : SuffixNode(parent,
 }
        
 void SuffixBranch::print(string sequence, int nodeNumber){                                             //      this method is different that than
-       cout << this << '\t' << parentNode << '\t' << nodeNumber << '\t' <<                     //      of a leaf because it prints out a
-       suffixNode << '\t' << startCharPosition << '\t' << endCharPosition << '\t';     //      value for the suffix node       
+       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
        
-       cout << '\'';
+       mothurOut("/");
        for(int i=startCharPosition;i<=endCharPosition;i++){
-               cout << deCodeSequence(sequence[i]);
+               mothurOut(toString(deCodeSequence(sequence[i])));
        }
-       cout << '\'' << endl;
+       mothurOut("/");  mothurOutEndLine();
 }
 
 //     we can access the children by subtracting '0' from the the char value from the string, the difference is an int
index 0dbe2c0e41e6bd68df024f411c0883bdd306fe8b..53a6d3f8bc690ffec892d31eec5cb47a59ecd0e2 100644 (file)
@@ -75,7 +75,7 @@ string SuffixTree::getSeqName()       {
 void SuffixTree::print(){
        vector<SuffixNode*> hold = nodeVector;
        sort(hold.begin(), hold.end(), compareParents);
-       cout << "Address\t\tParent\tNode\tSuffix\tStartC\tEndC\tSuffix" << endl;
+       mothurOut("Address\t\tParent\tNode\tSuffix\tStartC\tEndC\tSuffix"); mothurOutEndLine();
        for(int i=1;i<=nodeCounter;i++){
                hold[i]->print(sequence, i);
        }
index e228dbe7bcdef90bc829098091a8e1794c1d5114..228b93344d50967a065328be487dc30fc1d6c34c 100644 (file)
@@ -59,7 +59,7 @@ SummaryCommand::SummaryCommand(string option){
                        }
                        
                        //make sure the user has already run the read.otu command
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the summary.single command." << endl; abort = true; }
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the summary.single command."); mothurOutEndLine(); abort = true; }
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -78,7 +78,7 @@ SummaryCommand::SummaryCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -158,37 +158,29 @@ SummaryCommand::SummaryCommand(string option){
                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummaryCommand", "SummaryCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummaryCommand class function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void SummaryCommand::help(){
        try {
-               cout << "The summary.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
-               cout << "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";
-               cout << "The summary.single command parameters are label, line, calc, abund.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The summary.single command should be in the following format: " << "\n";
-               cout << "summary.single(label=yourLabel, line=yourLines, calc=yourEstimators)." << "\n";
-               cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
+               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, line, calc, abund.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The summary.single command should be in the following format: \n");
+               mothurOut("summary.single(label=yourLabel, line=yourLines, calc=yourEstimators).\n");
+               mothurOut("Example summary.single(label=unique-.01-.03, line=0,5,10, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson).\n");
                validCalculator->printCalc("summary", cout);
-               cout << "The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson" << "\n";
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
+               mothurOut("The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson\n");
+               mothurOut("The label and line parameters are used to analyze specific lines in your input.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummaryCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummaryCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -244,7 +236,7 @@ int SummaryCommand::execute(){
                        
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(sabund->getLabel()) == 1){                  
        
-                               cout << sabund->getLabel() << '\t' << count << endl;
+                               mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(sabund->getLabel());
                                userLabels.erase(sabund->getLabel());
                                userLines.erase(count);
@@ -263,7 +255,7 @@ int SummaryCommand::execute(){
                                delete sabund;
                                sabund = input->getSAbundVector(lastLabel);
                                
-                               cout << sabund->getLabel() << '\t' << count << endl;
+                               mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                processedLabels.insert(sabund->getLabel());
                                userLabels.erase(sabund->getLabel());
                                
@@ -287,12 +279,12 @@ int SummaryCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -301,7 +293,7 @@ int SummaryCommand::execute(){
                        delete sabund;
                        sabund = input->getSAbundVector(lastLabel);
                        
-                       cout << sabund->getLabel() << '\t' << count << endl;
+                       mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        outputFileHandle << sabund->getLabel();
                        for(int i=0;i<sumCalculators.size();i++){
                                vector<double> data = sumCalculators[i]->getValues(sabund);
@@ -317,13 +309,9 @@ int SummaryCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummaryCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummaryCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
index 9f815cdebea9b9bf839dee9a5f885972d3caf992..253c3382d9cfcfc94a59a90e990bf2474afe1ac5 100644 (file)
@@ -64,7 +64,7 @@ SummarySharedCommand::SummarySharedCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
-                                cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true; 
+                                mothurOut("You must read a list and a group, or a shared before you can use the summary.shared command."); mothurOutEndLine(); abort = true; 
                        }
                        
                        //check for optional parameter and set defaults
@@ -84,7 +84,7 @@ SummarySharedCommand::SummarySharedCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -166,39 +166,31 @@ SummarySharedCommand::SummarySharedCommand(string option){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummarySharedCommand class function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void SummarySharedCommand::help(){
        try {
-               cout << "The summary.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The summary.shared command parameters are label, line and calc.  No parameters are required, but you may not use " << "\n";
-               cout << "both the line and label parameters at the same time. The summary.shared command should be in the following format: " << "\n";
-               cout << "summary.shared(label=yourLabel, line=yourLines, calc=yourEstimators, groups=yourGroups)." << "\n";
-               cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
+               mothurOut("The summary.shared command can only be executed after a successful read.otu command.\n");
+               mothurOut("The summary.shared command parameters are label, line and calc.  No parameters are required, but you may not use \n");
+               mothurOut("both the line and label parameters at the same time. The summary.shared command should be in the following format: \n");
+               mothurOut("summary.shared(label=yourLabel, line=yourLines, calc=yourEstimators, groups=yourGroups).\n");
+               mothurOut("Example summary.shared(label=unique-.01-.03, line=0,5,10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
                validCalculator->printCalc("sharedsummary", cout);
-               cout << "The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan" << "\n";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
-               cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "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";
-               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
+               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 and line parameters are used to analyze specific lines 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. line), '=' and parameters (i.e.yourLines).\n\n");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummarySharedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummarySharedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
@@ -258,7 +250,7 @@ int SummarySharedCommand::execute(){
                }
                
                if (lookup.size() < 2) { 
-                       cout << "I cannot run the command without at least 2 valid groups."
+                       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
@@ -281,7 +273,7 @@ int SummarySharedCommand::execute(){
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -293,7 +285,7 @@ int SummarySharedCommand::execute(){
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        process(lookup);
                                        
                                        processedLabels.insert(lookup[0]->getLabel());
@@ -315,12 +307,12 @@ int SummarySharedCommand::execute(){
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -329,7 +321,7 @@ int SummarySharedCommand::execute(){
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                lookup = input->getSharedRAbundVectors(lastLabel);
 
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
@@ -349,13 +341,9 @@ int SummarySharedCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummarySharedCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummarySharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************/
@@ -415,13 +403,9 @@ void SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "SummarySharedCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SummarySharedCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************/
index ee17e6f37f6417d24546697e3247c21f34d1d0aa..ce3de379d05d5eca8c991d2e93e64060377a2304 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -42,13 +42,9 @@ Tree::Tree() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function Tree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "Tree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function Tree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
@@ -63,13 +59,9 @@ int Tree::getIndex(string searchName) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function getIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "getIndex");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function getIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 
@@ -79,13 +71,9 @@ void Tree::setIndex(string searchName, int index) {
                globaldata->gTreemap->setIndex(searchName, index);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function setIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "setIndex");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function setIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 void Tree::assembleTree() {
@@ -97,13 +85,9 @@ void Tree::assembleTree() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function assembleTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "assembleTree");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function assembleTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 void Tree::getCopy(Tree* copy) {
@@ -138,13 +122,9 @@ void Tree::getCopy(Tree* copy) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function getCopy. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "getCopy");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function getCopy. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 //returns a map with a groupname and the number of times that group was seen in the children
@@ -196,13 +176,9 @@ map<string, int> Tree::mergeGroups(int i) {
                return parsimony;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function mergeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "mergeGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function mergeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 //returns a map with a groupname and the number of times that group was seen in the children
@@ -261,13 +237,9 @@ map<string, int> Tree::mergeUserGroups(int i, vector<string> g) {
                return parsimony;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function mergeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "mergeUserGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function mergeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 
@@ -288,13 +260,9 @@ map<string,int> Tree::mergeGcounts(int position) {
                return sum;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function mergeGcounts. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "mergeGcounts");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function mergeGcounts. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 
@@ -334,13 +302,9 @@ void Tree::randomLabels(vector<string> g) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function randomLabels. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "randomLabels");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function randomLabels. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 
@@ -368,13 +332,9 @@ void Tree::randomLabels(string groupA, string groupB) {
                }
        }               
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function randomLabels. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "randomLabels");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function randomLabels. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /**************************************************************************************************/
 void Tree::randomBlengths()  {
@@ -388,13 +348,9 @@ void Tree::randomBlengths()  {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function randomBlengths. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "randomBlengths");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function randomBlengths. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*************************************************************************************************/
 void Tree::assembleRandomUnifracTree(vector<string> g) {
@@ -447,13 +403,9 @@ void Tree::randomTopology() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function randomTopology. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "randomTopology");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function randomTopology. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 void Tree::print(ostream& out) {
@@ -463,13 +415,9 @@ void Tree::print(ostream& out) {
                out << ";" << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*****************************************************************/
 void Tree::printForBoot(ostream& out) {
@@ -479,13 +427,9 @@ void Tree::printForBoot(ostream& out) {
                out << ";" << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function printForBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "printForBoot");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function printForBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
@@ -505,13 +449,9 @@ void Tree::createNewickFile(string f) {
                out.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function createNewickFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "createNewickFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function createNewickFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
@@ -528,13 +468,9 @@ int Tree::findRoot() {
                return -1;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function findRoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "findRoot");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function findRoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
@@ -576,13 +512,9 @@ void Tree::printBranch(int node, ostream& out, string mode) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "printBranch");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /*****************************************************************/
@@ -671,13 +603,9 @@ void Tree::parseTreeFile() {
                filehandle.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function parseTreeFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "parseTreeFile");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function parseTreeFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /*******************************************************/
 
@@ -685,19 +613,28 @@ void Tree::parseTreeFile() {
 void Tree::readTreeString(ifstream& filehandle)        {
        try {
                int c;
-               string name; //k
+               string name;// k;
                
                while((c = filehandle.peek()) != ';') { 
-                               //ifyou are a name
+//k = c;
+//cout << " at beginning of while " <<  k << endl;                     
+                       if(c == ')')  {    
+                               //to pass over labels in trees
+                               c=filehandle.get();
+                               while((c!=',') && (c != -1) && (c!= ':') && (c!=';')){ c=filehandle.get(); }
+                               filehandle.putback(c);
+                       }
+                       if(c == ';') { break; }
+                       //if you are a name
                        if((c != '(') && (c != ')') && (c != ',') && (c != ':') && (c != '\n') && (c != '\t') && (c != 32)) { //32 is space
                                name = "";
                                c = filehandle.get();
-       //              k = c;
+                       //k = c;
 //cout << k << endl;
                                while ((c != '(') && (c != ')') && (c != ',') && (c != ':') && (c != '\n') && (c != 32) && (c != '\t')) {                       
                                        name += c;
                                        c = filehandle.get();
-               //      k = c;
+                       //k = c;
 //cout << " in name while " << k << endl;
                                }
                                
@@ -711,26 +648,24 @@ void Tree::readTreeString(ifstream& filehandle)   {
                        if(c  == ':') { //read until you reach the end of the branch length
                                while ((c != '(') && (c != ')') && (c != ',') && (c != ';') && (c != '\n') && (c != '\t') && (c != 32)) {
                                        c = filehandle.get();
-                               //      k = c;
+                                       //k = c;
        //cout << " in branch while " << k << endl;
                                }
                                filehandle.putback(c);
                        }
+                       
                        c = filehandle.get();
                        if(c == ';') { break; }
-               //      k = c;
+                       if(c == ')') { filehandle.putback(c); }
+       //              k = c;
 //cout << k << endl;
 
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function parseTreeFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Tree", "readTreeString");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function parseTreeFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }      
 
 /*******************************************************/
index cb80ca82d49a68b640476691d30d695c6599d44d..cb797d8d229fd0a2dfaff82d431b084bd0a227a5 100644 (file)
@@ -69,11 +69,11 @@ TreeGroupCommand::TreeGroupCommand(string option){
                        format = globaldata->getFormat();
                        
                        //error checking on files                       
-                       if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == "")))  { cout << "You must run the read.otu command or provide a distance file before running the tree.shared command." << endl; abort = true; }
-                       else if ((phylipfile != "") && (columnfile != "")) { cout << "When running the tree.shared command with a distance file you may not use both the column and the phylip parameters." << endl; abort = true; }
+                       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 (columnfile != "") {
-                               if (namefile == "") {  cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
+                               if (namefile == "") {  mothurOut("You need to provide a namefile if you are going to use the column format."); mothurOutEndLine(); abort = true; }
                        }
 
                        //check for optional parameter and set defaults
@@ -93,7 +93,7 @@ TreeGroupCommand::TreeGroupCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -161,44 +161,36 @@ TreeGroupCommand::TreeGroupCommand(string option){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function TreeGroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function TreeGroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void TreeGroupCommand::help(){
        try {
-               cout << "The tree.shared command creates a .tre to represent the similiarity between groups or sequences." << "\n";
-               cout << "The tree.shared command can only be executed after a successful read.otu command or by providing a distance file." << "\n";
-               cout << "The tree.shared command parameters are groups, calc, phylip, column, name, cutoff, precision, line and label.  You may not use line and label at the same time." << "\n";
-               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example tree.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorabund)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile." << "\n";
-               cout << "The default value for calc is jclass-thetayc." << "\n";
-               cout << "The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose." << "\n";
+               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, line and label.  You may not use line and label at the same time.\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 line and 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, line=yourLines, label=yourLabels).\n");
+               mothurOut("Example tree.shared(groups=A-B-C, line=1-3-5, 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");
                validCalculator->printCalc("treegroup", cout);
-               cout << "Or the tree.shared command can be in the following format: tree.shared(phylip=yourPhylipFile)." << "\n";
-               cout << "Example tree.shared(phylip=abrecovery.dist)." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -224,7 +216,7 @@ int TreeGroupCommand::execute(){
                
                if (format == "sharedfile") {
                        //if the users entered no valid calculators don't execute command
-                       if (treeCalculators.size() == 0) { cout << "You have given no valid calculators." << endl; return 0; }
+                       if (treeCalculators.size() == 0) { mothurOut("You have given no valid calculators."); mothurOutEndLine(); return 0; }
 
                        //you have groups
                        read = new ReadOTUFile(globaldata->inputFileName);      
@@ -234,7 +226,7 @@ int TreeGroupCommand::execute(){
                        lookup = input->getSharedRAbundVectors();
                        lastLabel = lookup[0]->getLabel();
                        
-                       if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0; }
+                       if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups.  I cannot run the command."); mothurOutEndLine(); return 0; }
                
                        globaldata->runParse = false;
                        
@@ -282,7 +274,7 @@ int TreeGroupCommand::execute(){
                        outputFile = getRootName(globaldata->inputFileName) + "tre";    
                                
                        createTree();
-                       cout << "Tree complete. " << endl;
+                       mothurOut("Tree complete. "); mothurOutEndLine();
                }
                                
                //reset groups parameter
@@ -291,13 +283,9 @@ int TreeGroupCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 //**********************************************************************************************************************
 
@@ -372,11 +360,7 @@ void TreeGroupCommand::createTree(){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "createTree");
                exit(1);
        }
 }
@@ -400,13 +384,9 @@ void TreeGroupCommand::printSims(ostream& out) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "printSims");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 void TreeGroupCommand::makeSimsDist() {
@@ -437,13 +417,9 @@ void TreeGroupCommand::makeSimsDist() {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function makeSimsDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "makeSimsDist");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function makeSimsDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************/
@@ -470,7 +446,7 @@ void TreeGroupCommand::makeSimsShared() {
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
                
                        if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -482,7 +458,7 @@ void TreeGroupCommand::makeSimsShared() {
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                lookup = input->getSharedRAbundVectors(lastLabel);
 
-                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                process(lookup);
                                        
                                processedLabels.insert(lookup[0]->getLabel());
@@ -501,12 +477,12 @@ void TreeGroupCommand::makeSimsShared() {
                set<string>::iterator it;
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       cout << "Your file does not include the label "<< *it
+                       mothurOut("Your file does not include the label " + *it)
                        if (processedLabels.count(lastLabel) != 1) {
-                               cout << ". I will use " << lastLabel << "." << endl;
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLabel << "." << endl;
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                        }
                }
                
@@ -515,7 +491,7 @@ void TreeGroupCommand::makeSimsShared() {
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                        process(lookup);
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }         
                }
@@ -523,13 +499,9 @@ void TreeGroupCommand::makeSimsShared() {
                for(int i = 0 ; i < treeCalculators.size(); i++) {  delete treeCalculators[i]; }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function makeSimsShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "makeSimsShared");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function makeSimsShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************/
@@ -580,13 +552,9 @@ void TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeGroupCommand", "process");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeGroupCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************/
 
index ad8a2af17ac2b8fe954c3bff402f6d1bb20381db..044e87ca6c603f8762edc863e5adf827ede73bad 100644 (file)
@@ -116,11 +116,7 @@ bool TreeMap::isValidGroup(string groupname) {
                return false;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeMap class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeMap", "isValidGroup");
                exit(1);
        }
 }
@@ -134,11 +130,7 @@ void TreeMap::print(ostream& output){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeMap class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeMap", "print");
                exit(1);
        }
 }
@@ -162,11 +154,7 @@ void TreeMap::makeSim(GroupMap* groupmap) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function makeSim. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeMap class function makeSim. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeMap", "makeSim");
                exit(1);
        }
 }
@@ -192,11 +180,7 @@ void TreeMap::makeSim(ListVector* list) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function makeSim. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TreeMap class function makeSim. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TreeMap", "makeSim");
                exit(1);
        }
 }
index fc6ea3a595ac752e943151a84ce6a538f6d66670..54cdae4e502250229a6e70e5ce937a631a843b1e 100644 (file)
@@ -60,31 +60,27 @@ int Node::getIndex() { return vectorIndex; }
 //to be used by printTree in the Tree class to print the leaf info                     
 void Node::printNode() {
        try{
-               cout << parent << ' ' << lchild << ' ' << rchild << ' ' << group;
+               mothurOut(toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " " + group);
                //there is a branch length
                if (branchLength != -1) { 
-                       cout << ' ' << setprecision(4) << branchLength
+                       mothurOut(" " + toString(branchLength))
                }
-               cout << " |";
+               mothurOut(" |");
                map<string, int>::iterator it;
                for(it=pGroups.begin();it!=pGroups.end();it++){
-                       cout << ' ' << it->first << ':' << it->second;
+                       mothurOut(" " + it->first + ":" + toString(it->second));
                }
-               cout << " |";
+               mothurOut(" |");
                for(it=pcount.begin();it!=pcount.end();it++){
-                       cout << ' ' << it->first << ':' << it->second;
+                       mothurOut(" " + it->first + ":" + toString(it->second));
                }
-               cout << endl; 
+               mothurOutEndLine();
                
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Node class Function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Node", "printNode");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Node class function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /****************************************************************/     
index 1989365a5a2a653d54c6b4258f65deaceac079c6..ef0c06649af1afb64458bf153457bdadda566999 100644 (file)
@@ -37,7 +37,7 @@ TrimSeqsCommand::TrimSeqsCommand(string option){
                        
                        //check for required parameters
                        fastaFile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastaFile == "not found") { cout << "fasta is a required parameter for the screen.seqs command." << endl; abort = true; }
+                       if (fastaFile == "not found") { mothurOut("fasta is a required parameter for the screen.seqs command."); mothurOutEndLine(); abort = true; }
                        else if (fastaFile == "not open") { abort = true; }     
                
                
@@ -80,57 +80,49 @@ TrimSeqsCommand::TrimSeqsCommand(string option){
                        allFiles = isTrue(temp);
                        
                        if(allFiles && oligoFile == ""){
-                               cout << "You selected allfiles, but didn't enter an oligos file.  Ignoring the allfiles request." << endl;
+                               mothurOut("You selected allfiles, but didn't enter an oligos file.  Ignoring the allfiles request."); mothurOutEndLine();
                        }
                        if((qAverage != 0 && qThreshold != 0) && qFileName == ""){
-                               cout << "You didn't provide a quality file name, quality criteria will be ignored." << endl;
+                               mothurOut("You didn't provide a quality file name, quality criteria will be ignored."); mothurOutEndLine();
                                qAverage=0;
                                qThreshold=0;
                        }
                        if(!flip && oligoFile=="" && !maxLength && !minLength && (maxAmbig==-1) && !maxHomoP && qFileName == ""){               
-                               cout << "You didn't set any options... quiting command." << endl;
+                               mothurOut("You didn't set any options... quiting command."); mothurOutEndLine();
                                abort = true;
                        }
                }
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TrimSeqsCommand class Function TrimSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TrimSeqsCommand class function TrimSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void TrimSeqsCommand::help(){
        try {
-               cout << "The trim.seqs command reads a fastaFile and creates ....." << "\n";
-               cout << "The trim.seqs command parameters are fasta, flip, oligos, maxambig, maxhomop, minlength and maxlength." << "\n";
-               cout << "The fasta parameter is required." << "\n";
-               cout << "The flip parameter .... The default is 0." << "\n";
-               cout << "The oligos parameter .... The default is ""." << "\n";
-               cout << "The maxambig parameter .... The default is -1." << "\n";
-               cout << "The maxhomop parameter .... The default is 0." << "\n";
-               cout << "The minlength parameter .... The default is 0." << "\n";
-               cout << "The maxlength parameter .... The default is 0." << "\n";
-               cout << "The trim.seqs command should be in the following format: " << "\n";
-               cout << "trim.seqs(fasta=yourFastaFile, flip=yourFlip, oligos=yourOligos, maxambig=yourMaxambig,  " << "\n";
-               cout << "maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength)  " << "\n";    
-               cout << "Example trim.seqs(fasta=abrecovery.fasta, flip=..., oligos=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...)." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta)." << "\n" << "\n";
+               mothurOut("The trim.seqs command reads a fastaFile and creates .....\n");
+               mothurOut("The trim.seqs command parameters are fasta, flip, oligos, maxambig, maxhomop, minlength and maxlength.\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 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\n");
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TrimSeqsCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TrimSeqsCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the TrimSeqsCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -256,11 +248,7 @@ int TrimSeqsCommand::execute(){
                return 0;               
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the TrimSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the TrimSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "TrimSeqsCommand", "execute");
                exit(1);
        }
 }
@@ -476,7 +464,7 @@ bool TrimSeqsCommand::stripQualThreshold(Sequence& seq, ifstream& qFile){
        string name;
        
        qFile >> name;
-       if(name.substr(1) != seq.getName())     {       cout << "sequence name mismatch btwn fasta and qual file" << endl;      }
+       if(name.substr(1) != seq.getName())     {       mothurOut("sequence name mismatch btwn fasta and qual file"); mothurOutEndLine();       }
        while (!qFile.eof())    {       char c = qFile.get(); if (c == 10 || c == 13){  break;  }       }
        
        int score;
@@ -509,7 +497,7 @@ bool TrimSeqsCommand::cullQualAverage(Sequence& seq, ifstream& qFile){
        string name;
        
        qFile >> name;
-       if(name.substr(1) != seq.getName())     {       cout << "sequence name mismatch btwn fasta and qual file" << endl;      }
+       if(name.substr(1) != seq.getName())     {       mothurOut("sequence name mismatch btwn fasta and qual file"); mothurOutEndLine();       }
        while (!qFile.eof())    {       char c = qFile.get(); if (c == 10 || c == 13){  break;  }       }
        
        float score;    
index 154c528a851eb297a0783e26bb206aae80fc278c..7f851214453801eca61ec8752c6150fda10b0655 100644 (file)
@@ -35,7 +35,7 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) {
                        }
                        
                        if (globaldata->gTree.size() == 0) {//no trees were read
-                               cout << "You must execute the read.tree command, before you may execute the unifrac.unweighted command." << endl; abort = true;  }
+                               mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); mothurOutEndLine(); abort = true;  }
                                                                                
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -70,11 +70,7 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function UnifracUnweightedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracUnweightedCommand class function UnifracUnweightedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
                exit(1);
        }
 }
@@ -83,24 +79,20 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) {
 
 void UnifracUnweightedCommand::help(){
        try {
-               cout << "The unifrac.unweighted command can only be executed after a successful read.tree command." << "\n";
-               cout << "The unifrac.unweighted command parameters are groups and iters.  No parameters are required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The unifrac.unweighted command should be in the following format: unifrac.unweighted(groups=yourGroups, iters=yourIters)." << "\n";
-               cout << "Example unifrac.unweighted(groups=A-B-C, iters=500)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile, and iters is 1000." << "\n";
-               cout << "The unifrac.unweighted command output two files: .unweighted and .uwsummary their descriptions are in the manual." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               mothurOut("The unifrac.unweighted command can only be executed after a successful read.tree command.\n");
+               mothurOut("The unifrac.unweighted command parameters are 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 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracUnweightedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracUnweightedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -115,7 +107,7 @@ int UnifracUnweightedCommand::execute() {
                //create new tree with same num nodes and leaves as users
                
                outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "UWScore" <<'\t' << "UWSig" <<  endl;
-               cout << "Tree#" << '\t' << "Groups" << '\t'  <<  "UWScore" << '\t' << "UWSig" <<  endl;
+               mothurOut("Tree#\tGroups\tUWScore\tUWSig"); mothurOutEndLine();
                
                //get pscores for users trees
                for (int i = 0; i < T.size(); i++) {
@@ -193,11 +185,7 @@ int UnifracUnweightedCommand::execute() {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracUnweightedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracUnweightedCommand", "execute");
                exit(1);
        }
 }
@@ -220,11 +208,7 @@ void UnifracUnweightedCommand::printUnweightedFile() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function printUnweightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracUnweightedCommand class function printUnweightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracUnweightedCommand", "printUnweightedFile");
                exit(1);
        }
 }
@@ -240,24 +224,22 @@ void UnifracUnweightedCommand::printUWSummaryFile(int i) {
 
                for(int a = 0; a < numComp; a++) {
                        outSum << i+1 << '\t';
-                       cout << i+1 << '\t';
+                       mothurOut(toString(i+1) + "\t");
                        
                        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(); 
                        }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();
                        }
                }
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function printUWSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracUnweightedCommand class function printUWSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracUnweightedCommand", "printUWSummaryFile");
                exit(1);
        }
 }
index cf54e6420e6b1e4e2c54c87672142b0fb89dc655..fb3eb3ca2158d766a57b1f22c3a9c57bfe573370 100644 (file)
@@ -35,7 +35,7 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) {
                        }
                        
                        if (globaldata->gTree.size() == 0) {//no trees were read
-                               cout << "You must execute the read.tree command, before you may execute the unifrac.weighted command." << endl; abort = true;  }
+                               mothurOut("You must execute the read.tree command, before you may execute the unifrac.weighted command."); mothurOutEndLine(); abort = true;  }
                                                                                
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -69,11 +69,7 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function UnifracWeightedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function UnifracWeightedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
                exit(1);
        }
 }
@@ -81,24 +77,20 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) {
 
 void UnifracWeightedCommand::help(){
        try {
-               cout << "The unifrac.weighted command can only be executed after a successful read.tree command." << "\n";
-               cout << "The unifrac.weighted command parameters are groups and iters.  No parameters are required." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The unifrac.weighted command should be in the following format: unifrac.weighted(groups=yourGroups, iters=yourIters)." << "\n";
-               cout << "Example unifrac.weighted(groups=A-B-C, iters=500)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile, and iters is 1000." << "\n";
-               cout << "The unifrac.weighted command output two files: .weighted and .wsummary their descriptions are in the manual." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               mothurOut("The unifrac.weighted command can only be executed after a successful read.tree command.\n");
+               mothurOut("The unifrac.weighted command parameters are 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 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 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************/
@@ -170,7 +162,7 @@ int UnifracWeightedCommand::execute() {
                                //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) { cout << "error in UnifracWeightedCommand" << endl; exit(1); } //error code
+                               int index = findIndex(userData[f], f);    if (index == -1) { mothurOut("error in UnifracWeightedCommand"); 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);
@@ -203,11 +195,7 @@ int UnifracWeightedCommand::execute() {
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "execute");
                exit(1);
        }
 }
@@ -230,11 +218,7 @@ void UnifracWeightedCommand::printWeightedFile() {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function printWeightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function printWeightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "printWeightedFile");
                exit(1);
        }
 }
@@ -245,7 +229,7 @@ void UnifracWeightedCommand::printWSummaryFile() {
        try {
                //column headers
                outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" <<  endl;
-               cout << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" <<  endl;
+               mothurOut("Tree#\tGroups\tWScore\tWSig"); mothurOutEndLine(); 
                
                //format output
                outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
@@ -257,9 +241,11 @@ void UnifracWeightedCommand::printWSummaryFile() {
                                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();  
                                }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();  
                                }
                                count++;
                        }
@@ -267,11 +253,7 @@ void UnifracWeightedCommand::printWSummaryFile() {
                outSum.close();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function printWeightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function printWeightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "printWSummaryFile");
                exit(1);
        }
 }
@@ -285,11 +267,7 @@ int UnifracWeightedCommand::findIndex(float score, int index) {
                return rScores[index].size();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function findIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function findIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "findIndex");
                exit(1);
        }
 }
@@ -334,14 +312,9 @@ void UnifracWeightedCommand::calculateFreqsCumuls() {
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function calculateFreqsCums. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UnifracWeightedCommand", "calculateFreqsCums");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the UnifracWeightedCommand class function calculateFreqsCums. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /***********************************************************/
index b3f50c8895371e326b0e3c72614e4c1c4f92888b..687786a71e783bdb4df476eb17d6864e07238974 100644 (file)
@@ -181,14 +181,9 @@ EstOutput Unweighted::getValues(Tree* t) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Unweighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Unweighted", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Unweighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /**************************************************************************************************/
@@ -379,11 +374,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Unweighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Unweighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Unweighted", "getValues");
                exit(1);
        }
 }
index 819be0af66bbdb23d989587ee4c6ca676677ea76..afc602284e7aadb41c9859441157588ec21b6198 100644 (file)
--- a/uvest.cpp
+++ b/uvest.cpp
@@ -80,15 +80,9 @@ EstOutput UVEst::getUVest(vector<SharedRAbundVector*> shared) {
                return results;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the UVEst class Function getUVest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "UVEst", "getUVest");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the UVEst class Function getUVest. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
-
 }
 
 /***********************************************************************/
index 3e698bf19c67bfe46819df2a1bd10de2a0299b5b..504eb7103ee7e59c998cb438f520f3204a970c29 100644 (file)
@@ -27,13 +27,9 @@ ValidCalculators::ValidCalculators() {
                 initialHeat();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "ValidCalculator");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }                
 }
 
 /********************************************************************/
@@ -50,11 +46,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((single.find(calculator)) != (single.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a shared parameter
                }else if (parameter == "shared") {
@@ -62,11 +58,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((shared.find(calculator)) != (shared.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a rarefaction parameter
                }else if (parameter == "rarefaction") {
@@ -74,11 +70,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((rarefaction.find(calculator)) != (rarefaction.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a summary parameter
                }else if (parameter == "summary") {
@@ -86,11 +82,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((summary.find(calculator)) != (summary.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a sharedsummary parameter
                }else if (parameter == "sharedsummary") {
@@ -98,112 +94,108 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "sharedrarefaction") {
                        //is it valid
                        if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "vennsingle") {
                        //is it valid
                        if ((vennsingle.find(calculator)) != (vennsingle.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "vennshared") {
                        //is it valid
                        if ((vennshared.find(calculator)) != (vennshared.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "treegroup") {
                        //is it valid
                        if ((treegroup.find(calculator)) != (treegroup.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "matrix") {
                        //is it valid
                        if ((matrix.find(calculator)) != (matrix.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "heat") {
                        //is it valid
                        if ((heat.find(calculator)) != (heat.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "boot") {
                        //is it valid
                        if ((boot.find(calculator)) != (boot.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                }else if (parameter == "distance") {
                        //is it valid
                        if ((distance.find(calculator)) != (distance.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ";
+                               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++) {
-                                       cout << it->first << ", ";
+                                       mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               mothurOutEndLine();
                                return false; }
                //not a valid parameter
                }else { return false; }
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "isValidCalculator");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -232,13 +224,9 @@ void ValidCalculators::initialSingle() {
                single["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialSingle");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -268,13 +256,9 @@ void ValidCalculators::initialShared() {
                shared["default"]                   = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialShared");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -293,13 +277,9 @@ void ValidCalculators::initialRarefaction() {
                rarefaction["default"]      = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialRarefaction");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -329,13 +309,9 @@ void ValidCalculators::initialSummary() {
                summary["default"]          = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialSummary");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -365,13 +341,9 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialSharedSummary");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -384,13 +356,9 @@ void ValidCalculators::initialSharedRarefact() {
                sharedrarefaction["default"]        = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialSharedRarefact");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -404,13 +372,9 @@ void ValidCalculators::initialVennSingle() {
                vennsingle["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialVennSingle");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -422,13 +386,9 @@ void ValidCalculators::initialVennShared() {
                vennshared["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialVennShared");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -446,13 +406,9 @@ void ValidCalculators::initialTreeGroups() {
                treegroup["braycurtis"]                         = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialTreeGroups");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /********************************************************************/
 void ValidCalculators::initialHeat() {
@@ -469,13 +425,9 @@ void ValidCalculators::initialHeat() {
                heat["braycurtis"]                      = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialHeat");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -493,13 +445,9 @@ void ValidCalculators::initialMatrix() {
                matrix["braycurtis"]                    = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialMatrix");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -517,13 +465,9 @@ void ValidCalculators::initialBoot() {
                boot["braycurtis"]                      = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialBoot");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /********************************************************************/
 void ValidCalculators::initialDistance() {
@@ -533,13 +477,9 @@ void ValidCalculators::initialDistance() {
                distance["onegap"]              = "onegap";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "initialDistance");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -608,14 +548,9 @@ void ValidCalculators::printCalc(string parameter, ostream& out) {
                out << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidCalculator", "printCalc");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
 }
 /********************************************************************/
 
index 486316fcdc814307e78e029f9fc7400451cd9393..ad8038ee40e60c74ee9cc02ab831195726c7bf27 100644 (file)
@@ -16,13 +16,9 @@ ValidParameters::ValidParameters() {
                initParameterRanges();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidParameters", "ValidParameters");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -42,11 +38,11 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        }
                }
                if(!valid) {
-                       cout << "'" << parameter << "' is not a valid parameter." << endl;
-                       cout << "The valid parameters are: ";
+                       mothurOut(parameter + " is not a valid parameter."); mothurOutEndLine();
+                       mothurOut("The valid parameters are: ");
                        for(int i = 0; i < numParams-1; i++)
-                               cout << cParams.at(i) << ", ";
-                       cout << "and " << cParams.at(numParams-1) << ".\n";
+                               mothurOut(cParams.at(i) + ", ");
+                       mothurOut("and " + cParams.at(numParams-1) + ".\n");
                        return false;
                }
                
@@ -77,7 +73,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                                double logNum = log10((double)pVal);
                                double diff = (double)((int)logNum - logNum);
                                if(diff != 0) {
-                                       cout << "The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n";
+                                       mothurOut("The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n");
                                        return false;
                                }
                        }
@@ -103,7 +99,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(4).compare("only") == 0)
                                c = 1;
                        else {
-                               cout << "The range can only be 'between' or 'only' the bounding numbers.\n";
+                               mothurOut("The range can only be 'between' or 'only' the bounding numbers.\n");
                                return false;
                        }
                        
@@ -112,7 +108,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
                                d = 1;
                        else {
-                               cout << "The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n";
+                               mothurOut("The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n");
                                return false;
                        }
                        
@@ -121,7 +117,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
                                e = 1;
                        else {
-                               cout << "The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n";
+                               mothurOut("The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n");
                                return false;
                        }
                        
@@ -165,25 +161,25 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        
                        
                        if(!valid) {
-                               cout << "The '" << parameter << "' parameter needs to be ";
+                               mothurOut("The '" + parameter + "' parameter needs to be ");
                                if(c == 1)
-                                       cout << "either '" << a << "' or '" << b << "'.\n";
+                                       mothurOut("either '" + toString(a) + "' or '" + toString(b) + "'.\n");
                                else {
                                        if(a != piSentinel) {
-                                               cout << ">";
+                                               mothurOut(">");
                                                if(d != 0)
-                                                       cout << "=";
-                                               cout << " '" << a << "'";
+                                                       mothurOut("=");
+                                               mothurOut(" '" + toString(a) + "'");
                                        }
                                        if(b == piSentinel)
-                                               cout << "'.\n";
+                                               mothurOut( "'.\n");
                                        else if(a != piSentinel)
-                                               cout << " and ";
+                                               mothurOut(" and ");
                                        if(b != piSentinel) {
-                                               cout << "<";
+                                               mothurOut("<");
                                                if(e != 0)
-                                                       cout << "=";
-                                               cout << " '" << b << "'.\n";
+                                                       mothurOut("=");
+                                               mothurOut(" '" + toString(b) + "'.\n");
                                        }
                                }
                                return false;
@@ -192,11 +188,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                return true;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidParameters", "isValidParameters");
                exit(1);
        }
 }
@@ -223,11 +215,7 @@ string ValidParameters::validFile(map<string, string> container, string paramete
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function validFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function validFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidParameters", "validFile");
                exit(1);
        }
 }
@@ -272,11 +260,7 @@ void ValidParameters::initParameterRanges() {
                parameterRanges["size"] = addParameters(sizeArray, rangeSize);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidParameters", "initParameterRanges");
                exit(1);
        }
 }
@@ -290,11 +274,7 @@ vector<string> ValidParameters::addParameters(string parameters[], int size) {
                return pVector;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ValidParameters", "addParameters");
                exit(1);
        }
 }
index 921c125040d6950aeb773c995b1c0f2cca5d5d60..2c40c25ed7fadfcc50958ba1a1c87e124a939cf6 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -22,11 +22,7 @@ Venn::Venn(){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "Venn");
                exit(1);
        }
 }
@@ -59,11 +55,7 @@ void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "getPic");
                exit(1);
        }
 }
@@ -305,9 +297,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>"; 
                                outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>"; 
                                outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>"; 
-//cout << "numA = " << numA[0] << " numB = " << numB[0]        << " numC = " << numC[0] << endl;
-//cout << "sharedAB = " << sharedAB[0] << " sharedAC = " << sharedAC[0] << " sharedBC = " << sharedBC[0] << endl;
-//cout << "sharedAwithBC = " << sharedAwithBC[0]       << " sharedBwithAC = " << sharedBwithAC[0] << " sharedCwithAB = " << sharedCwithAB[0] << endl;  
+
                                //place labels within overlaps
                                outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"170\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n"; 
                                outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "</text>\n";  
@@ -374,7 +364,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                        //make a file for each calculator
                        for(int i=0;i<vCalcs.size();i++){
                                
-                               if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { cout << vCalcs[i]->getName() << " is not a valid calculator with four groups.  It will be disregarded. " << endl; }
+                               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(); }
                                else{
                                        string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
                                        openOutputFile(filenamesvg, outsvg);
@@ -507,11 +497,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "getPic");
                exit(1);
        }
 }
index fda33339bfc4a75a940f4c5cc0039c88edafcc30..38cf8cb6a1c189c2f2d3451d63c3891c65dbe499 100644 (file)
@@ -47,7 +47,7 @@ VennCommand::VennCommand(string option){
                        
                        //make sure the user has already run the read.otu command
                        if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
-                                cout << "You must read a list, or a list and a group, or a shared before you can use the venn command." << endl; abort = true; 
+                               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; 
                        }
 
                        //check for optional parameter and set defaults
@@ -67,7 +67,7 @@ VennCommand::VennCommand(string option){
                        }
                        
                        //make sure user did not use both the line and label parameters
-                       if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+                       if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
                        //if the user has not specified any line or labels use the ones from read.otu
                        else if ((line == "") && (label == "")) {  
                                allLines = globaldata->allLines; 
@@ -141,40 +141,32 @@ VennCommand::VennCommand(string option){
                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VennCommand", "VennCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VennCommand class function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //**********************************************************************************************************************
 
 void VennCommand::help(){
        try {
-               cout << "The venn command can only be executed after a successful read.otu command." << "\n";
-               cout << "The venn command parameters are groups, calc, abund, line and label.  No parameters are required, but you may not use line and label at the same time." << "\n";
-               cout << "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";
-               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a venn diagram created for, and are also separated by dashes." << "\n";
-               cout << "The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels, abund=yourAbund)." << "\n";
-               cout << "Example venn(groups=A-B-C, line=1-3-5, calc=sharedsobs-sharedchao, abund=20)." << "\n";
-               cout << "The default value for groups is all the groups in your groupfile up to 4, and all lines in your inputfile will be used." << "\n";
-               cout << "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";
-               cout << "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";
-               cout << "The only estmiator available four 4 groups is sharedsobs." << "\n";
-               cout << "The venn command outputs a .svg file for each calculator you specify at each distance you choose." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+               mothurOut("The venn command can only be executed after a successful read.otu command.\n");
+               mothurOut("The venn command parameters are groups, calc, abund, line and label.  No parameters are required, but you may not use line and label at the same time.\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 line and label allow 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, line=yourLines, label=yourLabels, abund=yourAbund).\n");
+               mothurOut("Example venn(groups=A-B-C, line=1-3-5, calc=sharedsobs-sharedchao, abund=20).\n");
+               mothurOut("The default value for groups is all the groups in your groupfile up to 4, and all lines 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");
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VennCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VennCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -232,13 +224,13 @@ int VennCommand::execute(){
                        while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
 
                                if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){                       
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
                                        userLines.erase(count);
                                        
                                        if (lookup.size() > 4) {
-                                               cout << "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." << endl;
+                                               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();
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        }
                                        venn->getPic(lookup, vennCalculators);
@@ -248,12 +240,12 @@ int VennCommand::execute(){
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
 
                                        if (lookup.size() > 4) {
-                                               cout << "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." << endl;
+                                               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();
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        }                               
                                        venn->getPic(lookup, vennCalculators);
@@ -272,12 +264,12 @@ int VennCommand::execute(){
                        set<string>::iterator it;
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               cout << "Your file does not include the label "<< *it
+                               mothurOut("Your file does not include the label " + *it)
                                if (processedLabels.count(lastLabel) != 1) {
-                                       cout << ". I will use " << lastLabel << "." << endl;
+                                       mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLabel << "." << endl;
+                                       mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                                }
                        }
                
@@ -286,12 +278,12 @@ int VennCommand::execute(){
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                        lookup = input->getSharedRAbundVectors(lastLabel);
 
-                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
 
                                        if (lookup.size() > 4) {
-                                               cout << "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." << endl;
+                                               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();
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        }                               
                                        venn->getPic(lookup, vennCalculators);
@@ -308,7 +300,7 @@ int VennCommand::execute(){
                
                                if(allLines == 1 || lines.count(count) == 1 || labels.count(sabund->getLabel()) == 1){                  
        
-                                       cout << sabund->getLabel() << '\t' << count << endl;
+                                       mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        venn->getPic(sabund, vennCalculators);
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -320,7 +312,7 @@ int VennCommand::execute(){
                                        delete sabund;
                                        sabund = input->getSAbundVector(lastLabel);
                                        
-                                       cout << sabund->getLabel() << '\t' << count << endl;
+                                       mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                        venn->getPic(sabund, vennCalculators);
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -338,12 +330,12 @@ int VennCommand::execute(){
                        set<string>::iterator it;
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               cout << "Your file does not include the label "<< *it
+                               mothurOut("Your file does not include the label " + *it)
                                if (processedLabels.count(lastLabel) != 1) {
-                                       cout << ". I will use " << lastLabel << "." << endl;
+                                       mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLabel << "." << endl;
+                                       mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
                                }
                        }
                
@@ -352,7 +344,7 @@ int VennCommand::execute(){
                                delete sabund;
                                sabund = input->getSAbundVector(lastLabel);
                                        
-                               cout << sabund->getLabel() << '\t' << count << endl;
+                               mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine();
                                venn->getPic(sabund, vennCalculators);
                                delete sabund;
                                        
@@ -364,13 +356,9 @@ int VennCommand::execute(){
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "VennCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the VennCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 //**********************************************************************************************************************
index 581078085d4e573ad100dbc48f1ec87d64558efa..d1bc40ea72b096e6ae8ffce9f5488dec31a85000 100644 (file)
@@ -109,14 +109,9 @@ EstOutput Weighted::getValues(Tree* t) {
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Weighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Weighted", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Weighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /**************************************************************************************************/
@@ -195,14 +190,9 @@ EstOutput Weighted::getValues(Tree* t, string groupA, string groupB) {
                return data; 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Weighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Weighted", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Weighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 
index 4b66ec9ef049cf0cb086bef586d6b9ce3889aebd..48bc3222e2acadb9095744082be88fc7d615cbd0 100644 (file)
@@ -27,13 +27,9 @@ EstOutput Whittaker::getValues(vector<SharedRAbundVector*> shared){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Whittaker class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Whittaker", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Whittaker class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/