]> git.donarmstrong.com Git - mothur.git/blobdiff - makegroupcommand.cpp
added countgaps parameter to chop.seqs command
[mothur.git] / makegroupcommand.cpp
index f567fbda600cecf76338c9081e10d51a872ecbc3..455826a3a8ab61ec1cf7a5af44e91ba791907583 100644 (file)
@@ -60,18 +60,26 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                                if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
                                        }
        
-                                       int ableToOpen;
                                        ifstream in;
-                                       
-                                       ableToOpen = openInputFile(fastaFileNames[i], in);
+                                       int ableToOpen = openInputFile(fastaFileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
-
+                                       
                                        if (ableToOpen == 1) { 
+                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
                                                //erase from file list
                                                fastaFileNames.erase(fastaFileNames.begin()+i);
                                                i--;
                                        }else{  filename += getRootName(getSimpleName(fastaFileNames[i]));  }
-                                       
                                }
                                
                                filename += "groups";
@@ -127,12 +135,16 @@ int MakeGroupCommand::execute(){
                
                for (int i = 0; i < fastaFileNames.size(); i++) {
                
+                       if (m->control_pressed) {  out.close(); remove(filename.c_str()); return 0; }
+                       
                        ifstream in;
                        openInputFile(fastaFileNames[i], in);
                        
                        while (!in.eof()) {
                                
-                               Sequence seq(in); gobble(in);
+                               Sequence seq(in, "no align"); gobble(in);
+                               
+                               if (m->control_pressed) {  in.close(); out.close(); remove(filename.c_str()); return 0; }
                                
                                if (seq.getName() != "") {      out << seq.getName() << '\t' << groupsNames[i] << endl;         }
                        }