]> git.donarmstrong.com Git - mothur.git/commitdiff
added check for blank files in openInputFile, add check for groupfiles that contain...
authorwestcott <westcott>
Thu, 17 Sep 2009 13:48:20 +0000 (13:48 +0000)
committerwestcott <westcott>
Thu, 17 Sep 2009 13:48:20 +0000 (13:48 +0000)
groupmap.h
mothur.h
pintail.cpp
sharedcommand.cpp

index d69699d382530f688a0f6023f90b1ffed1bdfffe..54225e22a0ffab29c3ef7081aec8e75257d6d2d7 100644 (file)
@@ -26,7 +26,8 @@ public:
        void setGroup(string, string);
        vector<string> namesOfGroups;
        map<string, int> groupIndex;  //groupname, vectorIndex in namesOfGroups. - used by collectdisplays.
-               
+       int getNumSeqs()  {  return groupmap.size();  }
+                       
 private:
        ifstream fileHandle;
        string groupFileName;
index e3e2ef415fd8f9f4ea5d45e8c0bcd192a06f01f7..836e0660dae78b87fe71e20bc95f59506c81d5dd 100644 (file)
--- 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;
        }
        
index 7b99cab9e7eed714a0cefeee4b45ed8057429c6f..5f575f2bc41721e7fc3b52ec7d6fb68163b43131 100644 (file)
@@ -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 == "") { 
index 4b35138998b13bfe181c743bdfd50e4f64f60752..717d3aaba162daad61bfcd053f672a3f5f685382 100644 (file)
@@ -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<SharedRAbundVector*> 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<string> processedLabels;
                set<string> userLabels = globaldata->labels;
@@ -131,7 +145,6 @@ int SharedCommand::execute(){
                }
                
                globaldata->gSharedList = NULL;
-               delete read;
                
                out.close();