]> git.donarmstrong.com Git - mothur.git/blobdiff - getoturepcommand.cpp
adds group parameter to chimera.uchime so you can check for chimeras with template...
[mothur.git] / getoturepcommand.cpp
index 342190db9a8f178aca59dfd94e7918fcd6e527c9..378e9186a70b46f8a8c8821b77e3c213b2859990 100644 (file)
@@ -117,6 +117,7 @@ GetOTURepCommand::GetOTURepCommand(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();
                        
@@ -202,6 +203,7 @@ GetOTURepCommand::GetOTURepCommand(string option)  {
                                else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
                        }
                        else if (fastafile == "not open") { abort = true; }     
+                       else { m->setFastaFile(fastafile); }
                
                        listfile = validParameter.validFile(parameters, "list", true);
                        if (listfile == "not found") {                  
@@ -210,20 +212,22 @@ GetOTURepCommand::GetOTURepCommand(string option)  {
                                else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
                        }
                        else if (listfile == "not open") { abort = true; }      
+                       else { m->setListFile(listfile); }
                        
                        phylipfile = validParameter.validFile(parameters, "phylip", true);
                        if (phylipfile == "not found") { phylipfile = "";  }
                        else if (phylipfile == "not open") { abort = true; }    
-                       else { distFile = phylipfile; format = "phylip";   }
+                       else { distFile = phylipfile; format = "phylip"; m->setPhylipFile(phylipfile);   }
                        
                        columnfile = validParameter.validFile(parameters, "column", true);
                        if (columnfile == "not found") { columnfile = ""; }
                        else if (columnfile == "not open") { abort = true; }    
-                       else { distFile = columnfile; format = "column";   }
+                       else { distFile = columnfile; format = "column";  m->setColumnFile(columnfile); }
                        
                        namefile = validParameter.validFile(parameters, "name", true);
                        if (namefile == "not open") { abort = true; }   
                        else if (namefile == "not found") { namefile = ""; }
+                       else { m->setNameFile(namefile); }
                        
                        if ((phylipfile == "") && (columnfile == "")) { //is there are current file available for either of these?
                                //give priority to column, then phylip
@@ -262,7 +266,8 @@ GetOTURepCommand::GetOTURepCommand(string option)  {
                        groupfile = validParameter.validFile(parameters, "group", true);
                        if (groupfile == "not open") { groupfile = ""; abort = true; }
                        else if (groupfile == "not found") { groupfile = ""; }
-                                               
+                       else { m->setGroupFile(groupfile); }
+                       
                        sorted = validParameter.validFile(parameters, "sorted", false);         if (sorted == "not found"){     sorted = "";    }
                        if (sorted == "none") { sorted=""; }
                        if ((sorted != "") && (sorted != "name") && (sorted != "bin") && (sorted != "size") && (sorted != "group")) {
@@ -285,7 +290,7 @@ GetOTURepCommand::GetOTURepCommand(string option)  {
                                        m->splitAtDash(groups, Groups);
                                }
                        }
-                       m->Groups = Groups;
+                       m->setGroups(Groups);
                        
                        string temp = validParameter.validFile(parameters, "large", false);             if (temp == "not found") {      temp = "F";     }
                        large = m->isTrue(temp);
@@ -389,7 +394,7 @@ int GetOTURepCommand::execute(){
                        //openfile for getMap to use
                        m->openInputFile(distFile, inRow);
                        
-                       if (m->control_pressed) { inRow.close(); remove(distFile.c_str()); return 0; }
+                       if (m->control_pressed) { inRow.close(); m->mothurRemove(distFile); return 0; }
                }
                
                
@@ -412,7 +417,7 @@ int GetOTURepCommand::execute(){
                
                                
                if (m->control_pressed) { 
-                       if (large) {  inRow.close(); remove(distFile.c_str());  }
+                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
                        return 0; 
                }
                
@@ -424,7 +429,9 @@ int GetOTURepCommand::execute(){
                        
                        if (Groups.size() != 0) {
                                SharedUtil* util = new SharedUtil();
-                               util->setGroups(Groups, groupMap->namesOfGroups, "getoturep");
+                               vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
+                               util->setGroups(Groups, gNamesOfGroups, "getoturep");
+                               groupMap->setNamesOfGroups(gNamesOfGroups);
                                delete util;
                        }
                }
@@ -441,7 +448,7 @@ int GetOTURepCommand::execute(){
                set<string> userLabels = labels;
                
                if (m->control_pressed) { 
-                       if (large) {  inRow.close(); remove(distFile.c_str());  }
+                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
                        delete input; delete list; return 0; 
                }
                
@@ -455,8 +462,8 @@ int GetOTURepCommand::execute(){
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
                                        if (m->control_pressed) { 
-                                               if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
+                                               if (large) {  inRow.close(); m->mothurRemove(distFile);  }
+                                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
                                                delete input; delete list; return 0; 
                                        }
                                        
@@ -474,8 +481,8 @@ int GetOTURepCommand::execute(){
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
                                        if (m->control_pressed) { 
-                                               if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
+                                               if (large) {  inRow.close(); m->mothurRemove(distFile);  }
+                                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
                                                delete input; delete list; return 0; 
                                        }
                                        
@@ -514,8 +521,8 @@ int GetOTURepCommand::execute(){
                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                        
                        if (m->control_pressed) { 
-                                       if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
+                                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
+                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
                                        delete input; delete list; return 0; 
                        }
                }
@@ -523,7 +530,7 @@ int GetOTURepCommand::execute(){
                //close and remove formatted matrix file
                if (large) {
                        inRow.close();
-                       remove(distFile.c_str());
+                       m->mothurRemove(distFile);
                }
                
                delete input;  
@@ -645,7 +652,7 @@ string GetOTURepCommand::findRep(vector<string> names) {
        try{
                // if only 1 sequence in bin or processing the "unique" label, then 
                // the first sequence of the OTU is the representative one
-               if ((names.size() == 1) || (list->getLabel() == "unique")) {
+               if ((names.size() == 1)) {
                        return names[0];
                }else{
                        vector<int> seqIndex(names.size());
@@ -949,7 +956,7 @@ int GetOTURepCommand::processNames(string filename, string label) {
                out.close();
                out2.close();
                
-               remove(filename.c_str());
+               m->mothurRemove(filename);
                rename(tempNameFile.c_str(), filename.c_str());
                
                return 0;