]> git.donarmstrong.com Git - mothur.git/blobdiff - removerarecommand.cpp
added otu.association command. added calcSpearman, calcKendall and calcPearson functi...
[mothur.git] / removerarecommand.cpp
index 41355b9560e910c03be93e527524e4363b86be11..24b616560de3bed794d423f4cb7a3544f0d48f5f 100644 (file)
@@ -50,7 +50,7 @@ string RemoveRareCommand::getHelpString(){
                helpString += "The nseqs parameter allows you to set the cutoff for an otu to be deemed rare. It is required.\n";
                helpString += "The remove.rare command should be in the following format: remove.rare(shared=yourSharedFile, nseqs=yourRareCutoff).\n";
                helpString += "Example remove.rare(shared=amazon.fn.shared, nseqs=2).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedFile).\n\n";
+               helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedFile).\n";
                return helpString;
        }
        catch(exception& e) {
@@ -83,6 +83,7 @@ RemoveRareCommand::RemoveRareCommand(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();
@@ -159,23 +160,28 @@ RemoveRareCommand::RemoveRareCommand(string option)  {
                        //check for file parameters
                        listfile = validParameter.validFile(parameters, "list", true);
                        if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }  
+                       else if (listfile == "not found") {  listfile = "";  }
+                       else { m->setListFile(listfile); }
                        
                        sabundfile = validParameter.validFile(parameters, "sabund", true);
                        if (sabundfile == "not open") { abort = true; }
                        else if (sabundfile == "not found") {  sabundfile = "";  }      
+                       else { m->setSabundFile(sabundfile); }
                        
                        rabundfile = validParameter.validFile(parameters, "rabund", true);
                        if (rabundfile == "not open") { abort = true; }
                        else if (rabundfile == "not found") {  rabundfile = "";  }                              
+                       else { m->setRabundFile(rabundfile); }
                        
                        groupfile = validParameter.validFile(parameters, "group", true);
                        if (groupfile == "not open") { groupfile = ""; abort = true; }
                        else if (groupfile == "not found") {  groupfile = "";  }        
+                       else { m->setGroupFile(groupfile); }
                        
                        sharedfile = validParameter.validFile(parameters, "shared", true);
                        if (sharedfile == "not open") { sharedfile = "";  abort = true; }
                        else if (sharedfile == "not found") {  sharedfile = "";  }
+                       else { m->setSharedFile(sharedfile); }
                        
                        if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
                                //is there are current file available for any of these?
@@ -214,7 +220,7 @@ RemoveRareCommand::RemoveRareCommand(string option)  {
                        
                        string temp = validParameter.validFile(parameters, "nseqs", false);      
                        if (temp == "not found") { m->mothurOut("nseqs is a required parameter."); m->mothurOutEndLine(); abort = true; }
-                       else { convert(temp, nseqs); }
+                       else { m->mothurConvert(temp, nseqs); }
                        
                        temp = validParameter.validFile(parameters, "bygroup", false);   if (temp == "not found") { temp = "f"; }
                        byGroup = m->isTrue(temp);
@@ -245,7 +251,7 @@ int RemoveRareCommand::execute(){
                if (listfile != "")                     {               processList();          }
                if (sharedfile != "")           {               processShared();        }
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0; }
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
                        
                if (outputNames.size() != 0) {
                        m->mothurOutEndLine();
@@ -347,7 +353,8 @@ int RemoveRareCommand::processList(){
                if (groupfile != "") { 
                        groupMap = new GroupMap(groupfile); groupMap->readMap(); 
                        SharedUtil util;
-                       util.setGroups(Groups, groupMap->namesOfGroups);
+                       vector<string> namesGroups = groupMap->getNamesOfGroups();
+                       util.setGroups(Groups, namesGroups);
                        m->openOutputFile(outputGroupFileName, outGroup);
                }
                
@@ -359,7 +366,7 @@ int RemoveRareCommand::processList(){
                        
                        //for each bin
                        for (int i = 0; i < list->getNumBins(); i++) {
-                               if (m->control_pressed) {  if (groupfile != "") { delete groupMap; outGroup.close(); remove(outputGroupFileName.c_str()); } out.close();  remove(outputFileName.c_str());  return 0; }
+                               if (m->control_pressed) {  if (groupfile != "") { delete groupMap; outGroup.close(); m->mothurRemove(outputGroupFileName); } out.close();  m->mothurRemove(outputFileName);  return 0; }
                                
                                //parse out names that are in accnos file
                                string binnames = list->get(i);
@@ -618,7 +625,7 @@ int RemoveRareCommand::processRabund(){
 //**********************************************************************************************************************
 int RemoveRareCommand::processShared(){
        try {
-               m->Groups = Groups;
+               m->setGroups(Groups);
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
@@ -645,6 +652,7 @@ int RemoveRareCommand::processShared(){
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
                                
+                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
                                processLookup(lookup, out);
                        }
                        
@@ -658,6 +666,7 @@ int RemoveRareCommand::processShared(){
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
                                
+                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
                                processLookup(lookup, out);                     
                                
                                //restore real lastlabel to save below
@@ -692,6 +701,7 @@ int RemoveRareCommand::processShared(){
                        
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        
+                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
                        processLookup(lookup, out);     
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }