From 510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 25 Jun 2009 18:33:56 +0000 Subject: [PATCH] added logfile feature --- ace.cpp | 6 +- aligncommand.cpp | 99 +++++------- alignment.cpp | 6 +- averagelinkage.cpp | 8 +- bergerparker.cpp | 6 +- binsequencecommand.cpp | 76 ++++------ blastalign.cpp | 4 +- blastdb.cpp | 4 +- boneh.cpp | 6 +- bootstrap.cpp | 6 +- bootstrapsharedcommand.cpp | 76 ++++------ bstick.cpp | 10 +- calculator.cpp | 110 +++++--------- calculator.h | 64 ++++---- chao1.cpp | 6 +- cluster.cpp | 28 +--- clustercommand.cpp | 42 ++---- collect.cpp | 18 +-- collectcommand.cpp | 55 +++---- collectsharedcommand.cpp | 57 +++---- commandfactory.cpp | 25 +-- commandoptionparser.cpp | 11 +- completelinkage.cpp | 7 +- concensuscommand.cpp | 86 +++-------- coverage.cpp | 6 +- database.cpp | 22 +-- deconvolutecommand.cpp | 32 ++-- distancecommand.cpp | 69 +++------ distancedb.cpp | 2 +- efron.cpp | 7 +- engine.cpp | 142 +++++++++--------- fastamap.cpp | 18 +-- fileoutput.cpp | 100 +++--------- filterseqscommand.cpp | 64 ++++---- fullmatrix.cpp | 40 +---- geom.cpp | 14 +- getgroupcommand.cpp | 39 ++--- getlabelcommand.cpp | 35 ++--- getlinecommand.cpp | 35 ++--- getoturepcommand.cpp | 284 +++++++++++++++-------------------- getoturepcommand.h | 23 +-- getrabundcommand.cpp | 55 +++---- getsabundcommand.cpp | 51 +++---- globaldata.cpp | 12 +- globaldata.hpp | 1 + goodscoverage.cpp | 6 +- groupmap.cpp | 6 +- heatmap.cpp | 32 +--- heatmapcommand.cpp | 75 ++++----- heatmapsim.cpp | 23 +-- heatmapsimcommand.cpp | 58 +++---- helpcommand.cpp | 6 +- inputdata.cpp | 90 ++--------- jackknife.cpp | 18 +-- kmerdb.cpp | 6 +- libshuff.cpp | 33 +--- libshuffcommand.cpp | 83 ++++------ listvector.cpp | 52 ++----- logsd.cpp | 13 +- matrixoutputcommand.cpp | 72 ++++----- mergefilecommand.cpp | 28 +--- mothur.cpp | 6 +- mothur.h | 214 ++++++++++++++++++-------- nameassignment.cpp | 20 +-- nast.cpp | 16 +- nocommands.cpp | 2 +- npshannon.cpp | 7 +- optionparser.cpp | 6 +- ordervector.cpp | 32 +--- parselistcommand.cpp | 82 +++++----- parsimony.cpp | 19 +-- parsimonycommand.cpp | 68 +++------ progress.cpp | 48 ++---- qstat.cpp | 7 +- quitcommand.cpp | 12 +- rabundvector.cpp | 56 ++----- rarecalc.cpp | 6 +- raredisplay.cpp | 32 +--- rarefact.cpp | 19 +-- rarefactcommand.cpp | 53 +++---- rarefactsharedcommand.cpp | 59 +++----- readcolumn.cpp | 7 +- readdistcommand.cpp | 48 +++--- readotu.cpp | 10 +- readotucommand.cpp | 50 +++--- readphylip.cpp | 16 +- readtree.cpp | 78 ++++------ readtreecommand.cpp | 40 ++--- reversecommand.cpp | 28 +--- sabundvector.cpp | 48 +----- screenseqscommand.cpp | 51 +++---- seqsummarycommand.cpp | 51 +++---- sequencedb.cpp | 56 ++----- shannon.cpp | 6 +- sharedace.cpp | 7 +- sharedanderbergs.cpp | 6 +- sharedbraycurtis.cpp | 8 +- sharedchao1.cpp | 55 ++----- sharedcommand.cpp | 29 +--- sharedjabund.cpp | 6 +- sharedjackknife.cpp | 14 +- sharedjclass.cpp | 6 +- sharedjest.cpp | 6 +- sharedkstest.cpp | 17 +-- sharedkulczynski.cpp | 6 +- sharedkulczynskicody.cpp | 6 +- sharedlennon.cpp | 6 +- sharedlistvector.cpp | 72 ++------- sharedmarczewski.cpp | 6 +- sharedmorisitahorn.cpp | 6 +- sharedochiai.cpp | 6 +- sharedordervector.cpp | 53 ++----- sharedrabundvector.cpp | 84 ++--------- sharedsabundvector.cpp | 48 +----- sharedsobs.cpp | 6 +- sharedsobscollectsummary.cpp | 6 +- sharedsorabund.cpp | 6 +- sharedsorclass.cpp | 6 +- sharedsorest.cpp | 6 +- sharedthetan.cpp | 6 +- sharedthetayc.cpp | 6 +- sharedutilities.cpp | 66 ++------ shen.cpp | 6 +- simpson.cpp | 6 +- singlelinkage.cpp | 6 +- slibshuff.cpp | 14 +- solow.cpp | 6 +- sparsematrix.cpp | 51 ++----- suffixdb.cpp | 4 +- suffixnodes.cpp | 20 +-- suffixtree.cpp | 2 +- summarycommand.cpp | 52 +++---- summarysharedcommand.cpp | 62 +++----- tree.cpp | 137 +++++------------ treegroupscommand.cpp | 104 +++++-------- treemap.cpp | 24 +-- treenode.cpp | 20 +-- trimseqscommand.cpp | 58 +++---- unifracunweightedcommand.cpp | 56 +++---- unifracweightedcommand.cpp | 69 +++------ unweighted.cpp | 13 +- uvest.cpp | 8 +- validcalculator.cpp | 175 +++++++-------------- validparameter.cpp | 66 +++----- venn.cpp | 24 +-- venncommand.cpp | 76 ++++------ weighted.cpp | 14 +- whittaker.cpp | 6 +- 148 files changed, 1740 insertions(+), 3615 deletions(-) diff --git a/ace.cpp b/ace.cpp index 54d0946..639a48f 100644 --- 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); - } } /***********************************************************************/ diff --git a/aligncommand.cpp b/aligncommand.cpp index 4bf18d7..0f5c86f 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -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); - } } //********************************************************************************************************************** diff --git a/alignment.cpp b/alignment.cpp index d64d8b2..6014506 100644 --- a/alignment.cpp +++ b/alignment.cpp @@ -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); } } diff --git a/averagelinkage.cpp b/averagelinkage.cpp index 54f3803..26283ff 100644 --- a/averagelinkage.cpp +++ b/averagelinkage.cpp @@ -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); - } - - } /***********************************************************************/ diff --git a/bergerparker.cpp b/bergerparker.cpp index b900ce1..a1e4b06 100644 --- a/bergerparker.cpp +++ b/bergerparker.cpp @@ -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); - } } /***********************************************************************/ diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp index a291caa..8805737 100644 --- a/binsequencecommand.cpp +++ b/binsequencecommand.cpp @@ -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::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); - } } //********************************************************************************************************************** diff --git a/blastalign.cpp b/blastalign.cpp index cb6abf9..0645fb0 100644 --- a/blastalign.cpp +++ b/blastalign.cpp @@ -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;igetSharedFile() == "") { - 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::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); - } } /***********************************************************/ diff --git a/bstick.cpp b/bstick.cpp index c3ff58f..5660997 100644 --- a/bstick.cpp +++ b/bstick.cpp @@ -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); - } } /***********************************************************************/ diff --git a/calculator.cpp b/calculator.cpp index c45ddbf..7f7296b 100644 --- a/calculator.cpp +++ b/calculator.cpp @@ -9,7 +9,7 @@ #include "calculator.h" -/***********************************************************************/ +/*********************************************************************** void VecCalc::printElements(vector vec){ try { for(int i = 0; i < vec.size(); i++) @@ -26,7 +26,7 @@ void VecCalc::printElements(vector vec){ } } -/***********************************************************************/ +/*********************************************************************** void VecCalc::printElements(vector vec){ try { @@ -43,7 +43,7 @@ void VecCalc::printElements(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** int VecCalc::findString(vector vec, string str){ try { for(int i = 0; i < vec.size(); i++) @@ -60,11 +60,11 @@ int VecCalc::findString(vector vec, string str){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** double VecCalc::mean(vector vec){ return sumElements(vec)/vec.size(); } -/***********************************************************************/ +/*********************************************************************** double VecCalc::stError(vector vec){ try { double sum = 0; @@ -88,13 +88,9 @@ int VecCalc::sumElements(vector 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 vec, int index){ @@ -105,13 +101,9 @@ int VecCalc::sumElements(vector 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 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 vec, int index){ @@ -140,15 +128,11 @@ double VecCalc::sumElements(vector 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 vec){ try { double max = -1000000.0; @@ -176,13 +160,9 @@ int VecCalc::numNZ(vector 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 vec){ @@ -194,15 +174,11 @@ double VecCalc::numNZ(vector 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 vec){ try { double numPos = 0; @@ -220,7 +196,7 @@ double VecCalc::numPos(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** double VecCalc::findMaxDiff(vector vec1, vector vec2){ try { double maxDiff = -10000000000.0; @@ -238,7 +214,7 @@ double VecCalc::findMaxDiff(vector vec1, vector vec2){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** double VecCalc::findDStat(vector vec1, vector vec2, double num){ try { double mDiff = findMaxDiff(vec1, vec2); @@ -253,7 +229,7 @@ double VecCalc::findDStat(vector vec1, vector vec2, double num){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::findQuartiles(vector vec){ try { vector quartiles; @@ -286,7 +262,7 @@ vector VecCalc::findQuartiles(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::add(vector vec, double x){ try { vector newVec; @@ -303,7 +279,7 @@ vector VecCalc::add(vector vec, double x){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::multiply(vector vec, double x){ try { vector newVec; @@ -320,7 +296,7 @@ vector VecCalc::multiply(vector vec, double x){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::power(vector vec, double p){ try { vector newVec; @@ -337,7 +313,7 @@ vector VecCalc::power(vector vec, double p){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::addVecs(vector vec1, vector vec2) //Vectors must be the same size. { try { vector newVec; @@ -354,7 +330,7 @@ vector VecCalc::addVecs(vector vec1, vector vec2) //Vect exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::multVecs(vector vec1, vector vec2) //Vectors must be the same size. { try { vector newVec; @@ -371,7 +347,7 @@ vector VecCalc::multVecs(vector vec1, vector vec2) //Vec exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::remDup(vector vec){ try { vector newVec; @@ -390,7 +366,7 @@ vector VecCalc::remDup(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::genCVec(vector vec1){ try { vector vec2; @@ -411,7 +387,7 @@ vector VecCalc::genCVec(vector vec1){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::genRelVec(vector vec){ try { vector newVec; @@ -429,7 +405,7 @@ vector VecCalc::genRelVec(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::genDiffVec(vector vec1, vector vec2){ try { vector newVec; @@ -446,7 +422,7 @@ vector VecCalc::genDiffVec(vector vec1, vector vec2){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::genCSVec(vector vec){ try { vector newVec; @@ -478,7 +454,7 @@ vector VecCalc::genCSVec(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::genTotVec(vector > vec){ try { vector newVec = vec.at(0); @@ -495,7 +471,7 @@ vector VecCalc::genTotVec(vector > vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::quicksort(vector vec){ try { sort(vec.rbegin(), vec.rend()); @@ -510,7 +486,7 @@ vector VecCalc::quicksort(vector vec){ exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector > VecCalc::gen2DVec(vector vec, int div, int type){ try { vector > vec2D; @@ -536,7 +512,7 @@ vector > VecCalc::gen2DVec(vector vec, int div, int type) exit(1); } } -/***********************************************************************/ +/*********************************************************************** vector VecCalc::getSData(char name[]){ try { vector vec; @@ -561,7 +537,7 @@ vector VecCalc::getSData(char name[]){ } /***********************************************************************/ -/***********************************************************************/ +/*********************************************************************** void BrokenStick::doBStick(vector vec)//vec = The data vector. { try { VecCalc vecCalc; @@ -600,7 +576,7 @@ void BrokenStick::doBStick(vector 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 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 vec, double cols)//vec = the data vector i exit(1); } } -/***********************************************************************/ +/*********************************************************************** void KS2SampleTest::doKSTest(vector abun1, vector abun2)//abun1 = 1st vector of abundances, abun2 = 2nd vector of abundances { try { VecCalc vecCalc; @@ -745,7 +721,7 @@ void KS2SampleTest::doKSTest(vector abun1, vector abun2)//abun1 } } -/***********************************************************************/ +/*********************************************************************** void QStatistic::doQStat(vector vec)//vec = The data vector. { try { @@ -772,7 +748,7 @@ void QStatistic::doQStat(vector vec)//vec = The data vector. exit(1); } } -/***********************************************************************/ +/*********************************************************************** double SSBPDiversityIndices::getShan(vector vec)//vec = The data vector. { try { VecCalc vecCalc; @@ -793,7 +769,7 @@ double SSBPDiversityIndices::getShan(vector vec)//vec = The data vector. exit(1); } } -/***********************************************************************/ +/*********************************************************************** double SSBPDiversityIndices::getSimp(vector vec)//vec = The data vector. { try { VecCalc vecCalc; @@ -812,7 +788,7 @@ double SSBPDiversityIndices::getSimp(vector vec)//vec = The data vector. exit(1); } } -/***********************************************************************/ +/*********************************************************************** double SSBPDiversityIndices::getBP(vector vec)//vec = The data vector. { try { VecCalc vecCalc; @@ -828,7 +804,7 @@ double SSBPDiversityIndices::getBP(vector vec)//vec = The data vector. exit(1); } } -/***********************************************************************/ +/*********************************************************************** void SSBPDiversityIndices::doSSBP(vector 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 diff --git a/calculator.h b/calculator.h index 5dc0812..ffc92b9 100644 --- a/calculator.h +++ b/calculator.h @@ -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); //This prints the values of the vector on one line with a space between each value. - void printElements(vector); //This prints the values of the vector on one line with a space between each value. - int findString(vector, string);//This returns the index of the given string in the given vector, if the string does not exist in the vector it returns -1. - double mean(vector); //This returns the mean value of the vector. - double stError(vector); //This returns the standard error of the vector. + //void printElements(vector); //This prints the values of the vector on one line with a space between each value. + //void printElements(vector); //This prints the values of the vector on one line with a space between each value. + //int findString(vector, string);//This returns the index of the given string in the given vector, if the string does not exist in the vector it returns -1. + //double mean(vector); //This returns the mean value of the vector. + //double stError(vector); //This returns the standard error of the vector. int sumElements(vector, int); int sumElements(vector); double sumElements(vector); //This returns the sum of all the values in the vector. double sumElements(vector, int); //This returns the sum of all the values in the vector excluding those whose index is before the given index. - double findMax(vector); //This returns the maximum value in the vector. + //double findMax(vector); //This returns the maximum value in the vector. int numNZ(vector); //This returns the number of non-zero values in the vector. double numNZ(vector); //This returns the number of non-zero values in the vector. - double numPos(vector); //This returns the number of positive values in the vector. - double findMaxDiff(vector, vector); //This returns the absolute value of the maximum difference between the two vectors. - double findDStat(vector, vector, double); //This returns the D-Statistic of the two vectors with the given total number of species. - vector findQuartiles(vector); //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 add(vector, double); //This adds the given number to every element in the given vector and returns the new vector. - vector multiply(vector, double); //This multiplies every element in the given vector by the given number and returns the new vector. - vector power(vector, double); //This raises every element in the given vector to the given number and returns the new vector. - vector addVecs(vector,vector); //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 multVecs(vector,vector); //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 remDup(vector); //This returns a vector that contains 1 of each unique element in the given vector. The order of the elements is not changed. - vector genCVec(vector); //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 genRelVec(vector); //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 genDiffVec(vector, vector);//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 genCSVec(vector);//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 genTotVec(vector >); //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 quicksort(vector); //This sorts the given vector from highest to lowest and returns the sorted vector. - vector > gen2DVec(vector, 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 getSData(char[]);//This takes a file name as a parameter and reads all of the data in the file into a vector. + //double numPos(vector); //This returns the number of positive values in the vector. + //double findMaxDiff(vector, vector); //This returns the absolute value of the maximum difference between the two vectors. + //double findDStat(vector, vector, double); //This returns the D-Statistic of the two vectors with the given total number of species. + //vector findQuartiles(vector); //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 add(vector, double); //This adds the given number to every element in the given vector and returns the new vector. + //vector multiply(vector, double); //This multiplies every element in the given vector by the given number and returns the new vector. + //vector power(vector, double); //This raises every element in the given vector to the given number and returns the new vector. + //vector addVecs(vector,vector); //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 multVecs(vector,vector); //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 remDup(vector); //This returns a vector that contains 1 of each unique element in the given vector. The order of the elements is not changed. + //vector genCVec(vector); //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 genRelVec(vector); //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 genDiffVec(vector, vector);//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 genCSVec(vector);//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 genTotVec(vector >); //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 quicksort(vector); //This sorts the given vector from highest to lowest and returns the sorted vector. + //vector > gen2DVec(vector, 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 getSData(char[]);//This takes a file name as a parameter and reads all of the data in the file into a 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); };*/ -/**************************************************************************************************/ +/************************************************************************************************** //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); }; -/**************************************************************************************************/ +/************************************************************************************************** /*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, vector); }; -/**************************************************************************************************/ +/************************************************************************************************** //This Class calculates and prints the Q-Statistic for the data. class QStatistic { public: void doQStat(vector); }; -/**************************************************************************************************/ +/************************************************************************************************** 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 { diff --git a/chao1.cpp b/chao1.cpp index 7757fb0..b601b51 100644 --- 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); - } } /***********************************************************************/ diff --git a/cluster.cpp b/cluster.cpp index 1ccb349..b9754be 100644 --- a/cluster.cpp +++ b/cluster.cpp @@ -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); - } } /***********************************************************************/ diff --git a/clustercommand.cpp b/clustercommand.cpp index eeba407..593f262 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -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); } - } //********************************************************************************************************************** diff --git a/collect.cpp b/collect.cpp index ac4aa4d..2d1f6e3 100644 --- a/collect.cpp +++ b/collect.cpp @@ -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); - } - } /**************************************************************************************/ diff --git a/collectcommand.cpp b/collectcommand.cpp index dbb2ede..c3a58d6 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -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::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); - } } //********************************************************************************************************************** diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index adb2aea..3fed167 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -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::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); - } } /***********************************************************/ diff --git a/commandfactory.cpp b/commandfactory.cpp index 7dd35fd..db11f8c 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -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); } } diff --git a/commandoptionparser.cpp b/commandoptionparser.cpp index e4db11d..f013a25 100644 --- a/commandoptionparser.cpp +++ b/commandoptionparser.cpp @@ -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); - } - } //********************************************************************************************************************** diff --git a/completelinkage.cpp b/completelinkage.cpp index 3c779b9..f69753b 100644 --- a/completelinkage.cpp +++ b/completelinkage.cpp @@ -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); - } - } /***********************************************************************/ diff --git a/concensuscommand.cpp b/concensuscommand.cpp index 09e0f32..30da32c 100644 --- a/concensuscommand.cpp +++ b/concensuscommand.cpp @@ -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 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 ConcensusCommand::getNextAvailableSet(vector 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 ConcensusCommand::getRestSet(vector bigset, vector bigset, vector 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); - } } //********************************************************************************************************************** diff --git a/coverage.cpp b/coverage.cpp index 441a029..16d2644 100644 --- a/coverage.cpp +++ b/coverage.cpp @@ -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); - } } diff --git a/database.cpp b/database.cpp index 852e2d2..5fc9b67 100644 --- a/database.cpp +++ b/database.cpp @@ -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(fastaFile),istreambuf_iterator(), '>'); // 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(); } /**************************************************************************************************/ diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index fba2d27..a936c82 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -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); } } diff --git a/distancecommand.cpp b/distancecommand.cpp index 67ad7be..f8a2a75 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -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); - } } /**************************************************************************************************/ diff --git a/distancedb.cpp b/distancedb.cpp index 25c95c7..90b7724 100644 --- a/distancedb.cpp +++ b/distancedb.cpp @@ -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(); } diff --git a/efron.cpp b/efron.cpp index 62d924b..9ddcdfa 100644 --- a/efron.cpp +++ b/efron.cpp @@ -8,7 +8,6 @@ */ #include "efron.h" -#include /***********************************************************************/ 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); - } } diff --git a/engine.cpp b/engine.cpp index 38429b9..f0fd05a 100644 --- a/engine.cpp +++ b/engine.cpp @@ -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); } } diff --git a/fastamap.cpp b/fastamap.cpp index 9b2438f..5775466 100644 --- a/fastamap.cpp +++ b/fastamap.cpp @@ -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); } } diff --git a/fileoutput.cpp b/fileoutput.cpp index 4347c12..63130a8 100644 --- a/fileoutput.cpp +++ b/fileoutput.cpp @@ -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 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 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 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 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 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 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); - } } /***********************************************************************/ diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index c38bfcb..ad491aa 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -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); } } diff --git a/fullmatrix.cpp b/fullmatrix.cpp index bc53b7d..5bb2d23 100644 --- a/fullmatrix.cpp +++ b/fullmatrix.cpp @@ -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> 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> 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); - } - } /**************************************************************************/ diff --git a/geom.cpp b/geom.cpp index a23352c..a52e644 100644 --- 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); - } } /***********************************************************************/ diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp index 4fa8413..95baec8 100644 --- a/getgroupcommand.cpp +++ b/getgroupcommand.cpp @@ -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); - } } diff --git a/getlabelcommand.cpp b/getlabelcommand.cpp index 40c656b..be2a989 100644 --- a/getlabelcommand.cpp +++ b/getlabelcommand.cpp @@ -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); - } } diff --git a/getlinecommand.cpp b/getlinecommand.cpp index 800f9d8..f1ec55c 100644 --- a/getlinecommand.cpp +++ b/getlinecommand.cpp @@ -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); - } } diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp index 1f5c02b..92ba3ad 100644 --- a/getoturepcommand.cpp +++ b/getoturepcommand.cpp @@ -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 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 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(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::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 names; - map sums; - map binMap; //subset of namesToIndex - just member of this bin - string binnames; - float min = 10000; - string minName; map groups; map::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::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 seqIndex(names.size()); + vector 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::iterator it = binMap.find(currentCell->row); - map::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::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); - } } //********************************************************************************************************************** - - - - - diff --git a/getoturepcommand.h b/getoturepcommand.h index 37c4194..4f755d0 100644 --- a/getoturepcommand.h +++ b/getoturepcommand.h @@ -20,18 +20,17 @@ #include "fastamap.h" #include "groupmap.h" -class GlobalData; - typedef list::iterator MatData; +typedef map 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 lines; //hold lines to be used set labels; //holds labels to be used map nameToIndex; //maps sequence name to index in sparsematrix - + + vector 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 }; diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index b8c692b..73862a8 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -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::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); - } } //********************************************************************************************************************** diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index f5beb32..0be26ce 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -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::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); - } } //********************************************************************************************************************** diff --git a/globaldata.cpp b/globaldata.cpp index 0d728a1..cdf819b 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -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); } } diff --git a/globaldata.hpp b/globaldata.hpp index 6f66cbe..ff09a36 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -48,6 +48,7 @@ public: set labels; //holds labels to be used vector Treenames; + string getPhylipFile(); string getColumnFile(); string getListFile(); diff --git a/goodscoverage.cpp b/goodscoverage.cpp index 61ffe41..8e823e4 100644 --- a/goodscoverage.cpp +++ b/goodscoverage.cpp @@ -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); - } } /***********************************************************************/ diff --git a/groupmap.cpp b/groupmap.cpp index 38addc9..dd6f924 100644 --- a/groupmap.cpp +++ b/groupmap.cpp @@ -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); } } diff --git a/heatmap.cpp b/heatmap.cpp index 3ed606f..6fd6861 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -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 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& 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); - } - } diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index 413889e..0ee34f9 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -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::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::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); - } } //********************************************************************************************************************** diff --git a/heatmapsim.cpp b/heatmapsim.cpp index 33588e6..ea01304 100644 --- a/heatmapsim.cpp +++ b/heatmapsim.cpp @@ -21,17 +21,7 @@ //********************************************************************************************************************** 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 lookup, vector } 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); - } - } //********************************************************************************************************************** diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index 331ff79..b9216e4 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -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 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::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); - } } //********************************************************************************************************************** diff --git a/helpcommand.cpp b/helpcommand.cpp index 93def59..47fb72a 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -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; } diff --git a/inputdata.cpp b/inputdata.cpp index c2f4e4e..cbf44ed 100644 --- a/inputdata.cpp +++ b/inputdata.cpp @@ -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 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 InputData::getSharedRAbundVectors(string label){ @@ -505,13 +465,9 @@ vector 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); - } } /***********************************************************************/ diff --git a/jackknife.cpp b/jackknife.cpp index a166eb4..1082465 100644 --- a/jackknife.cpp +++ b/jackknife.cpp @@ -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); - } } /***********************************************************************/ diff --git a/kmerdb.cpp b/kmerdb.cpp index 40cc1f6..0ec822f 100644 --- a/kmerdb.cpp +++ b/kmerdb.cpp @@ -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(); } /**************************************************************************************************/ diff --git a/libshuff.cpp b/libshuff.cpp index b7e5f27..002cd52 100644 --- a/libshuff.cpp +++ b/libshuff.cpp @@ -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 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 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;kgMatrix == 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 > allDistances; map >::iterator it; @@ -216,7 +203,7 @@ void LibShuffCommand::printCoverageFile() { } it=allDistances.begin(); - cout << setprecision(8); + //cout << setprecision(8); vector 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;jGroups.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; iGroups[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); } } diff --git a/listvector.cpp b/listvector.cpp index 4b21d5f..6e00807 100644 --- a/listvector.cpp +++ b/listvector.cpp @@ -36,11 +36,7 @@ ListVector::ListVector(string id, vector 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* 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* 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* 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); } } diff --git a/logsd.cpp b/logsd.cpp index 782af2a..62faf8e 100644 --- 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); - } } /***********************************************************************/ diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index e8fb553..64ec2a5 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -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 userLabels = labels; set 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::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 thisLookup){ @@ -349,13 +333,9 @@ void MatrixOutputCommand::process(vector 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); - } } /***********************************************************/ diff --git a/mergefilecommand.cpp b/mergefilecommand.cpp index 497d535..44cb03d 100644 --- a/mergefilecommand.cpp +++ b/mergefilecommand.cpp @@ -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); - } - } //********************************************************************************************************************** diff --git a/mothur.cpp b/mothur.cpp index 59837dd..0314331 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -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); } } diff --git a/mothur.h b/mothur.h index e5d1113..20d3b4b 100644 --- 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& 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& 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& 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& 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 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& 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& 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& 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& 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); - } - } /**************************************************************************************************/ diff --git a/nameassignment.cpp b/nameassignment.cpp index cf4e677..3bcf6f9 100644 --- a/nameassignment.cpp +++ b/nameassignment.cpp @@ -33,19 +33,9 @@ void NameAssignment::readMap(){ } fileHandle.close(); -// map::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::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); } } diff --git a/nast.cpp b/nast.cpp index 2d3db22..0741ccd 100644 --- 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;rightIndexsetAligned(candAln); } diff --git a/nocommands.cpp b/nocommands.cpp index 18a2948..5cf5a56 100644 --- a/nocommands.cpp +++ b/nocommands.cpp @@ -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); diff --git a/npshannon.cpp b/npshannon.cpp index 73dd834..fda649c 100644 --- a/npshannon.cpp +++ b/npshannon.cpp @@ -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); - } } /***********************************************************************/ diff --git a/optionparser.cpp b/optionparser.cpp index 2de1621..8f0e29d 100644 --- a/optionparser.cpp +++ b/optionparser.cpp @@ -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); } } diff --git a/ordervector.cpp b/ordervector.cpp index e306205..360c898 100644 --- a/ordervector.cpp +++ b/ordervector.cpp @@ -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); - } } /***********************************************************************/ diff --git a/parselistcommand.cpp b/parselistcommand.cpp index 8173bdc..0fdcf9a 100644 --- a/parselistcommand.cpp +++ b/parselistcommand.cpp @@ -35,20 +35,15 @@ ParseListCommand::ParseListCommand(){ //clears file before we start to write to it below for (int i=0; igetNumGroups(); 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 processedLabels; set userLabels = globaldata->labels; set 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::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); } } diff --git a/parsimony.cpp b/parsimony.cpp index 9a8706e..db6ed1d 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -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();igetNumNodes();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); - } - } /**************************************************************************************************/ diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index 266dd3b..6df2deb 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -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); } } diff --git a/progress.cpp b/progress.cpp index 65c01b9..6899e76 100644 --- a/progress.cpp +++ b/progress.cpp @@ -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 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 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* 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); } } diff --git a/rarecalc.cpp b/rarecalc.cpp index 88c704a..8f1d307 100644 --- a/rarecalc.cpp +++ b/rarecalc.cpp @@ -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); - } } /***********************************************************************/ diff --git a/raredisplay.cpp b/raredisplay.cpp index 61362c7..b86312b 100644 --- a/raredisplay.cpp +++ b/raredisplay.cpp @@ -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 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); } } diff --git a/rarefact.cpp b/rarefact.cpp index 6766249..f1b43fc 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -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); - } } diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index 9bb3daa..ee0c38f 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -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::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); - } } //********************************************************************************************************************** diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index d527f8b..71bfaf1 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -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::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); - } } diff --git a/readcolumn.cpp b/readcolumn.cpp index c03c37f..29c967e 100644 --- a/readcolumn.cpp +++ b/readcolumn.cpp @@ -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); - } - } /***********************************************************************/ diff --git a/readdistcommand.cpp b/readdistcommand.cpp index 744a35d..088f711 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -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); } } diff --git a/readotu.cpp b/readotu.cpp index a99f343..d16dab9 100644 --- a/readotu.cpp +++ b/readotu.cpp @@ -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); } } diff --git a/readotucommand.cpp b/readotucommand.cpp index 50ee5c1..07fe251 100644 --- a/readotucommand.cpp +++ b/readotucommand.cpp @@ -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); } } diff --git a/readphylip.cpp b/readphylip.cpp index a1063e9..fe278ab 100644 --- a/readphylip.cpp +++ b/readphylip.cpp @@ -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> 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> 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); - } -} + } /***********************************************************************/ diff --git a/readtree.cpp b/readtree.cpp index 670c6e0..5e909e6 100644 --- a/readtree.cpp +++ b/readtree.cpp @@ -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); - } } /**************************************************************************************************/ /**************************************************************************************************/ diff --git a/readtreecommand.cpp b/readtreecommand.cpp index d301b13..2a3c5d0 100644 --- a/readtreecommand.cpp +++ b/readtreecommand.cpp @@ -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 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); } } diff --git a/reversecommand.cpp b/reversecommand.cpp index 9e2a08b..7a87a99 100644 --- a/reversecommand.cpp +++ b/reversecommand.cpp @@ -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); } } diff --git a/sabundvector.cpp b/sabundvector.cpp index c1997d5..b70c642 100644 --- a/sabundvector.cpp +++ b/sabundvector.cpp @@ -29,11 +29,7 @@ SAbundVector::SAbundVector(string id, vector 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 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* 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); - } } /***********************************************************************/ diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index d0f0af0..4b267b5 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -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); - } - } //*************************************************************************************************************** diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 3259931..82a1d24 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -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); } - } //*************************************************************************************************************** diff --git a/sequencedb.cpp b/sequencedb.cpp index bc8523a..ca201d5 100644 --- a/sequencedb.cpp +++ b/sequencedb.cpp @@ -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); } } diff --git a/shannon.cpp b/shannon.cpp index 0d54b7b..1807375 100644 --- a/shannon.cpp +++ b/shannon.cpp @@ -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); - } } /***********************************************************************/ diff --git a/sharedace.cpp b/sharedace.cpp index 34ad28b..61a7c74 100644 --- a/sharedace.cpp +++ b/sharedace.cpp @@ -100,14 +100,9 @@ EstOutput SharedAce::getValues(vector 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); - } - } /***********************************************************************/ diff --git a/sharedanderbergs.cpp b/sharedanderbergs.cpp index 0a113ab..d55a016 100644 --- a/sharedanderbergs.cpp +++ b/sharedanderbergs.cpp @@ -40,13 +40,9 @@ EstOutput Anderberg::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedbraycurtis.cpp b/sharedbraycurtis.cpp index 9a63cdf..299939d 100644 --- a/sharedbraycurtis.cpp +++ b/sharedbraycurtis.cpp @@ -44,15 +44,9 @@ EstOutput BrayCurtis::getValues(vector 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); - } - - } /***********************************************************************/ diff --git a/sharedchao1.cpp b/sharedchao1.cpp index 8dff314..402e0d9 100644 --- a/sharedchao1.cpp +++ b/sharedchao1.cpp @@ -41,15 +41,12 @@ EstOutput SharedChao1::getValues(vector 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 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 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 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 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); - } } /*****************************************************************/ diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 6ca1ed6..4857a34 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -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::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 thislookup) { @@ -144,14 +130,9 @@ void SharedCommand::printSharedData(vector 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); } - } //********************************************************************************************************************** diff --git a/sharedjabund.cpp b/sharedjabund.cpp index bedec32..d07076a 100644 --- a/sharedjabund.cpp +++ b/sharedjabund.cpp @@ -27,13 +27,9 @@ EstOutput JAbund::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedjackknife.cpp b/sharedjackknife.cpp index c1e5ff4..012d206 100644 --- a/sharedjackknife.cpp +++ b/sharedjackknife.cpp @@ -116,17 +116,11 @@ EstOutput SharedJackknife::getValues(vector 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 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); - } } /***********************************************************************/ diff --git a/sharedjclass.cpp b/sharedjclass.cpp index a0ccc89..051f05e 100644 --- a/sharedjclass.cpp +++ b/sharedjclass.cpp @@ -41,13 +41,9 @@ EstOutput Jclass::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedjest.cpp b/sharedjest.cpp index 1ca64b4..0396f47 100644 --- a/sharedjest.cpp +++ b/sharedjest.cpp @@ -52,13 +52,9 @@ EstOutput Jest::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedkstest.cpp b/sharedkstest.cpp index f65f271..567b345 100644 --- a/sharedkstest.cpp +++ b/sharedkstest.cpp @@ -43,17 +43,6 @@ EstOutput KSTest::getValues(vector 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 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); - } } /***********************************************************************/ diff --git a/sharedkulczynski.cpp b/sharedkulczynski.cpp index 5eadd16..cd09063 100644 --- a/sharedkulczynski.cpp +++ b/sharedkulczynski.cpp @@ -40,13 +40,9 @@ EstOutput Kulczynski::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedkulczynskicody.cpp b/sharedkulczynskicody.cpp index 7ae6700..dbb3c45 100644 --- a/sharedkulczynskicody.cpp +++ b/sharedkulczynskicody.cpp @@ -40,13 +40,9 @@ EstOutput KulczynskiCody::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedlennon.cpp b/sharedlennon.cpp index 4846e20..514f2b9 100644 --- a/sharedlennon.cpp +++ b/sharedlennon.cpp @@ -46,13 +46,9 @@ EstOutput Lennon::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp index 3cb3e9e..ba2ac1f 100644 --- a/sharedlistvector.cpp +++ b/sharedlistvector.cpp @@ -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 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* 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* 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* 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); } } diff --git a/sharedmarczewski.cpp b/sharedmarczewski.cpp index d382f9b..e4b80be 100644 --- a/sharedmarczewski.cpp +++ b/sharedmarczewski.cpp @@ -38,13 +38,9 @@ EstOutput SharedMarczewski::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedmorisitahorn.cpp b/sharedmorisitahorn.cpp index 28ff4fe..f9c1b6b 100644 --- a/sharedmorisitahorn.cpp +++ b/sharedmorisitahorn.cpp @@ -50,13 +50,9 @@ EstOutput MorHorn::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedochiai.cpp b/sharedochiai.cpp index 744fb1c..1d0828e 100644 --- a/sharedochiai.cpp +++ b/sharedochiai.cpp @@ -40,13 +40,9 @@ EstOutput Ochiai::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedordervector.cpp b/sharedordervector.cpp index 218ed87..76eeafa 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -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* 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 SharedOrderVector::getSharedRAbundVector() { @@ -303,14 +282,9 @@ vector 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); - } } /***********************************************************************/ diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 2467128..0a69e4c 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -51,11 +51,7 @@ SharedRAbundVector::SharedRAbundVector(string id, vector 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::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* 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); } } diff --git a/sharedsabundvector.cpp b/sharedsabundvector.cpp index 51058cf..8282f66 100644 --- a/sharedsabundvector.cpp +++ b/sharedsabundvector.cpp @@ -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* hold = NULL){ @@ -287,13 +259,9 @@ OrderVector SharedSAbundVector::getOrderVector(map* 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); - } } /***********************************************************************/ diff --git a/sharedsobs.cpp b/sharedsobs.cpp index 388356e..b65a878 100644 --- a/sharedsobs.cpp +++ b/sharedsobs.cpp @@ -29,13 +29,9 @@ EstOutput SharedSobs::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index c0cc507..0096303 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -34,13 +34,9 @@ EstOutput SharedSobsCS::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedsorabund.cpp b/sharedsorabund.cpp index 6748bfe..7b472a7 100644 --- a/sharedsorabund.cpp +++ b/sharedsorabund.cpp @@ -27,13 +27,9 @@ EstOutput SorAbund::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedsorclass.cpp b/sharedsorclass.cpp index f4757a8..3bb2219 100644 --- a/sharedsorclass.cpp +++ b/sharedsorclass.cpp @@ -41,13 +41,9 @@ EstOutput SorClass::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedsorest.cpp b/sharedsorest.cpp index 91191d5..680c4ad 100644 --- a/sharedsorest.cpp +++ b/sharedsorest.cpp @@ -51,13 +51,9 @@ EstOutput SorEst::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedthetan.cpp b/sharedthetan.cpp index 0d7405c..6396d1d 100644 --- a/sharedthetan.cpp +++ b/sharedthetan.cpp @@ -51,13 +51,9 @@ EstOutput ThetaN::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedthetayc.cpp b/sharedthetayc.cpp index 59cea4d..abb30e5 100644 --- a/sharedthetayc.cpp +++ b/sharedthetayc.cpp @@ -48,13 +48,9 @@ EstOutput ThetaYC::getValues(vector 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); - } } /***********************************************************************/ diff --git a/sharedutilities.cpp b/sharedutilities.cpp index de627c6..7d85c4c 100644 --- a/sharedutilities.cpp +++ b/sharedutilities.cpp @@ -49,11 +49,7 @@ void SharedUtil::getSharedVectors(vector Groups, vector Groups, vector& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& userGroups, vector& 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& groupComb, vector 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 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& userGroups, map& } } 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); } } diff --git a/shen.cpp b/shen.cpp index 3d1c277..2be566c 100644 --- 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); - } }; diff --git a/simpson.cpp b/simpson.cpp index 758c4a3..d260800 100644 --- a/simpson.cpp +++ b/simpson.cpp @@ -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); - } } /***********************************************************************/ diff --git a/singlelinkage.cpp b/singlelinkage.cpp index a024453..5332e90 100644 --- a/singlelinkage.cpp +++ b/singlelinkage.cpp @@ -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); - } } /***********************************************************************/ diff --git a/slibshuff.cpp b/slibshuff.cpp index a9710de..219c709 100644 --- a/slibshuff.cpp +++ b/slibshuff.cpp @@ -45,14 +45,9 @@ vector > 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); - } - } /***********************************************************************/ diff --git a/solow.cpp b/solow.cpp index e227a9d..d29b9c9 100644 --- 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); - } } diff --git a/sparsematrix.cpp b/sparsematrix.cpp index c4120f4..7f1c3c8 100644 --- a/sparsematrix.cpp +++ b/sparsematrix.cpp @@ -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); - } } /***********************************************************************/ diff --git a/suffixdb.cpp b/suffixdb.cpp index 5e6fd10..5bcd8e9 100644 --- a/suffixdb.cpp +++ b/suffixdb.cpp @@ -25,11 +25,11 @@ 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 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); } diff --git a/summarycommand.cpp b/summarycommand.cpp index e228dbe..228b933 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -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::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 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); - } } //********************************************************************************************************************** diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 9f815cd..253c338 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -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::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 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); - } } /***********************************************************/ diff --git a/tree.cpp b/tree.cpp index ee17e6f..ce3de37 100644 --- 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 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 Tree::mergeUserGroups(int i, vector 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 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 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 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); - } } /*******************************************************/ diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index cb80ca8..cb797d8 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -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::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 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); - } } /***********************************************************/ diff --git a/treemap.cpp b/treemap.cpp index ad8a2af..044e87c 100644 --- a/treemap.cpp +++ b/treemap.cpp @@ -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); } } diff --git a/treenode.cpp b/treenode.cpp index fc6ea3a..54cdae4 100644 --- a/treenode.cpp +++ b/treenode.cpp @@ -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::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); - } } /****************************************************************/ diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 1989365..ef0c066 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -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; diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 154c528..7f85121 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -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); } } diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index cf54e64..fb3eb3c 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -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); - } - } /***********************************************************/ diff --git a/unweighted.cpp b/unweighted.cpp index b3f50c8..687786a 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -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); } } diff --git a/uvest.cpp b/uvest.cpp index 819be0a..afc6022 100644 --- a/uvest.cpp +++ b/uvest.cpp @@ -80,15 +80,9 @@ EstOutput UVEst::getUVest(vector 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); - } - - } /***********************************************************************/ diff --git a/validcalculator.cpp b/validcalculator.cpp index 3e698bf..504eb71 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -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); - } - } /********************************************************************/ diff --git a/validparameter.cpp b/validparameter.cpp index 486316f..ad8038e 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -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 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 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 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 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 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 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 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 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 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); } } diff --git a/venn.cpp b/venn.cpp index 921c125..2c40c25 100644 --- 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 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 lookup, vector vCalcs outsvg << ""; outsvg << ""; outsvg << ""; -//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 << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "\n"; @@ -374,7 +364,7 @@ void Venn::getPic(vector lookup, vector vCalcs //make a file for each calculator for(int i=0;igetName() != "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 lookup, vector 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); } } diff --git a/venncommand.cpp b/venncommand.cpp index fda3333..38cf8cb 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -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::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::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); - } } //********************************************************************************************************************** diff --git a/weighted.cpp b/weighted.cpp index 5810780..d1bc40e 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -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); - } - } diff --git a/whittaker.cpp b/whittaker.cpp index 4b66ec9..48bc322 100644 --- a/whittaker.cpp +++ b/whittaker.cpp @@ -27,13 +27,9 @@ EstOutput Whittaker::getValues(vector 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); - } } /***********************************************************************/ -- 2.39.2