]> git.donarmstrong.com Git - mothur.git/blobdiff - subsamplecommand.cpp
adding labels to list file.
[mothur.git] / subsamplecommand.cpp
index 32745a25ee0ae66e6f6cbcb50cc4db4469cca21f..a89d191a9127065922c3d498edce5cab41030f27 100644 (file)
@@ -273,7 +273,7 @@ SubSampleCommand::SubSampleCommand(string option) {
                        else if (countfile == "not found") { countfile = "";  } 
                        else {
                 m->setCountTableFile(countfile); 
-                ct.readTable(countfile);
+                ct.readTable(countfile, true, false);
             }
             
             if ((namefile != "") && (countfile != "")) {
@@ -552,7 +552,7 @@ int SubSampleCommand::getSubSampleFasta() {
                     else{
                         itGroupCounts = groupCounts.find(group);
                         if (itGroupCounts != groupCounts.end()) {
-                            if (groupCounts[group] < size) {   subset.insert(names[j]);        groupCounts[group]++; }
+                            if (itGroupCounts->second < size) {        subset.insert(names[j]);        (itGroupCounts->second)++; }
                         }
                     }                          
                 }
@@ -947,7 +947,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
        try {
                
                //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
+               vector<string> saveBinLabels = m->currentSharedBinLabels;
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
@@ -965,7 +965,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
                m->openOutputFile(outputFileName, out);
                outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
                
-        m->currentBinLabels = subsampledLabels;
+        m->currentSharedBinLabels = subsampledLabels;
         
                thislookup[0]->printHeaders(out);
                
@@ -977,7 +977,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
         
         
         //save mothurOut's binLabels to restore for next label
-               m->currentBinLabels = saveBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
                
                return 0;
                
@@ -1007,7 +1007,7 @@ int SubSampleCommand::getSubSampleList() {
                ListVector* list = input->getListVector();
                string lastLabel = list->getLabel();
                
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+        //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                set<string> processedLabels;
                set<string> userLabels = labels;
 
@@ -1265,11 +1265,18 @@ int SubSampleCommand::getSubSampleList() {
         
         if (taxonomyfile != "") {
             if (namefile == "") {
-                //fake nameMap
-                for (set<string>::iterator it = subset.begin(); it != subset.end(); it++) {
-                    vector<string> temp; temp.push_back(*it);
-                    nameMap[*it] = temp;
+                InputData input(listfile, "list");
+                ListVector* list = input.getListVector();
+                string lastLabel = list->getLabel();
+                
+                for (int i = 0; i < list->getNumBins(); i++) {
+                    vector<string> temp;
+                    string bin = list->get(i);
+                    m->splitAtComma(bin, temp);
+                    for (int j = 0; j < temp.size(); j++) { vector<string> tempFakeOut; tempFakeOut.push_back(temp[j]); nameMap[temp[j]] = tempFakeOut; }
                 }
+                delete list;
+                    
                 int tcount = getTax(subset);
                 if (tcount != subset.size()) { m->mothurOut("[ERROR]: subsampled list file contains " + toString(subset.size()) + " sequences, but I only found " + toString(tcount) + " in your taxonomy file, did you forget a name file? Please correct."); m->mothurOutEndLine(); }
             }else {