]> git.donarmstrong.com Git - mothur.git/blobdiff - libshuffcommand.cpp
rewrote metastats command in c++, added mothurRemove function to handle ~ error....
[mothur.git] / libshuffcommand.cpp
index c827b524649fefe49545aa8769401d781ff016c1..96abbbe995918d779e4cd9086e650b7aa63a8a7b 100644 (file)
@@ -86,6 +86,7 @@ LibShuffCommand::LibShuffCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -137,7 +138,7 @@ LibShuffCommand::LibShuffCommand(string option)  {
                                        m->mothurOut("You must provide a phylip file."); m->mothurOutEndLine(); 
                                        abort = true;
                                } 
-                       }       
+                       }else { m->setPhylipFile(phylipfile); } 
                        
                        //check for required parameters
                        groupfile = validParameter.validFile(parameters, "group", true);
@@ -149,7 +150,7 @@ LibShuffCommand::LibShuffCommand(string option)  {
                                        m->mothurOut("You must provide a group file."); m->mothurOutEndLine(); 
                                        abort = true;
                                } 
-                       }       
+                       }else { m->setGroupFile(groupfile); }   
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
@@ -221,7 +222,7 @@ int LibShuffCommand::execute(){
                        m->openOutputFile(newGroupFile, outGroups);
                        
                        for (int i = 0; i < matrix->getNumSeqs(); i++) {
-                               if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); remove(newGroupFile.c_str()); return 0; }
+                               if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; }
                                
                                Names temp = matrix->getRowInfo(i);
                                outGroups << temp.seqName << '\t' << temp.groupName << endl;
@@ -237,12 +238,16 @@ int LibShuffCommand::execute(){
                        groupMap = new GroupMap(groupfile);
                        groupMap->readMap();
                        
-                       if (m->control_pressed) { delete groupMap; delete matrix; remove(newGroupFile.c_str()); return 0; }
+                       if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; }
                }
                
                        
                setGroups();                                                            //set the groups to be analyzed and sorts them
-                       
+               
+               if (numGroups < 2) { m->mothurOut("[ERROR]: libshuff requires at least 2 groups, you only have " + toString(numGroups) + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
+               
+               if (m->control_pressed) { delete groupMap; delete matrix; return 0; }
+               
                /********************************************************************************************/
                //this is needed because when we read the matrix we sort it into groups in alphabetical order
                //the rest of the command and the classes used in this command assume specific order
@@ -315,7 +320,7 @@ int LibShuffCommand::execute(){
                
                delete matrix; delete groupMap;
                
-               if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0; }
 
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();