]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed classify.seq error message when flip accnos file was blank. Fixed bug with...
authorSarah Westcott <mothur.westcott@gmail.com>
Mon, 5 Mar 2012 14:59:50 +0000 (09:59 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Mon, 5 Mar 2012 14:59:50 +0000 (09:59 -0500)
classifyseqscommand.cpp
phylotypecommand.cpp

index 794b961dcc29ecdc79bf063d116887b4cf8c30ac..72acd2265a06af1b77dc525f3627e51c458e6aed 100644 (file)
@@ -905,16 +905,35 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile,
                }
                
        #endif  
-               
+        vector<string> nonBlankAccnosFiles;
+               if (!(m->isBlank(accnos))) { nonBlankAccnosFiles.push_back(accnos); }
+               else { m->mothurRemove(accnos); } //remove so other files can be renamed to it
+        
                for(int i=0;i<processIDS.size();i++){
                        appendTaxFiles((taxFileName + toString(processIDS[i]) + ".temp"), taxFileName);
                        appendTaxFiles((tempTaxFile + toString(processIDS[i]) + ".temp"), tempTaxFile);
-                       appendTaxFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
+            if (!(m->isBlank(accnos + toString(processIDS[i]) + ".temp"))) {
+                               nonBlankAccnosFiles.push_back(accnos + toString(processIDS[i]) + ".temp");
+                       }else { m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));  }
+
                        m->mothurRemove((m->getFullPathName(taxFileName) + toString(processIDS[i]) + ".temp"));
                        m->mothurRemove((m->getFullPathName(tempTaxFile) + toString(processIDS[i]) + ".temp"));
-                       m->mothurRemove((m->getFullPathName(accnos) + toString(processIDS[i]) + ".temp"));
                }
                
+        //append accnos files
+               if (nonBlankAccnosFiles.size() != 0) { 
+                       rename(nonBlankAccnosFiles[0].c_str(), accnos.c_str());
+                       
+                       for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
+                               appendTaxFiles(nonBlankAccnosFiles[h], accnos);
+                               m->mothurRemove(nonBlankAccnosFiles[h]);
+                       }
+               }else { //recreate the accnosfile if needed
+                       ofstream out;
+                       m->openOutputFile(accnos, out);
+                       out.close();
+               }
+
                return num;
                
        }
index 1d6c391de69c83a86971873577a0df0b21efdbcd..f402f2a8ab15a1808a461d376818d97d98c5c5c7 100644 (file)
@@ -244,13 +244,15 @@ int PhylotypeCommand::execute(){
                                        //make the names compatable with listvector
                                        string name = "";
                                        for (int i = 0; i < names.size(); i++) {  
-                                               if (namefile != "") {   
-                                                       map<string, string>::iterator itNames = namemap.find(names[i]);  //make sure this name is in namefile
-               
-                                                       if (itNames != namemap.end()) {  name += namemap[names[i]] + ",";   } //you found it in namefile
-                                                       else { m->mothurOut(names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); exit(1);  }
-                                                       
-                                               }else{   name += names[i] + ",";        }
+                        if (names[i] != "unknown") {
+                            if (namefile != "") {      
+                                map<string, string>::iterator itNames = namemap.find(names[i]);  //make sure this name is in namefile
+                                
+                                if (itNames != namemap.end()) {  name += namemap[names[i]] + ",";   } //you found it in namefile
+                                else { m->mothurOut(names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); exit(1);  }
+                                
+                            }else{   name += names[i] + ",";   }
+                        }
                                        }
                                        name = name.substr(0, name.length()-1);  //rip off extra ','