]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed minor issue with sub.sample command.
authorwestcott <westcott>
Tue, 4 Oct 2011 19:24:17 +0000 (19:24 +0000)
committerwestcott <westcott>
Tue, 4 Oct 2011 19:24:17 +0000 (19:24 +0000)
countgroupscommand.cpp
getgroupscommand.cpp
removegroupscommand.cpp
seqerrorcommand.cpp
subsamplecommand.cpp

index 24b4214dd5600ef0f0625ba7acf0da2a8f328108..0c03882a459135afaad797728f2ed268b17c9abb 100644 (file)
@@ -34,7 +34,7 @@ vector<string> CountGroupsCommand::setParameters(){
 string CountGroupsCommand::getHelpString(){    
        try {
                string helpString = "";
-               helpString += "The count.groups command counts sequences from a specfic group or set of groups from the following file types: group or shared file.\n";
+               helpString += "The count.groups command counts sequences from a specific group or set of groups from the following file types: group or shared file.\n";
                helpString += "The count.groups command parameters are accnos, group, shared and groups. You must provide a group or shared file.\n";
                helpString += "The accnos parameter allows you to provide a file containing the list of groups.\n";
                helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like.  You can separate group names with dashes.\n";
index 5021f4085534cfc84a17d5875e449cf90f9f1d53..e8f42dda532fab7f252de8c95e220c8eb27fa8f8 100644 (file)
@@ -189,6 +189,15 @@ GetGroupsCommand::GetGroupsCommand(string option)  {
                        else if (namefile == "not found") {  namefile = "";  }  
                        else { m->setNameFile(namefile); }
                        
+                       groupfile = validParameter.validFile(parameters, "group", true);
+                       if (groupfile == "not open") { abort = true; }
+                       else if (groupfile == "not found") {  
+                               //if there is a current group file, use it
+                               groupfile = m->getGroupFile(); 
+                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
+                               else {  m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
+                       }else { m->setGroupFile(groupfile); }   
+                       
                        listfile = validParameter.validFile(parameters, "list", true);
                        if (listfile == "not open") { abort = true; }
                        else if (listfile == "not found") {  listfile = "";  }
index 81722dd3e4047fc2505d64372a2ca539978c9445..725efafebce46296da2d9fd60a367ddc44d18fc2 100644 (file)
@@ -190,6 +190,15 @@ RemoveGroupsCommand::RemoveGroupsCommand(string option)  {
                        else if (namefile == "not found") {  namefile = "";  }  
                        else { m->setNameFile(namefile); }
                        
+                       groupfile = validParameter.validFile(parameters, "group", true);
+                       if (groupfile == "not open") { abort = true; }
+                       else if (groupfile == "not found") {            
+                               //if there is a current group file, use it
+                               groupfile = m->getGroupFile(); 
+                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
+                               else {  m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
+                       }else { m->setGroupFile(groupfile); }   
+                       
                        listfile = validParameter.validFile(parameters, "list", true);
                        if (listfile == "not open") { listfile = ""; abort = true; }
                        else if (listfile == "not found") {  listfile = "";  }
index d3f62826dce1d75e03e70c8614de2465ded64302..253e03e2a1d380cb4d13f360fc9a5fecaaeb0808 100644 (file)
@@ -178,7 +178,11 @@ SeqErrorCommand::SeqErrorCommand(string option)  {
                        }
                        else if (queryFileName == "not open") { abort = true; } 
                        else { m->setFastaFile(queryFileName); }
-
+                       
+                       referenceFileName = validParameter.validFile(parameters, "reference", true);
+                       if (referenceFileName == "not found") { m->mothurOut("reference is a required parameter for the seq.error command."); m->mothurOutEndLine(); abort = true; }
+                       else if (referenceFileName == "not open") { abort = true; }     
+                       
                        //check for optional parameters
                        namesFileName = validParameter.validFile(parameters, "name", true);
                        if(namesFileName == "not found"){       namesFileName = "";     }
index 49a821045e122b5097fde092a5845378e21afc60..24c83fdc2142a0ad875cba6ff49ffd3d15b73fef 100644 (file)
@@ -426,6 +426,7 @@ int SubSampleCommand::getSubSampleFasta() {
                if (persample) {
                        //initialize counts
                        map<string, int> groupCounts;
+                       map<string, int>::iterator itGroupCounts;
                        for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
                        
                        for (int j = 0; j < names.size(); j++) {
@@ -435,7 +436,10 @@ int SubSampleCommand::getSubSampleFasta() {
                                string group = groupMap->getGroup(names[j]);
                                if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
                                else{
-                                       if (groupCounts[group] < size) {        subset.insert(names[j]);        }
+                                       itGroupCounts = groupCounts.find(group);
+                                       if (itGroupCounts != groupCounts.end()) {
+                                               if (groupCounts[group] < size) {        subset.insert(names[j]);        groupCounts[group]++; }
+                                       }
                                }                               
                        }
                }else {
@@ -1025,6 +1029,7 @@ int SubSampleCommand::getSubSampleList() {
                if (persample) {
                        //initialize counts
                        map<string, int> groupCounts;
+                       map<string, int>::iterator itGroupCounts;
                        for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
                        
                        for (int j = 0; j < names.size(); j++) {
@@ -1034,7 +1039,10 @@ int SubSampleCommand::getSubSampleList() {
                                string group = groupMap->getGroup(names[j]);
                                if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
                                else{
-                                       if (groupCounts[group] < size) {        subset.insert(names[j]);        }
+                                       itGroupCounts = groupCounts.find(group);
+                                       if (itGroupCounts != groupCounts.end()) {
+                                               if (groupCounts[group] < size) {        subset.insert(names[j]);        groupCounts[group]++; }
+                                       }
                                }                               
                        }
                }else{