From c5c3ba0fa9d18707c9c9ce692cff061b6f882e44 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 17 Sep 2009 13:48:20 +0000 Subject: [PATCH] added check for blank files in openInputFile, add check for groupfiles that contain more seqs than the list files in sharedcommand --- groupmap.h | 3 ++- mothur.h | 4 ++++ pintail.cpp | 11 ++++------- sharedcommand.cpp | 17 +++++++++++++++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/groupmap.h b/groupmap.h index d69699d..54225e2 100644 --- a/groupmap.h +++ b/groupmap.h @@ -26,7 +26,8 @@ public: void setGroup(string, string); vector namesOfGroups; map groupIndex; //groupname, vectorIndex in namesOfGroups. - used by collectdisplays. - + int getNumSeqs() { return groupmap.size(); } + private: ifstream fileHandle; string groupFileName; diff --git a/mothur.h b/mothur.h index e3e2ef4..836e066 100644 --- a/mothur.h +++ b/mothur.h @@ -425,6 +425,10 @@ inline int openInputFile(string fileName, ifstream& fileHandle){ return 1; } else { + //check for blank file + gobble(fileHandle); + if (fileHandle.eof()) { mothurOut(fileName + " is blank. Please correct."); mothurOutEndLine(); return 1; } + return 0; } diff --git a/pintail.cpp b/pintail.cpp index 7b99cab..5f575f2 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -146,18 +146,15 @@ void Pintail::getChimeras() { mothurOut("Done."); mothurOutEndLine(); }else { createProcessesPairs(); } -/*string o = "foronlinepintailpairs-eachgap"; +string o = "closestmatch.eachgap.fasta"; ofstream out7; openOutputFile(o, out7); for (int i = 0; i < bestfit.size(); i++) { - out7 << querySeqs[i]->getName() << endl; - out7 << querySeqs[i]->getUnaligned() << endl << endl; - - out7 << bestfit[i]->getName() << endl; - out7 << bestfit[i]->getUnaligned() << endl << endl << endl; + out7 << ">" << querySeqs[i]->getName() << "-"<< bestfit[i]->getName() << endl; + out7 << bestfit[i]->getAligned() << endl; } -out7.close();/*/ +out7.close(); //find P mothurOut("Getting conservation... "); cout.flush(); if (consfile == "") { diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 4b35138..717d3aa 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -57,12 +57,26 @@ int SharedCommand::execute(){ //read in listfile read = new ReadOTUFile(globaldata->inputFileName); read->read(&*globaldata); + delete read; input = globaldata->ginput; SharedList = globaldata->gSharedList; string lastLabel = SharedList->getLabel(); vector lookup; - + + if (SharedList->getNumSeqs() != groupMap->getNumSeqs()) { + mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); mothurOutEndLine(); + + //delete memory + for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { + delete it3->second; + } + delete SharedList; + globaldata->gSharedList = NULL; + + 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; set userLabels = globaldata->labels; @@ -131,7 +145,6 @@ int SharedCommand::execute(){ } globaldata->gSharedList = NULL; - delete read; out.close(); -- 2.39.2