From c6e5f84783b39a558119835963dec3c4facb0154 Mon Sep 17 00:00:00 2001 From: westcott Date: Fri, 3 Sep 2010 10:34:35 +0000 Subject: [PATCH] working on testing --- engine.cpp | 2 +- filterseqscommand.cpp | 4 ++-- getseqscommand.cpp | 30 ++++++++++++++++++------------ globaldata.cpp | 2 ++ globaldata.hpp | 1 + nast.cpp | 4 +++- pintail.cpp | 10 +++++----- removeseqscommand.cpp | 34 ++++++++++++++++++++++------------ sharedrabundfloatvector.cpp | 9 ++++++--- sharedrabundvector.cpp | 16 +++++++++------- summarysharedcommand.cpp | 3 ++- treegroupscommand.cpp | 2 ++ trimseqscommand.cpp | 2 +- 13 files changed, 74 insertions(+), 45 deletions(-) diff --git a/engine.cpp b/engine.cpp index 5e82d13..54524ba 100644 --- a/engine.cpp +++ b/engine.cpp @@ -199,7 +199,7 @@ string Engine::getCommand() { string nextCommand = ""; mout->mothurOut("mothur > "); - m->getline(cin, nextCommand); + getline(cin, nextCommand); mout->mothurOutJustToLog(toString(nextCommand)); return nextCommand; diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index 4ee6748..1b3b3cf 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -362,7 +362,7 @@ int FilterSeqsCommand::filterSequences() { if (m->control_pressed) { return 1; } #else - numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]); + int numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]); numSeqs += numFastaSeqs; if (m->control_pressed) { return 1; } @@ -662,7 +662,7 @@ string FilterSeqsCommand::createFilter() { if (m->control_pressed) { return filterString; } #else - numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]); + int numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]); numSeqs += numFastaSeqs; if (m->control_pressed) { return filterString; } #endif diff --git a/getseqscommand.cpp b/getseqscommand.cpp index e7226ce..1926ae0 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -206,8 +206,9 @@ int GetSeqsCommand::execute(){ //********************************************************************************************************************** int GetSeqsCommand::readFasta(){ try { - if (outputDir == "") { outputDir += m->hasPath(fastafile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(fastafile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile); ofstream out; m->openOutputFile(outputFileName, out); @@ -252,8 +253,9 @@ int GetSeqsCommand::readFasta(){ //********************************************************************************************************************** int GetSeqsCommand::readList(){ try { - if (outputDir == "") { outputDir += m->hasPath(listfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(listfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile); ofstream out; m->openOutputFile(outputFileName, out); @@ -323,8 +325,9 @@ int GetSeqsCommand::readList(){ //********************************************************************************************************************** int GetSeqsCommand::readName(){ try { - if (outputDir == "") { outputDir += m->hasPath(namefile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(namefile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile); ofstream out; m->openOutputFile(outputFileName, out); @@ -416,8 +419,9 @@ int GetSeqsCommand::readName(){ //********************************************************************************************************************** int GetSeqsCommand::readGroup(){ try { - if (outputDir == "") { outputDir += m->hasPath(groupfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile); ofstream out; m->openOutputFile(outputFileName, out); @@ -462,8 +466,9 @@ int GetSeqsCommand::readGroup(){ //********************************************************************************************************************** int GetSeqsCommand::readTax(){ try { - if (outputDir == "") { outputDir += m->hasPath(taxfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(taxfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile); ofstream out; m->openOutputFile(outputFileName, out); @@ -507,8 +512,9 @@ int GetSeqsCommand::readTax(){ //alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name int GetSeqsCommand::readAlign(){ try { - if (outputDir == "") { outputDir += m->hasPath(alignfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report"; + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(alignfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report"; ofstream out; m->openOutputFile(outputFileName, out); diff --git a/globaldata.cpp b/globaldata.cpp index 74daaa2..b18324b 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -67,6 +67,7 @@ GlobalData::GlobalData() { gTreemap = NULL; gSequenceDB = NULL; nameMap = NULL; + saveNextLabel = ""; } /*******************************************************/ @@ -87,6 +88,7 @@ void GlobalData::clear() { sharedfile = ""; relAbundfile = ""; format = ""; + saveNextLabel = ""; } diff --git a/globaldata.hpp b/globaldata.hpp index bfb8a06..b5e8c7c 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -48,6 +48,7 @@ public: set labels; //holds labels to be used vector Treenames; map names; + string saveNextLabel; string getPhylipFile(); diff --git a/nast.cpp b/nast.cpp index 9cdf1b2..b288752 100644 --- a/nast.cpp +++ b/nast.cpp @@ -223,7 +223,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl void Nast::regapSequences(){ //This is essentially part B in Fig 2. of DeSantis et al. try { - + //cout << candidateSeq->getName() << endl; string candPair = candidateSeq->getPairwise(); string candAln = ""; @@ -252,6 +252,7 @@ void Nast::regapSequences(){ //This is essentially part B in Fig 2. of DeSantis string lastLoop = ""; while(pairwiseAlignIndexsetAligned(candAln); + //cout << "here" << endl; } catch(exception& e) { m->errorOut(e, "Nast", "regapSequences"); diff --git a/pintail.cpp b/pintail.cpp index 4ad60c5..2362eb5 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -92,7 +92,7 @@ int Pintail::doPrep() { m->mothurOut("Getting conservation... "); cout.flush(); if (consfile == "") { m->mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush(); - probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + m->getSimpleName(templateFileName)); + probabilityProfile = decalc->calcFreq(templateSeqs, templateFileName); if (m->control_pressed) { return 0; } m->mothurOut("Done."); m->mothurOutEndLine(); }else { probabilityProfile = readFreq(); m->mothurOut("Done."); } @@ -170,13 +170,13 @@ int Pintail::doPrep() { string noOutliers, outliers; if ((!filter) && (seqMask == "")) { - noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.quan"; + noOutliers = templateFileName + "pintail.quan"; }else if ((!filter) && (seqMask != "")) { - noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.masked.quan"; + noOutliers =templateFileName + "pintail.masked.quan"; }else if ((filter) && (seqMask != "")) { - noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan"; + noOutliers = templateFileName + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan"; }else if ((filter) && (seqMask == "")) { - noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan"; + noOutliers = templateFileName + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan"; } decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size()); diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index b77e69f..0ab181b 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -210,8 +210,10 @@ int RemoveSeqsCommand::execute(){ //********************************************************************************************************************** int RemoveSeqsCommand::readFasta(){ try { - if (outputDir == "") { outputDir += m->hasPath(fastafile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(fastafile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile); + ofstream out; m->openOutputFile(outputFileName, out); @@ -254,8 +256,10 @@ int RemoveSeqsCommand::readFasta(){ //********************************************************************************************************************** int RemoveSeqsCommand::readList(){ try { - if (outputDir == "") { outputDir += m->hasPath(listfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(listfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile); + ofstream out; m->openOutputFile(outputFileName, out); @@ -323,8 +327,9 @@ int RemoveSeqsCommand::readList(){ //********************************************************************************************************************** int RemoveSeqsCommand::readName(){ try { - if (outputDir == "") { outputDir += m->hasPath(namefile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(namefile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile); ofstream out; m->openOutputFile(outputFileName, out); @@ -408,8 +413,10 @@ int RemoveSeqsCommand::readName(){ //********************************************************************************************************************** int RemoveSeqsCommand::readGroup(){ try { - if (outputDir == "") { outputDir += m->hasPath(groupfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile); + ofstream out; m->openOutputFile(outputFileName, out); @@ -449,8 +456,9 @@ int RemoveSeqsCommand::readGroup(){ //********************************************************************************************************************** int RemoveSeqsCommand::readTax(){ try { - if (outputDir == "") { outputDir += m->hasPath(taxfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile); + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(taxfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile); ofstream out; m->openOutputFile(outputFileName, out); @@ -491,8 +499,10 @@ int RemoveSeqsCommand::readTax(){ //alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name int RemoveSeqsCommand::readAlign(){ try { - if (outputDir == "") { outputDir += m->hasPath(alignfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report"; + string thisOutputDir = outputDir; + if (outputDir == "") { thisOutputDir += m->hasPath(alignfile); } + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report"; + ofstream out; m->openOutputFile(outputFileName, out); diff --git a/sharedrabundfloatvector.cpp b/sharedrabundfloatvector.cpp index f7405ae..84b1cf5 100644 --- a/sharedrabundfloatvector.cpp +++ b/sharedrabundfloatvector.cpp @@ -45,8 +45,12 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } lookup.clear(); + if (globaldata->saveNextLabel == "") { f >> label; } + else { label = globaldata->saveNextLabel; } + //read in first row since you know there is at least 1 group. - f >> label >> groupN >> num; + f >> groupN >> num; + holdLabel = label; //add new vector to lookup @@ -103,8 +107,7 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma if (f.eof() != true) { f >> nextLabel; } } - //put file pointer back since you are now at a new distance label - for (int i = 0; i < nextLabel.length(); i++) { f.unget(); } + globaldata->saveNextLabel = nextLabel; if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 6259ba2..9328cbd 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -73,8 +73,12 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } lookup.clear(); + if (globaldata->saveNextLabel == "") { f >> label; } + else { label = globaldata->saveNextLabel; } + //read in first row since you know there is at least 1 group. - f >> label >> groupN >> num; + f >> groupN >> num; + holdLabel = label; //add new vector to lookup @@ -98,13 +102,12 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), //numSeqs += inputData; //numBins++; if (inputData > maxRank) { maxRank = inputData; } - } m->gobble(f); - if (f.eof() != true) { f >> nextLabel; } - + if (!(f.eof())) { f >> nextLabel; } + //read the rest of the groups info in while ((nextLabel == holdLabel) && (f.eof() != true)) { f >> groupN >> num; @@ -133,9 +136,8 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), if (f.eof() != true) { f >> nextLabel; } } - - //put file pointer back since you are now at a new distance label - for (int i = 0; i < nextLabel.length(); i++) { f.unget(); } + + globaldata->saveNextLabel = nextLabel; if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 3828a38..f44a2cd 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -422,7 +422,8 @@ int SummarySharedCommand::process(vector thisLookup) { int n = 1; vector subset; - for (int k = 0; k < (thisLookup.size() - 1); k++) { // pass cdd each set of groups to commpare + for (int k = 0; k < (thisLookup.size() - 1); k++) { // pass cdd each set of groups to compare + for (int l = n; l < thisLookup.size(); l++) { outputFileHandle << thisLookup[0]->getLabel() << '\t'; diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 9594767..637ecce 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -50,6 +50,8 @@ TreeGroupCommand::TreeGroupCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + globaldata->newRead(); + //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; } diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 3c1367a..acdf475 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -315,7 +315,7 @@ int TrimSeqsCommand::execute(){ if (m->control_pressed) { return 0; } #else - driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, groupFile, fastaFileNames, qualFileNames, lines[0], qlines[0]); + driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, groupFile, fastaFileNames, qualFileNames, lines[0], qLines[0]); for (int j = 0; j < fastaFileNames.size(); j++) { rename((fastaFileNames[j] + toString(j) + ".temp").c_str(), fastaFileNames[j].c_str()); -- 2.39.2