]> git.donarmstrong.com Git - mothur.git/commitdiff
adding labels to list file.
authorSarah Westcott <mothur.westcott@gmail.com>
Thu, 17 Oct 2013 18:20:30 +0000 (14:20 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Thu, 17 Oct 2013 18:20:30 +0000 (14:20 -0400)
57 files changed:
Mothur.xcodeproj/project.pbxproj
binsequencecommand.cpp
classifyotucommand.cpp
clustercommand.cpp
clusterdoturcommand.cpp
clustersplitcommand.cpp
collectsharedcommand.cpp
consensusseqscommand.cpp
corraxescommand.cpp
createdatabasecommand.cpp
datavector.hpp
engine.cpp
filtersharedcommand.cpp
getcoremicrobiomecommand.cpp
getgroupscommand.cpp
getlineagecommand.cpp
getlistcountcommand.cpp
getmetacommunitycommand.cpp
getotulabelscommand.cpp
getotuscommand.cpp
getrelabundcommand.cpp
getseqscommand.cpp
getsharedotucommand.cpp
hclustercommand.cpp
heatmap.cpp
indicatorcommand.cpp
kruskalwalliscommand.cpp
lefsecommand.cpp
listotulabelscommand.cpp
listvector.cpp
listvector.hpp
makebiomcommand.cpp
makelefsecommand.cpp
mergegroupscommand.cpp
metastatscommand.cpp
mgclustercommand.cpp
mothurmetastats.cpp
mothurout.h
normalizesharedcommand.cpp
otuassociationcommand.cpp
otuhierarchycommand.cpp
randomforest.cpp
removegroupscommand.cpp
removelineagecommand.cpp
removeotulabelscommand.cpp
removerarecommand.cpp
sharedcommand.cpp
sharedcommand.h
sharedlistvector.cpp
sharedlistvector.h
sharedordervector.cpp
sharedrabundfloatvector.cpp
sharedrabundvector.cpp
sharedsobscollectsummary.cpp
sparcccommand.cpp
subsample.cpp
subsamplecommand.cpp

index 4fb82f5e8acacfb590ac2ac4b44620b70566ad87..a26db6132837d72ef08bce41b1e06d971c321865 100644 (file)
                                "DSTROOT[sdk=*]" = TARGET_BUILD_DIR;
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_MODEL_TUNING = G5;
                                "DSTROOT[sdk=*]" = TARGET_BUILD_DIR;
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 3;
+                               GCC_OPTIMIZATION_LEVEL = 0;
                                "INSTALL_PATH[sdk=*]" = TARGET_BUILD_DIR;
                                PRODUCT_NAME = mothur;
                                SDKROOT = macosx;
                                "INSTALL_PATH[sdk=*]" = TARGET_BUILD_DIR;
                                PRODUCT_NAME = mothur;
                                SDKROOT = macosx;
                                DEPLOYMENT_LOCATION = YES;
                                DSTROOT = TARGET_BUILD_DIR;
                                GCC_MODEL_TUNING = G5;
                                DEPLOYMENT_LOCATION = YES;
                                DSTROOT = TARGET_BUILD_DIR;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 3;
+                               GCC_OPTIMIZATION_LEVEL = 0;
                                GCC_WARN_UNUSED_VALUE = YES;
                                PRODUCT_NAME = mothur;
                                SDKROOT = macosx;
                                GCC_WARN_UNUSED_VALUE = YES;
                                PRODUCT_NAME = mothur;
                                SDKROOT = macosx;
index f9784b3ea91e09d1c0d86232b67b70bc5e789b99..738c3241732c814d01b87052fa3cafd899c74182 100644 (file)
@@ -398,6 +398,7 @@ int BinSeqCommand::process(ListVector* list) {
         m->mothurOut(list->getLabel()); m->mothurOutEndLine();
         
         //for each bin in the list vector
         m->mothurOut(list->getLabel()); m->mothurOutEndLine();
         
         //for each bin in the list vector
+        vector<string> binLabels = list->getLabels();
         for (int i = 0; i < list->size(); i++) {
             
             if (m->control_pressed) {  return 1; }
         for (int i = 0; i < list->size(); i++) {
             
             if (m->control_pressed) {  return 1; }
@@ -421,11 +422,11 @@ int BinSeqCommand::process(ListVector* list) {
                             }
                             if (groups.size() != 0) { groupInfo += groups[groups.size()-1]; }
                             else { groupInfo = "not found";  }
                             }
                             if (groups.size() != 0) { groupInfo += groups[groups.size()-1]; }
                             else { groupInfo = "not found";  }
-                            name = name + "\t" + groupInfo + "\t" + toString(i+1)+ "\tNumRep=" + toString(ct.getNumSeqs(name));
+                            name = name + "\t" + groupInfo + "\t" + binLabels[i] + "\tNumRep=" + toString(ct.getNumSeqs(name));
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }else {
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }else {
-                            name = name + "\t" + toString(i+1) + "\tNumRep=" + toString(ct.getNumSeqs(name));
+                            name = name + "\t" + binLabels[i] + "\tNumRep=" + toString(ct.getNumSeqs(name));
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }
@@ -435,7 +436,7 @@ int BinSeqCommand::process(ListVector* list) {
                     if (sequence != "not found") {
                         //if you don't have groups
                         if (groupfile == "") {
                     if (sequence != "not found") {
                         //if you don't have groups
                         if (groupfile == "") {
-                            name = name + "\t" + toString(i+1);
+                            name = name + "\t" + binLabels[i];
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }else {//if you do have groups
                             out << ">" << name << endl;
                             out << sequence << endl;
                         }else {//if you do have groups
@@ -444,7 +445,7 @@ int BinSeqCommand::process(ListVector* list) {
                                 m->mothurOut(name + " is missing from your group file. Please correct. ");  m->mothurOutEndLine();
                                 return 1;
                             }else{
                                 m->mothurOut(name + " is missing from your group file. Please correct. ");  m->mothurOutEndLine();
                                 return 1;
                             }else{
-                                name = name + "\t" + group + "\t" + toString(i+1);
+                                name = name + "\t" + group + "\t" + binLabels[i];
                                 out << ">" << name << endl;
                                 out << sequence << endl;
                             }
                                 out << ">" << name << endl;
                                 out << sequence << endl;
                             }
index 217bc868eb8984c1111ff50fa84f83abeefa2059..160928f3aa46906900ac5262f198112fb70fda36 100644 (file)
@@ -586,6 +586,7 @@ int ClassifyOtuCommand::process(ListVector* processList) {
         
                //for each bin in the list vector
         string snumBins = toString(processList->getNumBins());
         
                //for each bin in the list vector
         string snumBins = toString(processList->getNumBins());
+        vector<string> binLabels = processList->getLabels();
                for (int i = 0; i < processList->getNumBins(); i++) {
                        
                        if (m->control_pressed) { break; }
                for (int i = 0; i < processList->getNumBins(); i++) {
                        
                        if (m->control_pressed) { break; }
@@ -598,17 +599,8 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                        names = findConsensusTaxonomy(thisNames, size, conTax);
                
                        if (m->control_pressed) { break; }
                        names = findConsensusTaxonomy(thisNames, size, conTax);
                
                        if (m->control_pressed) { break; }
-                       
-                       //output to new names file
-            string binLabel = "Otu";
-            string sbinNumber = toString(i+1);
-            if (sbinNumber.length() < snumBins.length()) { 
-                int diff = snumBins.length() - sbinNumber.length();
-                for (int h = 0; h < diff; h++) { binLabel += "0"; }
-            }
-            binLabel += sbinNumber;
 
 
-                       out << binLabel << '\t' << size << '\t' << conTax << endl;
+                       out << binLabels[i] << '\t' << size << '\t' << conTax << endl;
                        
                        string noConfidenceConTax = conTax;
                        m->removeConfidences(noConfidenceConTax);
                        
                        string noConfidenceConTax = conTax;
                        m->removeConfidences(noConfidenceConTax);
@@ -683,16 +675,8 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                     
                     if (m->control_pressed) { break; }
                     
                     
                     if (m->control_pressed) { break; }
                     
-                    //output to new names file
-                    string binLabel = "Otu";
-                    string sbinNumber = toString(i+1);
-                    if (sbinNumber.length() < snumBins.length()) { 
-                        int diff = snumBins.length() - sbinNumber.length();
-                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                    }
-                    binLabel += sbinNumber;
                     
                     
-                    (*outs[groupIndex[itParsed->first]]) << binLabel << '\t' << size << '\t' << conTax << endl;
+                    (*outs[groupIndex[itParsed->first]]) << binLabels[i] << '\t' << size << '\t' << conTax << endl;
                     
                     string noConfidenceConTax = conTax;
                     m->removeConfidences(noConfidenceConTax);
                     
                     string noConfidenceConTax = conTax;
                     m->removeConfidences(noConfidenceConTax);
index c1ac5bbddd5be05c41e03853c25af4340eab133e..5ac4166c7afa54d2047814bc4b4a18c018786057 100644 (file)
@@ -361,7 +361,7 @@ int ClusterCommand::execute(){
         }
                m->openOutputFile(listFileName, listFile);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
         }
                m->openOutputFile(listFileName, listFile);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
-               
+        list->printHeaders(listFile);
                
                time_t estart = time(NULL);
                float previousDist = 0.00000;
                
                time_t estart = time(NULL);
                float previousDist = 0.00000;
index 96bfc5c523be69bcc75dae33e35a209846aa2302..dadc9cc485dedeec55a1057474f2eab19bf0d4ab 100644 (file)
@@ -259,6 +259,7 @@ int ClusterDoturCommand::execute(){
         }
                m->openOutputFile(listFileName, listFile);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
         }
                m->openOutputFile(listFileName, listFile);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
+        list->printHeaders(listFile);
                
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;
                
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;
index b5dc9692f0f7afefabae27676b9aa61491c048f1..874eb6d7b535e9e400cca8f22593280ecd959b42 100644 (file)
@@ -833,8 +833,10 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> us
                m->openOutputFile(listFileName, outList);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                
                m->openOutputFile(listFileName, outList);
         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                
-               
                map<float, int>::iterator itLabel;
                map<float, int>::iterator itLabel;
+        
+        //clears out junk for autocompleting of list files above.  Perhaps there is a beter way to handle this from within the data structure?
+        m->printedListHeaders = false;
 
                //for each label needed
                for(itLabel = userLabels.begin(); itLabel != userLabels.end(); itLabel++) {
 
                //for each label needed
                for(itLabel = userLabels.begin(); itLabel != userLabels.end(); itLabel++) {
@@ -890,6 +892,8 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> us
                 rabund->print(outRabund);
             }
                        //outList << endl;
                 rabund->print(outRabund);
             }
                        //outList << endl;
+            if (!m->printedListHeaders) { 
+                m->listBinLabelsInFile.clear(); completeList.printHeaders(outList); }
             completeList.print(outList);
                        
                        if (rabund != NULL) { delete rabund; }
             completeList.print(outList);
                        
                        if (rabund != NULL) { delete rabund; }
index dd1ec270334e09f1d316ce060c2ab8c185e0d313..40ee3d255cc03c3a005bc79d77eeee78fb25d510 100644 (file)
@@ -89,7 +89,7 @@ string CollectSharedCommand::getHelpString(){
                helpString += "The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n";
                helpString += "If you use sharedchao and run into memory issues, set all to false. \n";
                helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
                helpString += "The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n";
                helpString += "If you use sharedchao and run into memory issues, set all to false. \n";
                helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n";
+               helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedfile).\n";
                return helpString;
        }
        catch(exception& e) {
                return helpString;
        }
        catch(exception& e) {
index fbec746804bcd7257383e99f26e058dfe4df6f25..d9a5e294c08d1cd3a68c7890b7c0a6ab7fbde04a 100644 (file)
@@ -436,23 +436,16 @@ int ConsensusSeqsCommand::processList(ListVector*& list){
                outSummary << "OTU#\tPositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
                
         string snumBins = toString(list->getNumBins());
                outSummary << "OTU#\tPositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
                
         string snumBins = toString(list->getNumBins());
+        vector<string> binLabels = list->getLabels();
                for (int i = 0; i < list->getNumBins(); i++) {
                        
                        if (m->control_pressed) { outSummary.close(); outName.close(); outFasta.close(); return 0; }
                        
                        string bin = list->get(i);
                        string consSeq = getConsSeq(bin, outSummary, i);
                for (int i = 0; i < list->getNumBins(); i++) {
                        
                        if (m->control_pressed) { outSummary.close(); outName.close(); outFasta.close(); return 0; }
                        
                        string bin = list->get(i);
                        string consSeq = getConsSeq(bin, outSummary, i);
-            
-            string seqName = "Otu";
-            string sbinNumber = toString(i+1);
-            if (sbinNumber.length() < snumBins.length()) {
-                int diff = snumBins.length() - sbinNumber.length();
-                for (int h = 0; h < diff; h++) { seqName += "0"; }
-            }
-            seqName += sbinNumber;
                        
                        
-                       outFasta << ">" << seqName << endl << consSeq << endl;
-                       outName << seqName << '\t' << seqName << "," << bin << endl;
+                       outFasta << ">" << binLabels[i] << endl << consSeq << endl;
+                       outName << binLabels[i] << '\t' << binLabels[i] << "," << bin << endl;
                }
                
                outSummary.close(); outName.close(); outFasta.close();
                }
                
                outSummary.close(); outName.close(); outFasta.close();
index 853c174ac63012c2ebf8d21800c4886138f8ab16..72fa03b75edc196aafcaaa4b6ade6f95d1106d48 100644 (file)
@@ -339,7 +339,7 @@ int CorrAxesCommand::calcPearson(map<string, vector<float> >& axes, ofstream& ou
           //for each otu
           for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                   
           //for each otu
           for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                   
-                  if (metadatafile == "") {  out << m->currentBinLabels[i];    }
+                  if (metadatafile == "") {  out << m->currentSharedBinLabels[i];      }
                   else {  out << metadataLabels[i];            }
                                   
                   //find the averages this otu - Y
                   else {  out << metadataLabels[i];            }
                                   
                   //find the averages this otu - Y
@@ -474,7 +474,7 @@ int CorrAxesCommand::calcSpearman(map<string, vector<float> >& axes, ofstream& o
                //for each otu
                for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                        
                //for each otu
                for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                        
-                       if (metadatafile == "") {  out << m->currentBinLabels[i];       }
+                       if (metadatafile == "") {  out << m->currentSharedBinLabels[i]; }
                        else {  out << metadataLabels[i];               }
                        
                        //find the ranks of this otu - Y
                        else {  out << metadataLabels[i];               }
                        
                        //find the ranks of this otu - Y
@@ -627,7 +627,7 @@ int CorrAxesCommand::calcKendall(map<string, vector<float> >& axes, ofstream& ou
                //for each otu
                for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                
                //for each otu
                for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
                
-                       if (metadatafile == "") {  out << m->currentBinLabels[i];       }
+                       if (metadatafile == "") {  out << m->currentSharedBinLabels[i]; }
                        else {  out << metadataLabels[i];               }
                        
                        //find the ranks of this otu - Y
                        else {  out << metadataLabels[i];               }
                        
                        //find the ranks of this otu - Y
@@ -834,7 +834,7 @@ int CorrAxesCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>& thisloo
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                newBinLabels.push_back(binLabel);
                        }
                                
                                newBinLabels.push_back(binLabel);
                        }
@@ -843,7 +843,7 @@ int CorrAxesCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>& thisloo
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
+               m->currentSharedBinLabels = newBinLabels;
                
                return 0;
                
                
                return 0;
                
index 235682bfec8fdfc36c43ed25fb78ffd06eef1b4f..a3531661d47c5cc640b822d5ba176a0f50a61844 100644 (file)
@@ -364,11 +364,15 @@ int CreateDatabaseCommand::execute(){
             header += "repSeqName\trepSeq\tOTUConTaxonomy";
             out << header << endl;
             
             header += "repSeqName\trepSeq\tOTUConTaxonomy";
             out << header << endl;
             
+            vector<string> binLabels = list->getLabels();
             for (int i = 0; i < list->getNumBins(); i++) {
                 
             for (int i = 0; i < list->getNumBins(); i++) {
                 
+                int index = findIndex(otuLabels, binLabels[i]);
+                if (index == -1) {  m->mothurOut("[ERROR]: " + binLabels[i] + " is not in your constaxonomy file, aborting.\n"); m->control_pressed = true; }
+                
                 if (m->control_pressed) { break; }
                 
                 if (m->control_pressed) { break; }
                 
-                out << otuLabels[i] << '\t';
+                out << otuLabels[index] << '\t';
                 
                 vector<string> binNames;
                 string bin = list->get(i);
                 
                 vector<string> binNames;
                 string bin = list->get(i);
@@ -387,12 +391,12 @@ int CreateDatabaseCommand::execute(){
                     map<string, string>::iterator it = repNames.find(bin);
                     
                     if (it == repNames.end()) {
                     map<string, string>::iterator it = repNames.find(bin);
                     
                     if (it == repNames.end()) {
-                        m->mothurOut("[ERROR: OTU " + otuLabels[i] + " is not in the repnames file. Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
+                        m->mothurOut("[ERROR: OTU " + otuLabels[index] + " is not in the repnames file. Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
                     }else { seqRepName = it->second;  numSeqsRep = binNames.size(); }
                     
                     //sanity check
                     }else { seqRepName = it->second;  numSeqsRep = binNames.size(); }
                     
                     //sanity check
-                    if (binNames.size() != classifyOtuSizes[i]) {
-                        m->mothurOut("[ERROR: OTU " + otuLabels[i] + " contains " + toString(binNames.size()) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[i]) + ". Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
+                    if (binNames.size() != classifyOtuSizes[index]) {
+                        m->mothurOut("[ERROR: OTU " + otuLabels[index] + " contains " + toString(binNames.size()) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[index]) + ". Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
                     }
                 }else {
                     //find rep sequence in bin
                     }
                 }else {
                     //find rep sequence in bin
@@ -406,11 +410,11 @@ int CreateDatabaseCommand::execute(){
                     }
                     
                     if (seqRepName == "") {
                     }
                     
                     if (seqRepName == "") {
-                        m->mothurOut("[ERROR: OTU " + otuLabels[i] + " is not in the count file. Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
+                        m->mothurOut("[ERROR: OTU " + otuLabels[index] + " is not in the count file. Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
                     }
                     
                     if (numSeqsRep != classifyOtuSizes[i]) {
                     }
                     
                     if (numSeqsRep != classifyOtuSizes[i]) {
-                        m->mothurOut("[ERROR: OTU " + otuLabels[i] + " contains " + toString(numSeqsRep) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[i]) + ". Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
+                        m->mothurOut("[ERROR: OTU " + otuLabels[index] + " contains " + toString(numSeqsRep) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[index]) + ". Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
                     }
                 }
                 
                     }
                 }
                 
@@ -443,7 +447,7 @@ int CreateDatabaseCommand::execute(){
                 }else { out << numSeqsRep << '\t'; }
                 
                 //output repSeq
                 }else { out << numSeqsRep << '\t'; }
                 
                 //output repSeq
-                out << seqRepName << '\t' << seqs[i].getAligned() << '\t' << taxonomies[i] << endl;
+                out << seqRepName << '\t' << seqs[index].getAligned() << '\t' << taxonomies[index] << endl;
             }
             
             
             }
             
             
@@ -462,8 +466,8 @@ int CreateDatabaseCommand::execute(){
                 
                 if (m->control_pressed) { break; }
                 
                 
                 if (m->control_pressed) { break; }
                 
-                int index = findIndex(otuLabels, m->currentBinLabels[h]);
-                if (index == -1) {  m->mothurOut("[ERROR]: " + m->currentBinLabels[h] + " is not in your constaxonomy file, aborting.\n"); m->control_pressed = true; }
+                int index = findIndex(otuLabels, m->currentSharedBinLabels[h]);
+                if (index == -1) {  m->mothurOut("[ERROR]: " + m->currentSharedBinLabels[h] + " is not in your constaxonomy file, aborting.\n"); m->control_pressed = true; }
                 
                 if (m->control_pressed) { break; }
                 
                 
                 if (m->control_pressed) { break; }
                 
@@ -478,7 +482,7 @@ int CreateDatabaseCommand::execute(){
                 
                 //sanity check
                 if (totalAbund != classifyOtuSizes[index]) {
                 
                 //sanity check
                 if (totalAbund != classifyOtuSizes[index]) {
-                    m->mothurOut("[WARNING]: OTU " + m->currentBinLabels[h] + " contains " + toString(totalAbund) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[index]) + ". Make sure you are using files for the same distance.\n"); //m->control_pressed = true;   break;
+                    m->mothurOut("[WARNING]: OTU " + m->currentSharedBinLabels[h] + " contains " + toString(totalAbund) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[index]) + ". Make sure you are using files for the same distance.\n"); //m->control_pressed = true;   break;
                 }
                 
                 //output repSeq
                 }
                 
                 //output repSeq
index e6c839d4772d0586457a9913df2d9e889db60e00..dfcd684eaaec9e725ddf6e860b9d22ec4c4a90c5 100644 (file)
@@ -23,10 +23,10 @@ class DataVector {
        
 public:
        DataVector(){ m = MothurOut::getInstance(); }// : maxRank(0), numBins(0), numSeqs(0){};
        
 public:
        DataVector(){ m = MothurOut::getInstance(); }// : maxRank(0), numBins(0), numSeqs(0){};
-       DataVector(string l) : label(l) {};
-       DataVector(const DataVector& dv) : label(dv.label){};//, maxRank(dv.maxRank), numBins(dv.numBins), numSeqs(dv.numSeqs) {};
-       DataVector(ifstream&);
-       DataVector(ifstream&, GroupMap*);
+       DataVector(string l) : label(l) { m = MothurOut::getInstance();};
+       DataVector(const DataVector& dv) : label(dv.label){ m = MothurOut::getInstance();};//, maxRank(dv.maxRank), numBins(dv.numBins), numSeqs(dv.numSeqs) {};
+       DataVector(ifstream&) {m = MothurOut::getInstance();}
+       DataVector(ifstream&, GroupMap*){m = MothurOut::getInstance();}
        virtual ~DataVector(){};
        
 //     virtual int getNumBins()        {       return numBins;         }
        virtual ~DataVector(){};
        
 //     virtual int getNumBins()        {       return numBins;         }
index e4e107168c5723c82b90a7f103ccb8d9ee83cb60..d6be4e4f1a16e00af29cfe36052c98e3a6e98efb 100644 (file)
@@ -123,10 +123,12 @@ bool InteractEngine::getInput(){
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
-                                       mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
+                    mout->commandInputsConvertError = false;
+                                       mout->printedSharedHeaders = false;
+                                       mout->currentSharedBinLabels.clear();
+                                       mout->sharedBinLabelsInFile.clear();
+                    mout->printedListHeaders = false;
+                    mout->listBinLabelsInFile.clear();
                                                        
                                        Command* command = cFactory->getCommand(commandName, options);
                                        if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
                                                        
                                        Command* command = cFactory->getCommand(commandName, options);
                                        if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
@@ -309,10 +311,12 @@ bool BatchEngine::getInput(){
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
                                        mout->commandInputsConvertError = false;
                                        mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
+                    mout->printedSharedHeaders = false;
+                    mout->currentSharedBinLabels.clear();
+                    mout->sharedBinLabelsInFile.clear();
+                    mout->printedListHeaders = false;
+                    mout->listBinLabelsInFile.clear();
 
                                                        
                                        Command* command = cFactory->getCommand(commandName, options);
 
                                                        
                                        Command* command = cFactory->getCommand(commandName, options);
@@ -480,10 +484,12 @@ bool ScriptEngine::getInput(){
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
                                        mout->clearAllGroups();
                                        mout->Treenames.clear();
                                        mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
-                                       mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
+                    mout->commandInputsConvertError = false;
+                    mout->printedSharedHeaders = false;
+                    mout->currentSharedBinLabels.clear();
+                    mout->sharedBinLabelsInFile.clear();
+                    mout->printedListHeaders = false;
+                    mout->listBinLabelsInFile.clear();
 
                                        Command* command = cFactory->getCommand(commandName, options);
                                        if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
 
                                        Command* command = cFactory->getCommand(commandName, options);
                                        if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
index 5b5fcb1a5ed36578ebb70b3e8f3ac1048ec1ad4f..a2510a697737c5596a47cf5a0f36a950959c2b04 100644 (file)
@@ -325,7 +325,7 @@ int FilterSharedCommand::processShared(vector<SharedRAbundVector*>& thislookup)
        try {
                
                //save mothurOut's binLabels to restore for next label
        try {
                
                //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
+               vector<string> saveBinLabels = m->currentSharedBinLabels;
                
         map<string, string> variables; 
         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
                
         map<string, string> variables; 
         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
@@ -474,7 +474,7 @@ int FilterSharedCommand::processShared(vector<SharedRAbundVector*>& thislookup)
                m->openOutputFile(outputFileName, out);
                outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
                
                m->openOutputFile(outputFileName, out);
                outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
                
-        m->currentBinLabels = filteredLabels;
+        m->currentSharedBinLabels = filteredLabels;
         
                filteredLookup[0]->printHeaders(out);
                
         
                filteredLookup[0]->printHeaders(out);
                
@@ -486,7 +486,7 @@ int FilterSharedCommand::processShared(vector<SharedRAbundVector*>& thislookup)
         
         
         //save mothurOut's binLabels to restore for next label
         
         
         //save mothurOut's binLabels to restore for next label
-               m->currentBinLabels = saveBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
         
         for (int j = 0; j < filteredLookup.size(); j++) { delete filteredLookup[j]; }
                
         
         for (int j = 0; j < filteredLookup.size(); j++) { delete filteredLookup[j]; }
                
index 5fbb78131ed3ceda425516bdcd2766f3c1eb196f..2a81aceaec825d29de3a2373d461466fb28aa93c 100644 (file)
@@ -352,14 +352,14 @@ int GetCoreMicroBiomeCommand::createTable(vector<SharedRAbundFloatVector*>& look
                 for (int k = 0; k < counts[j]; k++) { table[j][k]++; }
                 
                 if ((abund == -1) && (samples != -1)) { //we want all OTUs with this number of samples
                 for (int k = 0; k < counts[j]; k++) { table[j][k]++; }
                 
                 if ((abund == -1) && (samples != -1)) { //we want all OTUs with this number of samples
-                    if (counts[j] >= samples) { otuNames[j].push_back(m->currentBinLabels[i]); }
+                    if (counts[j] >= samples) { otuNames[j].push_back(m->currentSharedBinLabels[i]); }
                 }else if ((abund != -1) && (samples == -1)) { //we want all OTUs with this relabund
                     if (j == abund) {  
                 }else if ((abund != -1) && (samples == -1)) { //we want all OTUs with this relabund
                     if (j == abund) {  
-                        for (int k = 0; k < counts[j]; k++) {  otuNames[k+1].push_back(m->currentBinLabels[i]); }
+                        for (int k = 0; k < counts[j]; k++) {  otuNames[k+1].push_back(m->currentSharedBinLabels[i]); }
                     }
                 }else if ((abund != -1) && (samples != -1)) { //we want only OTUs with this relabund for this number of samples
                     if ((j == abund) && (counts[j] >= samples)) {  
                     }
                 }else if ((abund != -1) && (samples != -1)) { //we want only OTUs with this relabund for this number of samples
                     if ((j == abund) && (counts[j] >= samples)) {  
-                        otuNames[j].push_back(m->currentBinLabels[i]); 
+                        otuNames[j].push_back(m->currentSharedBinLabels[i]); 
                     }
                 }
             }
                     }
                 }
             }
index 15dcbba802d5e850fccbb7bb71b05dba6af38b74..bb15a3f5a21e3c7785283cfc5d6eade2c1bda6ed 100644 (file)
@@ -68,7 +68,7 @@ string GetGroupsCommand::getOutputPattern(string type) {
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
-        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],[tag],pick,[extension]";    }
         else if (type == "shared")      {   pattern = "[filename],[tag],pick,[extension]";    }
         else if (type == "design")      {   pattern = "[filename],pick,[extension]";    }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         else if (type == "shared")      {   pattern = "[filename],[tag],pick,[extension]";    }
         else if (type == "design")      {   pattern = "[filename],pick,[extension]";    }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
@@ -585,10 +585,6 @@ int GetGroupsCommand::readList(){
         map<string, string> variables; 
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
         map<string, string> variables; 
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
-               string outputFileName = getOutputFileName("list", variables);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
                
                ifstream in;
                m->openInputFile(listfile, in);
                
                ifstream in;
                m->openInputFile(listfile, in);
@@ -599,9 +595,19 @@ int GetGroupsCommand::readList(){
                while(!in.eof()){
                        
                        selectedCount = 0;
                while(!in.eof()){
                        
                        selectedCount = 0;
-                       
+
                        //read in list vector
                        ListVector list(in);
                        //read in list vector
                        ListVector list(in);
+            
+            variables["[tag]"] = list.getLabel();
+            string outputFileName = getOutputFileName("list", variables);
+                       
+                       ofstream out;
+                       m->openOutputFile(outputFileName, out);
+                       outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
+            
+            vector<string> binLabels = list.getLabels();
+            vector<string> newBinLabels;
                        
                        //make a new list vector
                        ListVector newList;
                        
                        //make a new list vector
                        ListVector newList;
@@ -613,13 +619,14 @@ int GetGroupsCommand::readList(){
                                
                                //parse out names that are in accnos file
                                string binnames = list.get(i);
                                
                                //parse out names that are in accnos file
                                string binnames = list.get(i);
+                vector<string> thisBinNames;
+                m->splitAtComma(binnames, thisBinNames);
                                
                                string newNames = "";
                                
                                string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
+                for (int j = 0; j < thisBinNames.size(); j++) {
+                    string name = thisBinNames[j];
+                    
+                    //if that name is in the .accnos file, add it
                                        if (names.count(name) != 0) {  newNames += name + ",";  selectedCount++;  }
                                        else{
                                                //if you are not in the accnos file check if you are a name that needs to be changed
                                        if (names.count(name) != 0) {  newNames += name + ",";  selectedCount++;  }
                                        else{
                                                //if you are not in the accnos file check if you are a name that needs to be changed
@@ -629,39 +636,30 @@ int GetGroupsCommand::readList(){
                                                        selectedCount++;
                                                }
                                        }
                                                        selectedCount++;
                                                }
                                        }
-                               }
-                               
-                               //get last name
-                               if (names.count(binnames) != 0) {  newNames += binnames + ",";  selectedCount++;  }
-                               else{
-                                       //if you are not in the accnos file check if you are a name that needs to be changed
-                                       map<string, string>::iterator it = uniqueToRedundant.find(binnames);
-                                       if (it != uniqueToRedundant.end()) {
-                                               newNames += it->second + ",";
-                                               selectedCount++;
-                                       }
-                               }
-                               
+                }
+                                                               
                                //if there are names in this bin add to new list
                                if (newNames != "") {  
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
                                //if there are names in this bin add to new list
                                if (newNames != "") {  
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
+                                       newList.push_back(newNames);
+                    newBinLabels.push_back(binLabels[i]);
                                }
                        }
                        
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
                                }
                        }
                        
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
+                newList.setLabels(newBinLabels);
+                newList.printHeaders(out);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
+            out.close();
                }
                }
-               in.close();     
-               out.close();
+               in.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
                
                if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
                
                
                m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
                
index 862aef7a0da6dde200bc387209bdd73d730015f5..ec5ef61233d7cfa24ef1b9b9d7debf355a5820ba 100644 (file)
@@ -75,7 +75,7 @@ string GetLineageCommand::getOutputPattern(string type) {
         else if (type == "name")            {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")           {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")           {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")            {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")           {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")           {   pattern = "[filename],pick,[extension]";    }
-        else if (type == "list")            {   pattern = "[filename],pick,[extension]-[filename],[distance],pick,[extension]";    }
+        else if (type == "list")            {   pattern = "[filename],[distance],pick,[extension]";    }
         else if (type == "shared")          {   pattern = "[filename],[distance],pick,[extension]";    }
         else if (type == "alignreport")     {   pattern = "[filename],pick.align.report";    }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         else if (type == "shared")          {   pattern = "[filename],[distance],pick,[extension]";    }
         else if (type == "alignreport")     {   pattern = "[filename],pick.align.report";    }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
@@ -537,18 +537,13 @@ int GetLineageCommand::readList(){
                map<string, string> variables; 
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
                map<string, string> variables; 
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
-               string outputFileName = getOutputFileName("list", variables);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
+                               
                ifstream in;
                m->openInputFile(listfile, in);
                
                bool wroteSomething = false;
                
                while(!in.eof()){
                ifstream in;
                m->openInputFile(listfile, in);
                
                bool wroteSomething = false;
                
                while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
 
                        //read in list vector
                        ListVector list(in);
 
                        //read in list vector
                        ListVector list(in);
@@ -556,6 +551,18 @@ int GetLineageCommand::readList(){
                        //make a new list vector
                        ListVector newList;
                        newList.setLabel(list.getLabel());
                        //make a new list vector
                        ListVector newList;
                        newList.setLabel(list.getLabel());
+            
+            variables["[distance]"] = list.getLabel();
+            string outputFileName = getOutputFileName("list", variables);
+                       
+                       ofstream out;
+                       m->openOutputFile(outputFileName, out);
+                       outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
+            
+            if (m->control_pressed) { in.close(); out.close(); return 0; }
+            
+            vector<string> binLabels = list.getLabels();
+            vector<string> newBinLabels;
                        
                        //for each bin
                        for (int i = 0; i < list.getNumBins(); i++) {
                        
                        //for each bin
                        for (int i = 0; i < list.getNumBins(); i++) {
@@ -576,23 +583,26 @@ int GetLineageCommand::readList(){
                                //if there are names in this bin add to new list
                                if (newNames != "") { 
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
                                //if there are names in this bin add to new list
                                if (newNames != "") { 
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
+                                       newList.push_back(newNames);
+                    newBinLabels.push_back(binLabels[i]);
                                }
                        }
                                
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
                                }
                        }
                                
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
+                               newList.setLabels(newBinLabels);
+                newList.printHeaders(out);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
+            out.close();
                }
                in.close();     
                }
                in.close();     
-               out.close();
+               
                
                if (wroteSomething == false) { m->mothurOut("Your file contains does not contain any sequences from " + taxons + "."); m->mothurOutEndLine();  }
                
                if (wroteSomething == false) { m->mothurOut("Your file contains does not contain any sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
                
                return 0;
 
                
                return 0;
 
@@ -615,6 +625,8 @@ int GetLineageCommand::readConsList(){
         bool wroteSomething = false;
         string snumBins = toString(list->getNumBins());
         
         bool wroteSomething = false;
         string snumBins = toString(list->getNumBins());
         
+        vector<string> binLabels = list->getLabels();
+        vector<string> newBinLabels;
         for (int i = 0; i < list->getNumBins(); i++) {
             
             if (m->control_pressed) { delete list; return 0;}
         for (int i = 0; i < list->getNumBins(); i++) {
             
             if (m->control_pressed) { delete list; return 0;}
@@ -631,6 +643,7 @@ int GetLineageCommand::readConsList(){
             if (names.count(m->getSimpleLabel(otuLabel)) != 0) {
                                selectedCount++;
                 newList.push_back(list->get(i));
             if (names.count(m->getSimpleLabel(otuLabel)) != 0) {
                                selectedCount++;
                 newList.push_back(list->get(i));
+                newBinLabels.push_back(binLabels[i]);
             }
         }
         
             }
         }
         
@@ -648,6 +661,8 @@ int GetLineageCommand::readConsList(){
         //print new listvector
         if (newList.getNumBins() != 0) {
             wroteSomething = true;
         //print new listvector
         if (newList.getNumBins() != 0) {
             wroteSomething = true;
+            newList.setLabels(newBinLabels);
+            newList.printHeaders(out);
             newList.print(out);
         }
                out.close();
             newList.print(out);
         }
                out.close();
@@ -767,9 +782,9 @@ int GetLineageCommand::readShared(){
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
-            if (names.count(m->getSimpleLabel(m->currentBinLabels[i])) != 0) {
+            if (names.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) != 0) {
                 numSelected++; wroteSomething = true;
                 numSelected++; wroteSomething = true;
-                newLabels.push_back(m->currentBinLabels[i]);
+                newLabels.push_back(m->currentSharedBinLabels[i]);
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
@@ -789,7 +804,7 @@ int GetLineageCommand::readShared(){
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
-        m->currentBinLabels = newLabels;
+        m->currentSharedBinLabels = newLabels;
         
                newLookup[0]->printHeaders(out);
                
         
                newLookup[0]->printHeaders(out);
                
index a4d7b83397f83bf6ae3dd21627566252035b328f..2f194a8068555fb9f962e725bd9eec977d2fa174 100644 (file)
@@ -260,19 +260,20 @@ void GetListCountCommand::process(ListVector* list) {
                m->mothurOut(list->getLabel()); m->mothurOutEndLine();
                
                //for each bin in the list vector
                m->mothurOut(list->getLabel()); m->mothurOutEndLine();
                
                //for each bin in the list vector
+        vector<string> binLabels = list->getLabels();
                for (int i = 0; i < list->getNumBins(); i++) {
                        if (m->control_pressed) { break; }
                        
                        binnames = list->get(i);
                        
                        if (sort == "otu") {
                for (int i = 0; i < list->getNumBins(); i++) {
                        if (m->control_pressed) { break; }
                        
                        binnames = list->get(i);
                        
                        if (sort == "otu") {
-                               out << i+1 << '\t' << binnames << endl;
+                               out << binLabels[i] << '\t' << binnames << endl;
                        }else{ //sort = name
                                vector<string> names;
                                m->splitAtComma(binnames, names);
                                
                                for (int j = 0; j < names.size(); j++) {
                        }else{ //sort = name
                                vector<string> names;
                                m->splitAtComma(binnames, names);
                                
                                for (int j = 0; j < names.size(); j++) {
-                                       out << names[j] << '\t' << i+1 << endl;
+                                       out << names[j] << '\t' << binLabels[i] << endl;
                                }
                        }
                }
                                }
                        }
                }
index 8f78ca2a45fce56f6ef8996c880b48677ae32357..08cd35a9470406ba0d4827b7e3b10a94f7de94ad 100644 (file)
@@ -577,7 +577,7 @@ int GetMetaCommunityCommand::processDriver(vector<SharedRAbundVector*>& thislook
             outputNames.push_back(matrixName); outputTypes["matrix"].push_back(matrixName);
             
             findQ.printZMatrix(matrixName, thisGroups);
             outputNames.push_back(matrixName); outputTypes["matrix"].push_back(matrixName);
             
             findQ.printZMatrix(matrixName, thisGroups);
-            findQ.printRelAbund(relabund, m->currentBinLabels);
+            findQ.printRelAbund(relabund, m->currentSharedBinLabels);
             
             if(optimizegap != -1 && (numPartitions - minPartition) >= optimizegap && numPartitions >= minpartitions){
                 string tempDoneFile = m->getRootName(m->getSimpleName(sharedfile)) + toString(processID) + ".done.temp";
             
             if(optimizegap != -1 && (numPartitions - minPartition) >= optimizegap && numPartitions >= minpartitions){
                 string tempDoneFile = m->getRootName(m->getSimpleName(sharedfile)) + toString(processID) + ".done.temp";
index 00297e2d8049be362a991589446544b6c1cf99fc..452d7f605cdf489e03196ab2237dc187f63fa26c 100644 (file)
@@ -465,9 +465,9 @@ int GetOtuLabelsCommand::readShared(){
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
-            if (labels.count(m->getSimpleLabel(m->currentBinLabels[i])) != 0) {
+            if (labels.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) != 0) {
                 numSelected++; wroteSomething = true;
                 numSelected++; wroteSomething = true;
-                newLabels.push_back(m->currentBinLabels[i]);
+                newLabels.push_back(m->currentSharedBinLabels[i]);
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
@@ -487,7 +487,7 @@ int GetOtuLabelsCommand::readShared(){
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
-        m->currentBinLabels = newLabels;
+        m->currentSharedBinLabels = newLabels;
         
                newLookup[0]->printHeaders(out);
                
         
                newLookup[0]->printHeaders(out);
                
@@ -523,22 +523,16 @@ int GetOtuLabelsCommand::readList(){
         bool wroteSomething = false;
         string snumBins = toString(list->getNumBins());
         
         bool wroteSomething = false;
         string snumBins = toString(list->getNumBins());
         
+        vector<string> binLabels = list->getLabels();
+        vector<string> newLabels;
         for (int i = 0; i < list->getNumBins(); i++) {
             
             if (m->control_pressed) { delete list; return 0;}
             
         for (int i = 0; i < list->getNumBins(); i++) {
             
             if (m->control_pressed) { delete list; return 0;}
             
-            //create a label for this otu
-            string otuLabel = "Otu";
-            string sbinNumber = toString(i+1);
-            if (sbinNumber.length() < snumBins.length()) { 
-                int diff = snumBins.length() - sbinNumber.length();
-                for (int h = 0; h < diff; h++) { otuLabel += "0"; }
-            }
-            otuLabel += sbinNumber; 
-            
-            if (labels.count(m->getSimpleLabel(otuLabel)) != 0) {
+            if (labels.count(m->getSimpleLabel(binLabels[i])) != 0) {
                                selectedCount++;
                 newList.push_back(list->get(i));
                                selectedCount++;
                 newList.push_back(list->get(i));
+                newLabels.push_back(binLabels[i]);
             }
         }
         
             }
         }
         
@@ -556,6 +550,8 @@ int GetOtuLabelsCommand::readList(){
         //print new listvector
         if (newList.getNumBins() != 0) {
             wroteSomething = true;
         //print new listvector
         if (newList.getNumBins() != 0) {
             wroteSomething = true;
+            newList.setLabels(newLabels);
+            newList.printHeaders(out);
             newList.print(out);
         }
                out.close();
             newList.print(out);
         }
                out.close();
index 335ebc4506ca99ac3a0e3dc9a2d068b0f1c41cd7..3ca7f5d575db0a7e3a065ebcf371128698d5056b 100644 (file)
@@ -244,9 +244,16 @@ int GetOtusCommand::execute(){
 //**********************************************************************************************************************
 int GetOtusCommand::readListGroup(){
        try {
 //**********************************************************************************************************************
 int GetOtusCommand::readListGroup(){
        try {
-               string thisOutputDir = outputDir;
+               InputData* input = new InputData(listfile, "list");
+               ListVector* list = input->getListVector();
+               string lastLabel = list->getLabel();
+               
+               //using first label seen if none is provided
+               if (label == "") { label = lastLabel; }
+        
+        string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-        map<string, string> variables; 
+        map<string, string> variables;
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[tag]"] = label;
         variables["[extension]"] = m->getExtension(listfile);
         variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[tag]"] = label;
         variables["[extension]"] = m->getExtension(listfile);
@@ -254,8 +261,8 @@ int GetOtusCommand::readListGroup(){
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
-               
-               string GroupOutputDir = outputDir;
+        
+        string GroupOutputDir = outputDir;
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
         variables["[filename]"] = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile));
         variables["[extension]"] = m->getExtension(groupfile);
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
         variables["[filename]"] = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile));
         variables["[extension]"] = m->getExtension(groupfile);
@@ -263,13 +270,7 @@ int GetOtusCommand::readListGroup(){
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
-                       
-               InputData* input = new InputData(listfile, "list");
-               ListVector* list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               //using first label seen if none is provided
-               if (label == "") { label = lastLabel; }
+
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                set<string> labels; labels.insert(label);
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                set<string> labels; labels.insert(label);
@@ -366,6 +367,8 @@ int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream
                
                int numOtus = 0;
                //for each bin
                
                int numOtus = 0;
                //for each bin
+        vector<string> binLabels = list->getLabels();
+        vector<string> newBinLabels;
                for (int i = 0; i < list->getNumBins(); i++) {
                        if (m->control_pressed) { return 0; }
                        
                for (int i = 0; i < list->getNumBins(); i++) {
                        if (m->control_pressed) { return 0; }
                        
@@ -399,7 +402,8 @@ int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream
                        
                        //if there are sequences from the groups we want in this bin add to new list, output to groupfile
                        if (keepBin) {  
                        
                        //if there are sequences from the groups we want in this bin add to new list, output to groupfile
                        if (keepBin) {  
-                               newList.push_back(binnames);    
+                               newList.push_back(binnames);
+                newBinLabels.push_back(binLabels[i]);
                                outGroup << groupFileOutput;
                                numOtus++;
                        }
                                outGroup << groupFileOutput;
                                numOtus++;
                        }
@@ -408,7 +412,9 @@ int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream
                //print new listvector
                if (newList.getNumBins() != 0) {
                        wroteSomething = true;
                //print new listvector
                if (newList.getNumBins() != 0) {
                        wroteSomething = true;
-                       newList.print(out);
+                       newList.setLabels(newBinLabels);
+            newList.printHeaders(out);
+            newList.print(out);
                }
                
                m->mothurOut(newList.getLabel() + " - selected " + toString(numOtus) + " of the " + toString(list->getNumBins()) + " OTUs."); m->mothurOutEndLine();
                }
                
                m->mothurOut(newList.getLabel() + " - selected " + toString(numOtus) + " of the " + toString(list->getNumBins()) + " OTUs."); m->mothurOutEndLine();
index f36f1ba23a6af6c9110dc0aac103054ceefedaff..791f5631a680fe17968eeec63762388c288ba162 100644 (file)
@@ -192,7 +192,7 @@ int GetRelAbundCommand::execute(){
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                               if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                                getRelAbundance(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
                                getRelAbundance(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -205,7 +205,7 @@ int GetRelAbundCommand::execute(){
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
                                lookup = input->getSharedRAbundVectors(lastLabel);
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
                                lookup = input->getSharedRAbundVectors(lastLabel);
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                               if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                                getRelAbundance(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
                                getRelAbundance(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -246,7 +246,7 @@ int GetRelAbundCommand::execute(){
                        lookup = input->getSharedRAbundVectors(lastLabel);
                        
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        lookup = input->getSharedRAbundVectors(lastLabel);
                        
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                       if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                        getRelAbundance(lookup, out);
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                        getRelAbundance(lookup, out);
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
index 82f9710e6e40cb84b8fee9f285fca71b3fe0099c..7f0f3ddb51da8496c292367b5dfc728b3915d53f 100644 (file)
@@ -88,7 +88,7 @@ string GetSeqsCommand::getOutputPattern(string type) {
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
-        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],[distance],pick,[extension]";    }
         else if (type == "qfile")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "accnosreport")      {   pattern = "[filename],pick.accnos.report";    }
         else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
         else if (type == "qfile")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "accnosreport")      {   pattern = "[filename],pick.accnos.report";    }
         else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
@@ -614,9 +614,6 @@ int GetSeqsCommand::readList(){
         map<string, string> variables; 
                variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
         map<string, string> variables; 
                variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
         variables["[extension]"] = m->getExtension(listfile);
-               string outputFileName = getOutputFileName("list", variables);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
                
                ifstream in;
                m->openInputFile(listfile, in);
                
                ifstream in;
                m->openInputFile(listfile, in);
@@ -629,8 +626,6 @@ int GetSeqsCommand::readList(){
                while(!in.eof()){
                        
                        selectedCount = 0;
                while(!in.eof()){
                        
                        selectedCount = 0;
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
 
                        //read in list vector
                        ListVector list(in);
 
                        //read in list vector
                        ListVector list(in);
@@ -638,6 +633,18 @@ int GetSeqsCommand::readList(){
                        //make a new list vector
                        ListVector newList;
                        newList.setLabel(list.getLabel());
                        //make a new list vector
                        ListVector newList;
                        newList.setLabel(list.getLabel());
+            
+            variables["[distance]"] = list.getLabel();
+            string outputFileName = getOutputFileName("list", variables);
+                       
+                       ofstream out;
+                       m->openOutputFile(outputFileName, out);
+                       outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
+            
+            vector<string> binLabels = list.getLabels();
+            vector<string> newBinLabels;
+            
+            if (m->control_pressed) { in.close(); out.close();  return 0; }
                        
                        //for each bin
                        for (int i = 0; i < list.getNumBins(); i++) {
                        
                        //for each bin
                        for (int i = 0; i < list.getNumBins(); i++) {
@@ -657,23 +664,26 @@ int GetSeqsCommand::readList(){
                                //if there are names in this bin add to new list
                                if (newNames != "") { 
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
                                //if there are names in this bin add to new list
                                if (newNames != "") { 
                                        newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
+                                       newList.push_back(newNames);
+                    newBinLabels.push_back(binLabels[i]);
                                }
                        }
                                
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
                                }
                        }
                                
                        //print new listvector
                        if (newList.getNumBins() != 0) {
                                wroteSomething = true;
+                               newList.setLabels(newBinLabels);
+                newList.printHeaders(out);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
                                newList.print(out);
                        }
                        
                        m->gobble(in);
+            out.close();
                }
                in.close();     
                }
                in.close();     
-               out.close();
+               
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
                
                m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
                
                
                m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
                
index 1074d323e9aaeae08b69a2d546fdb8cae544d330..9302d1d21dfc52dbe295754e38aa86de55e0a4cc 100644 (file)
@@ -431,6 +431,7 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                int num = 0;
                                
                //go through each bin, find out if shared
                int num = 0;
                                
                //go through each bin, find out if shared
+        vector<string> binLabels = shared->getLabels();
                for (int i = 0; i < shared->getNumBins(); i++) {
                        if (m->control_pressed) { outNames.close(); m->mothurRemove(outputFileNames); return 0; }
                        
                for (int i = 0; i < shared->getNumBins(); i++) {
                        if (m->control_pressed) { outNames.close(); m->mothurRemove(outputFileNames); return 0; }
                        
@@ -452,7 +453,7 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                                //find group
                                string seqGroup = groupMap->getGroup(name);
                                if (output != "accnos") {
                                //find group
                                string seqGroup = groupMap->getGroup(name);
                                if (output != "accnos") {
-                                       namesOfSeqsInThisBin.push_back((name + "|" + seqGroup + "|" + toString(i+1)));
+                                       namesOfSeqsInThisBin.push_back((name + "|" + seqGroup + "|" + binLabels[i]));
                                }else {  namesOfSeqsInThisBin.push_back(name);  }
                                
                                if (seqGroup == "not found") { m->mothurOut(name + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1);  }
                                }else {  namesOfSeqsInThisBin.push_back(name);  }
                                
                                if (seqGroup == "not found") { m->mothurOut(name + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1);  }
@@ -691,7 +692,7 @@ int GetSharedOTUCommand::process(vector<SharedRAbundVector*>& lookup) {
                        
                        for(int j = 0; j < lookup.size(); j++) {
                                string seqGroup = lookup[j]->getGroup();
                        
                        for(int j = 0; j < lookup.size(); j++) {
                                string seqGroup = lookup[j]->getGroup();
-                string name = m->currentBinLabels[i];
+                string name = m->currentSharedBinLabels[i];
                                
                 if (lookup[j]->getAbundance(i) != 0) {
                     if (output != "accnos") {
                                
                 if (lookup[j]->getAbundance(i) != 0) {
                     if (output != "accnos") {
index b991ccd6289b9afd44628c12bf451eb86529fa44..06d7260462878fc134268dba18ff0692515c80f8 100644 (file)
@@ -315,7 +315,9 @@ int HClusterCommand::execute(){
                }else{
                        m->mothurOut("Error: no list vector!"); m->mothurOutEndLine(); return 0;
                }
                }else{
                        m->mothurOut("Error: no list vector!"); m->mothurOutEndLine(); return 0;
                }
-               
+        
+        list->printHeaders(listFile);
+        
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;
                oldRAbund = *rabund;
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;
                oldRAbund = *rabund;
index 367342c7167451402c5879a1f6efd1f83e7a48a4..514c7af15312b60d4787bb0aa659dbd9f1ccaf08 100644 (file)
@@ -119,7 +119,7 @@ string HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                }
                
                //sort lookup so shared bins are on top
                }
                
                //sort lookup so shared bins are on top
-        vector<string> sortedLabels = m->currentBinLabels;
+        vector<string> sortedLabels = m->currentSharedBinLabels;
                if (sorted != "none") {  sortedLabels = sortSharedVectors(lookup);  }
                
                vector<vector<string> > scaleRelAbund;
                if (sorted != "none") {  sortedLabels = sortSharedVectors(lookup);  }
                
                vector<vector<string> > scaleRelAbund;
@@ -221,7 +221,7 @@ vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
                map<int, int>::iterator it;
         
                map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
                map<int, int>::iterator it;
         
-        vector<string> sortedLabels = m->currentBinLabels;
+        vector<string> sortedLabels = m->currentSharedBinLabels;
                
                /****************** find order of otus **********************/
                if (sorted == "shared") {
                
                /****************** find order of otus **********************/
                if (sorted == "shared") {
@@ -254,7 +254,7 @@ vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                                int newAbund = looktemp[j]->getAbundance(i);                                                                                            // 1 -> 3
                                lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
                        }
                                int newAbund = looktemp[j]->getAbundance(i);                                                                                            // 1 -> 3
                                lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
                        }
-            sortedLabels[place[i]] = m->currentBinLabels[i];
+            sortedLabels[place[i]] = m->currentSharedBinLabels[i];
                }
                
                //delete looktemp -- Sarah look at - this is causing segmentation faults
                }
                
                //delete looktemp -- Sarah look at - this is causing segmentation faults
@@ -430,7 +430,7 @@ string HeatMap::getPic(vector<SharedRAbundFloatVector*> lookup) {
                }
                
                //sort lookup so shared bins are on top
                }
                
                //sort lookup so shared bins are on top
-               vector<string> sortedLabels = m->currentBinLabels;
+               vector<string> sortedLabels = m->currentSharedBinLabels;
                if (sorted != "none") {  sortedLabels = sortSharedVectors(lookup);  }
                
                vector<vector<string> > scaleRelAbund;
                if (sorted != "none") {  sortedLabels = sortSharedVectors(lookup);  }
                
                vector<vector<string> > scaleRelAbund;
@@ -532,7 +532,7 @@ vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundFloatVector*>& look
                map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
                map<int, int>::iterator it;
         
                map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
                map<int, int>::iterator it;
         
-        vector<string> sortedLabels = m->currentBinLabels;
+        vector<string> sortedLabels = m->currentSharedBinLabels;
                
                /****************** find order of otus **********************/
                if (sorted == "shared") {
                
                /****************** find order of otus **********************/
                if (sorted == "shared") {
@@ -564,7 +564,7 @@ vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundFloatVector*>& look
                        for (int j = 0; j < looktemp.size(); j++) {                                                                                                             // 3 -> 2
                                float newAbund = looktemp[j]->getAbundance(i);                                                                                          // 1 -> 3
                                lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
                        for (int j = 0; j < looktemp.size(); j++) {                                                                                                             // 3 -> 2
                                float newAbund = looktemp[j]->getAbundance(i);                                                                                          // 1 -> 3
                                lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
-                sortedLabels[place[i]] = m->currentBinLabels[i];
+                sortedLabels[place[i]] = m->currentSharedBinLabels[i];
                        }
                }
                
                        }
                }
                
index fd818acb44c4c5280c6a54971d3d39413307861d..ab6e67027b1fe85ff97e2e7d40c1b6f9ff3ff1bc 100644 (file)
@@ -490,17 +490,17 @@ int IndicatorCommand::GetIndicatorSpecies(){
                                
                        if (m->control_pressed) { out.close(); return 0; }
                        
                                
                        if (m->control_pressed) { out.close(); return 0; }
                        
-                       out << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t'; 
+                       out << m->currentSharedBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t';
                        
                        if (pValues[j] > (1/(float)iters)) { out << pValues[j] << endl; } 
                        else { out << "<" << (1/(float)iters) << endl; }
                        
                        if (pValues[j] <= 0.05) {
                        
                        if (pValues[j] > (1/(float)iters)) { out << pValues[j] << endl; } 
                        else { out << "<" << (1/(float)iters) << endl; }
                        
                        if (pValues[j] <= 0.05) {
-                               cout << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j]  << '\t';
+                               cout << m->currentSharedBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j]  << '\t';
                                string pValueString = "<" + toString((1/(float)iters)); 
                                if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
                                else { cout << "<" << (1/(float)iters); }
                                string pValueString = "<" + toString((1/(float)iters)); 
                                if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
                                else { cout << "<" << (1/(float)iters); }
-                               m->mothurOutJustToLog(m->currentBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); 
+                               m->mothurOutJustToLog(m->currentSharedBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString);
                                m->mothurOutEndLine(); 
                        }
                }
                                m->mothurOutEndLine(); 
                        }
                }
@@ -538,7 +538,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                
                //print headings
                out << "TreeNode\t";
                
                //print headings
                out << "TreeNode\t";
-               for (int i = 0; i < numBins; i++) { out << m->currentBinLabels[i] << "_IndGroups" << '\t' << m->currentBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; }
+               for (int i = 0; i < numBins; i++) { out << m->currentSharedBinLabels[i] << "_IndGroups" << '\t' << m->currentSharedBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; }
                out << endl;
                
                m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicator_Groups\tIndicatorValue\tpValue\n");
                out << endl;
                
                m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicator_Groups\tIndicatorValue\tpValue\n");
@@ -697,11 +697,11 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                                }
                                
                                if (pValues[j] <= 0.05) {
                                }
                                
                                if (pValues[j] <= 0.05) {
-                                       cout << i+1 << '\t' << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j]  << '\t';
+                                       cout << i+1 << '\t' << m->currentSharedBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j]  << '\t';
                                        string pValueString = "<" + toString((1/(float)iters)); 
                                        if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
                                        else { cout << "<" << (1/(float)iters); }
                                        string pValueString = "<" + toString((1/(float)iters)); 
                                        if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
                                        else { cout << "<" << (1/(float)iters); }
-                                       m->mothurOutJustToLog(toString(i) + "\t" + m->currentBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); 
+                                       m->mothurOutJustToLog(toString(i) + "\t" + m->currentSharedBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString);
                                        m->mothurOutEndLine(); 
                                }
                        }
                                        m->mothurOutEndLine(); 
                                }
                        }
index 777444bc09749c6aaa7240448e8d777da8c14317..dc297e11d3ed61202a8e4bcb001686ea9475e52c 100644 (file)
@@ -307,7 +307,7 @@ int KruskalWallisCommand::process(vector<SharedRAbundVector*>& lookup, DesignMap
             double H = linear.calcKruskalWallis(values, pValue);
             
             //output H and signifigance
             double H = linear.calcKruskalWallis(values, pValue);
             
             //output H and signifigance
-            out << m->currentBinLabels[i] << '\t' << H << '\t' << pValue << endl;
+            out << m->currentSharedBinLabels[i] << '\t' << H << '\t' << pValue << endl;
         }
         out.close();
                 
         }
         out.close();
                 
index 8d1768c2b1d87bc840de743cc5d1dbdc0801b7da..0403c910705313432fa7320150326927d03c783b 100644 (file)
@@ -1009,8 +1009,8 @@ int LefseCommand::printResults(vector< vector<double> > means, map<int, double>
             if (maxMean > logMaxMean) { logMaxMean = maxMean; }
             logMaxMean = log10(logMaxMean);
             
             if (maxMean > logMaxMean) { logMaxMean = maxMean; }
             logMaxMean = log10(logMaxMean);
             
-            out << m->currentBinLabels[i] << '\t' << logMaxMean << '\t';
-            if (m->debug) { temp = m->currentBinLabels[i] + '\t' + toString(logMaxMean) + '\t'; }
+            out << m->currentSharedBinLabels[i] << '\t' << logMaxMean << '\t';
+            if (m->debug) { temp = m->currentSharedBinLabels[i] + '\t' + toString(logMaxMean) + '\t'; }
             
             map<int, double>::iterator it = sigLDA.find(i);
             if (it != sigLDA.end()) {
             
             map<int, double>::iterator it = sigLDA.find(i);
             if (it != sigLDA.end()) {
@@ -1040,7 +1040,7 @@ bool LefseCommand::printToCoutForRTesting(vector< vector<double> >& adjustedLook
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
-            cout << m->currentBinLabels[it->first] << " <- c(";
+            cout << m->currentSharedBinLabels[it->first] << " <- c(";
             for (int h = 0; h < rand_s.size()-1; h++) {  cout << (adjustedLookup[count][rand_s[h]]) << ", "; }
             cout << (adjustedLookup[count][rand_s[rand_s.size()-1]]) << ")\n";
             count++;
             for (int h = 0; h < rand_s.size()-1; h++) {  cout << (adjustedLookup[count][rand_s[h]]) << ", "; }
             cout << (adjustedLookup[count][rand_s[rand_s.size()-1]]) << ")\n";
             count++;
@@ -1096,7 +1096,7 @@ bool LefseCommand::printToCoutForRTesting(vector< vector<double> >& adjustedLook
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
-            tempOutput += "\"" + m->currentBinLabels[it->first] + "\"=" + m->currentBinLabels[it->first] + ",";
+            tempOutput += "\"" + m->currentSharedBinLabels[it->first] + "\"=" + m->currentSharedBinLabels[it->first] + ",";
         }
         //tempOutput = tempOutput.substr(0, tempOutput.length()-1);
         tempOutput += " class=treatments";
         }
         //tempOutput = tempOutput.substr(0, tempOutput.length()-1);
         tempOutput += " class=treatments";
@@ -1109,7 +1109,7 @@ bool LefseCommand::printToCoutForRTesting(vector< vector<double> >& adjustedLook
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
         for (map<int, double>::iterator it = bins.begin(); it != bins.end(); it++) {
             if (m->control_pressed) { break; }
             
-            tempOutput +=  m->currentBinLabels[it->first] + "+";
+            tempOutput +=  m->currentSharedBinLabels[it->first] + "+";
         }
         tempOutput = tempOutput.substr(0, tempOutput.length()-1); //rip off extra plus sign
         tempOutput += "), data = dat, tol = 1e-10))";
         }
         tempOutput = tempOutput.substr(0, tempOutput.length()-1); //rip off extra plus sign
         tempOutput += "), data = dat, tol = 1e-10))";
@@ -1168,7 +1168,7 @@ int LefseCommand::makeShared(int numDesignLines) {
             lookup.push_back(temp);
         }
         
             lookup.push_back(temp);
         }
         
-        m->currentBinLabels.clear();
+        m->currentSharedBinLabels.clear();
         int count = 0;
         while (!in.eof()) {
             if (m->control_pressed) { return 0; }
         int count = 0;
         while (!in.eof()) {
             if (m->control_pressed) { return 0; }
@@ -1189,7 +1189,7 @@ int LefseCommand::makeShared(int numDesignLines) {
                     lookup[i-1]->push_back(value, toString(i-1));
                     //cout << pieces[i] << '\t';
                 }
                     lookup[i-1]->push_back(value, toString(i-1));
                     //cout << pieces[i] << '\t';
                 }
-                m->currentBinLabels.push_back(toString(count));
+                m->currentSharedBinLabels.push_back(toString(count));
                 //m->currentBinLabels.push_back(pieces[0]);
                 //cout << line<< endl;
                 //cout << endl;
                 //m->currentBinLabels.push_back(pieces[0]);
                 //cout << line<< endl;
                 //cout << endl;
index 037c8225cfbc96f4b3ea3986ef16bf961a9afec1..512dd6da763241d47d727dd10efcce3a68eab2b8 100644 (file)
@@ -461,7 +461,7 @@ int ListOtuLabelsCommand::createList(vector<SharedRAbundVector*>& lookup){
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
-        for (int i = 0; i < m->currentBinLabels.size(); i++) {  out << m->currentBinLabels[i] << endl;  }
+        for (int i = 0; i < m->currentSharedBinLabels.size(); i++) {  out << m->currentSharedBinLabels[i] << endl;  }
         
         out.close();
         
         
         out.close();
         
@@ -485,7 +485,7 @@ int ListOtuLabelsCommand::createList(vector<SharedRAbundFloatVector*>& lookup){
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
-        for (int i = 0; i < m->currentBinLabels.size(); i++) {  out << m->currentBinLabels[i] << endl;  }
+        for (int i = 0; i < m->currentSharedBinLabels.size(); i++) {  out << m->currentSharedBinLabels[i] << endl;  }
         
         out.close();
         
         
         out.close();
         
@@ -507,20 +507,8 @@ int ListOtuLabelsCommand::createList(ListVector*& list){
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
-        string snumBins = toString(list->getNumBins());
-        for (int i = 0; i < list->getNumBins(); i++) {
-            if (m->control_pressed) { break; }
-            
-            string otuLabel = "Otu";
-            string sbinNumber = toString(i+1);
-            if (sbinNumber.length() < snumBins.length()) { 
-                int diff = snumBins.length() - sbinNumber.length();
-                for (int h = 0; h < diff; h++) { otuLabel += "0"; }
-            }
-            otuLabel += sbinNumber; 
-            
-            out << otuLabel << endl;
-        }
+        vector<string> binLabels = list->getLabels();
+        for (int i = 0; i < binLabels.size(); i++) {  out << binLabels[i] << endl;  }
 
         out.close();
         
 
         out.close();
         
index 2758c94264a1ba527e8d7c3970e0bac53254579b..90df802cfea64f2894733bcd377936b4476ac05b 100644 (file)
@@ -67,8 +67,59 @@ ListVector::ListVector(string id, vector<string> lv) : DataVector(id), data(lv){
 ListVector::ListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
                int hold;
 ListVector::ListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
                int hold;
-               f >> label >> hold;
+        
+        //are we at the beginning of the file??
+               if (m->saveNextLabel == "") {
+                       f >> label;
+            
+                       //is this a shared file that has headers
+                       if (label == "label") {
+                               
+                               //gets "numOtus"
+                               f >> label; m->gobble(f);
+                               
+                               //eat rest of line
+                               label = m->getline(f); m->gobble(f);
+                               
+                               //parse labels to save
+                               istringstream iStringStream(label);
+                               m->listBinLabelsInFile.clear();
+                               while(!iStringStream.eof()){
+                                       if (m->control_pressed) { break; }
+                                       string temp;
+                                       iStringStream >> temp;  m->gobble(iStringStream);
+                    
+                                       m->listBinLabelsInFile.push_back(temp);
+                               }
+                               
+                               f >> label >> hold;
+                       }else {
+                //read in first row
+                f >> hold;
+                
+                //make binlabels because we don't have any
+                string snumBins = toString(hold);
+                m->listBinLabelsInFile.clear();
+                for (int i = 0; i < hold; i++) {
+                    //if there is a bin label use it otherwise make one
+                    string binLabel = "Otu";
+                    string sbinNumber = toString(i+1);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    m->listBinLabelsInFile.push_back(binLabel);
+                }
+            }
+            m->saveNextLabel = label;
+               }else {
+            f >> label >> hold;
+            m->saveNextLabel = label;
+        }
        
        
+        binLabels.assign(m->listBinLabelsInFile.begin(), m->listBinLabelsInFile.begin()+hold);
+               
                data.assign(hold, "");
                string inputData = "";
        
                data.assign(hold, "");
                string inputData = "";
        
@@ -77,6 +128,8 @@ ListVector::ListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numS
                        set(i, inputData);
                }
                m->gobble(f);
                        set(i, inputData);
                }
                m->gobble(f);
+        
+        if (f.eof()) { m->saveNextLabel = ""; }
        }
        catch(exception& e) {
                m->errorOut(e, "ListVector", "ListVector");
        }
        catch(exception& e) {
                m->errorOut(e, "ListVector", "ListVector");
@@ -109,6 +162,60 @@ void ListVector::set(int binNumber, string seqNames){
 string ListVector::get(int index){
        return data[index];
 }
 string ListVector::get(int index){
        return data[index];
 }
+/***********************************************************************/
+
+void ListVector::setLabels(vector<string> labels){
+       try {
+               binLabels = labels;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListVector", "setLabels");
+               exit(1);
+       }
+}
+
+/***********************************************************************/
+//could potentially end up with duplicate binlabel names with code below.
+//we don't currently use them in a way that would do that.
+//if you had a listfile that had been subsampled and then added to it, dup names would be possible.
+vector<string> ListVector::getLabels(){
+    try {
+        
+        string tagHeader = "Otu";
+        if (m->sharedHeaderMode == "tax") { tagHeader = "PhyloType"; }
+        
+        if (binLabels.size() < data.size()) {
+            string snumBins = toString(numBins);
+            
+            for (int i = 0; i < numBins; i++) {
+                string binLabel = tagHeader;
+                
+                if (i < binLabels.size()) { //label exists, check leading zeros length
+                    string sbinNumber = m->getSimpleLabel(binLabels[i]);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    binLabels[i] = binLabel;
+                }else{
+                    string sbinNumber = toString(i+1);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    binLabels.push_back(binLabel);
+                }
+            }
+        }
+        return binLabels;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "ListVector", "getLabels");
+               exit(1);
+       }
+}
 
 /***********************************************************************/
 
 
 /***********************************************************************/
 
@@ -150,6 +257,52 @@ void ListVector::clear(){
        
 }
 
        
 }
 
+/***********************************************************************/
+void ListVector::printHeaders(ostream& output){
+       try {
+               string snumBins = toString(numBins);
+               output << "label\tnumOtus\t";
+               if (m->sharedHeaderMode == "tax") {
+                       for (int i = 0; i < numBins; i++) {
+                               
+                               //if there is a bin label use it otherwise make one
+                               string binLabel = "PhyloType";
+                               string sbinNumber = toString(i+1);
+                               if (sbinNumber.length() < snumBins.length()) {
+                                       int diff = snumBins.length() - sbinNumber.length();
+                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                               }
+                               binLabel += sbinNumber;
+                               if (i < binLabels.size()) {  binLabel = binLabels[i]; }
+                               
+                               output << binLabel << '\t';
+                       }
+                       output << endl;
+               }else {
+                       for (int i = 0; i < numBins; i++) {
+                               //if there is a bin label use it otherwise make one
+                               string binLabel = "Otu";
+                               string sbinNumber = toString(i+1);
+                               if (sbinNumber.length() < snumBins.length()) {
+                                       int diff = snumBins.length() - sbinNumber.length();
+                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                               }
+                               binLabel += sbinNumber;
+                               if (i < binLabels.size()) {  binLabel = binLabels[i]; }
+                               
+                               output << binLabel << '\t';
+                       }
+                       
+                       output << endl;
+               }
+               m->printedListHeaders = true;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListVector", "printHeaders");
+               exit(1);
+       }
+}
+
 /***********************************************************************/
 
 void ListVector::print(ostream& output){
 /***********************************************************************/
 
 void ListVector::print(ostream& output){
index dcf01a0ad4b356f152a3cf8ca168a6ba528b63bb..b2bc511cfd258da992f9f1b8a44971f4dd29e3e2 100644 (file)
@@ -20,7 +20,7 @@ public:
        ListVector(int);
 //     ListVector(const ListVector&);
        ListVector(string, vector<string>);
        ListVector(int);
 //     ListVector(const ListVector&);
        ListVector(string, vector<string>);
-       ListVector(const ListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){};
+       ListVector(const ListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs), binLabels(lv.binLabels) {};
        ListVector(ifstream&);
        ~ListVector(){};
        
        ListVector(ifstream&);
        ~ListVector(){};
        
@@ -30,11 +30,14 @@ public:
 
        void set(int, string);  
        string get(int);
 
        void set(int, string);  
        string get(int);
+    vector<string> getLabels();
+    void setLabels(vector<string>);
        void push_back(string);
        void resize(int);
        void clear();
        int size();
        void print(ostream&);
        void push_back(string);
        void resize(int);
        void clear();
        int size();
        void print(ostream&);
+    void printHeaders(ostream&);
        
        RAbundVector getRAbundVector();
        SAbundVector getSAbundVector();
        
        RAbundVector getRAbundVector();
        SAbundVector getSAbundVector();
@@ -45,6 +48,7 @@ private:
        int maxRank;
        int numBins;
        int numSeqs;
        int maxRank;
        int numBins;
        int numSeqs;
+    vector<string> binLabels;
 
 };
 
 
 };
 
index 248b3c8194d27e05e9e8b15359cf6de5b9c2395a..0d289d7c195ae4b19d020de145e2b80382caf006 100644 (file)
@@ -447,10 +447,10 @@ int MakeBiomCommand::getBiom(vector<SharedRAbundVector*>& lookup){
         string rowBack = "\", \"metadata\":";
         for (int i = 0; i < numBins-1; i++) {
             if (m->control_pressed) {  out.close(); return 0; }
         string rowBack = "\", \"metadata\":";
         for (int i = 0; i < numBins-1; i++) {
             if (m->control_pressed) {  out.close(); return 0; }
-            if (!picrust) { out << rowFront << m->currentBinLabels[i] << rowBack << metadata[i] << "},\n"; }
+            if (!picrust) { out << rowFront << m->currentSharedBinLabels[i] << rowBack << metadata[i] << "},\n"; }
             else {  out << rowFront << picrustLabels[i] << rowBack << metadata[i] << "},\n"; }
         }
             else {  out << rowFront << picrustLabels[i] << rowBack << metadata[i] << "},\n"; }
         }
-        if (!picrust) {  out << rowFront << m->currentBinLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n"; }
+        if (!picrust) {  out << rowFront << m->currentSharedBinLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n"; }
         else {  out << rowFront << picrustLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n"; }
         //get column info
         /*"columns": [
         else {  out << rowFront << picrustLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n"; }
         //get column info
         /*"columns": [
@@ -574,7 +574,7 @@ vector<string> MakeBiomCommand::getMetaData(vector<SharedRAbundVector*>& lookup,
             in.close();
             
             //should the labels be Otu001 or PhyloType001
             in.close();
             
             //should the labels be Otu001 or PhyloType001
-            string firstBin = m->currentBinLabels[0];
+            string firstBin = m->currentSharedBinLabels[0];
             string binTag = "Otu";
             if ((firstBin.find("Otu")) == string::npos) { binTag = "PhyloType";  }
             
             string binTag = "Otu";
             if ((firstBin.find("Otu")) == string::npos) { binTag = "PhyloType";  }
             
@@ -611,9 +611,9 @@ vector<string> MakeBiomCommand::getMetaData(vector<SharedRAbundVector*>& lookup,
                 
                 if (m->control_pressed) { return metadata; }
                 
                 
                 if (m->control_pressed) { return metadata; }
                 
-                it = labelTaxMap.find(m->getSimpleLabel(m->currentBinLabels[i]));
+                it = labelTaxMap.find(m->getSimpleLabel(m->currentSharedBinLabels[i]));
                 
                 
-                if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentBinLabels[i] + ".\n"); m->control_pressed = true; }
+                if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentSharedBinLabels[i] + ".\n"); m->control_pressed = true; }
                 else {
                     if (picrust) {
                         string temp = it->second; m->removeConfidences(temp);
                 else {
                     if (picrust) {
                         string temp = it->second; m->removeConfidences(temp);
index 73f9db202a0171bd49623ab685f88f9b38593dc5..c859bfbc230201e4be1ef73ab19ed56f28b3412d 100644 (file)
@@ -289,7 +289,7 @@ int MakeLefseCommand::runRelabund(map<string, consTax2>& consTax, vector<SharedR
         
         for (int i = 0; i < lookup[0]->getNumBins(); i++) { //process each otu
             if (m->control_pressed) { break; }
         
         for (int i = 0; i < lookup[0]->getNumBins(); i++) { //process each otu
             if (m->control_pressed) { break; }
-            string nameOfOtu = m->currentBinLabels[i];
+            string nameOfOtu = m->currentSharedBinLabels[i];
             if (constaxonomyfile != "") { //try to find the otuName in consTax to replace with consensus taxonomy
                 map<string, consTax2>::iterator it = consTax.find(nameOfOtu);
                 if (it != consTax.end()) {
             if (constaxonomyfile != "") { //try to find the otuName in consTax to replace with consensus taxonomy
                 map<string, consTax2>::iterator it = consTax.find(nameOfOtu);
                 if (it != consTax.end()) {
@@ -299,7 +299,7 @@ int MakeLefseCommand::runRelabund(map<string, consTax2>& consTax, vector<SharedR
                     //remove confidences and change ; to |
                     m->removeConfidences(nameOfOtu);
                     for (int j = 0; j < nameOfOtu.length()-1; j++) {
                     //remove confidences and change ; to |
                     m->removeConfidences(nameOfOtu);
                     for (int j = 0; j < nameOfOtu.length()-1; j++) {
-                        if (nameOfOtu[j] == ';') { fixedName += "_" + m->currentBinLabels[i] + '|'; }
+                        if (nameOfOtu[j] == ';') { fixedName += "_" + m->currentSharedBinLabels[i] + '|'; }
                         else { fixedName += nameOfOtu[j]; }
                     }
                     nameOfOtu = fixedName;
                         else { fixedName += nameOfOtu[j]; }
                     }
                     nameOfOtu = fixedName;
index bfd1b8484eee963c897000a20024aae831c531f5..0ddc3d477336d34340497b82121cb0c032c9067b 100644 (file)
@@ -327,7 +327,7 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                                
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                
                                
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                               if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                                process(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
                                process(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -341,7 +341,7 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                                lookup = input.getSharedRAbundVectors(lastLabel);
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                
                                lookup = input.getSharedRAbundVectors(lastLabel);
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                               if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                                process(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
                                process(lookup, out);
                                
                                processedLabels.insert(lookup[0]->getLabel());
@@ -383,7 +383,7 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                        
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        
                        
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        
-                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
+                       if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
                        process(lookup, out);
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                        process(lookup, out);
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
index 204d83e10df302ba17d3303c0bdb0a81f54536be..33b559fc2dc358017c90fd44fe77ec0be61acb65 100644 (file)
@@ -646,7 +646,7 @@ int MetaStatsCommand::convertToInput(vector<SharedRAbundVector*>& subset, string
         out << subset[subset.size()-1]->getGroup() << endl;
         
         for (int i = 0; i < subset[0]->getNumBins(); i++) {
         out << subset[subset.size()-1]->getGroup() << endl;
         
         for (int i = 0; i < subset[0]->getNumBins(); i++) {
-            out << m->currentBinLabels[i] << '\t';
+            out << m->currentSharedBinLabels[i] << '\t';
             for (int j = 0; j < subset.size()-1; j++) {
                 out << subset[j]->getAbundance(i) << '\t';
             }
             for (int j = 0; j < subset.size()-1; j++) {
                 out << subset[j]->getAbundance(i) << '\t';
             }
index 85db5e0e8ffc384960f7954d6db1266bac9ea3c1..a2079251c4af101750b317e3926eba75d5302c9c 100644 (file)
@@ -295,6 +295,7 @@ int MGClusterCommand::execute(){
             m->openOutputFile(rabundFileName,  rabundFile);
         }
                m->openOutputFile(listFileName, listFile);
             m->openOutputFile(rabundFileName,  rabundFile);
         }
                m->openOutputFile(listFileName, listFile);
+        list->printHeaders(listFile);
                
                if (m->control_pressed) { 
                        delete nameMap; delete read; delete list; delete rabund; 
                
                if (m->control_pressed) { 
                        delete nameMap; delete read; delete list; delete rabund; 
index 4715de9b7ac6d8c9f14e4fd4575906c433ae2808..f6a7800c3697833eeb9160330671804f13633bfb 100644 (file)
@@ -229,7 +229,7 @@ int MothurMetastats::runMetastats(string outputFileName, vector< vector<double>
                        if (m->control_pressed) { out.close(); return 0; }
                        
             //if there are binlabels use them otherwise count.
                        if (m->control_pressed) { out.close(); return 0; }
                        
             //if there are binlabels use them otherwise count.
-                       if (m->binLabelsInFile.size() == row) { out << m->binLabelsInFile[i] << '\t'; }
+                       if (i < m->currentSharedBinLabels.size()) { out << m->currentSharedBinLabels[i] << '\t'; }
             else { out << (i+1) << '\t'; }
             
             out << C1[i][0] << '\t' << C1[i][1] << '\t' << C1[i][2] << '\t' << C2[i][0] << '\t' << C2[i][1] << '\t' << C2[i][2] << '\t' << pvalues[i] << '\t' << qvalues[i] << endl;
             else { out << (i+1) << '\t'; }
             
             out << C1[i][0] << '\t' << C1[i][1] << '\t' << C1[i][2] << '\t' << C2[i][0] << '\t' << C2[i][1] << '\t' << C2[i][2] << '\t' << pvalues[i] << '\t' << qvalues[i] << endl;
index f58f4e874a7f72961489d7e2651bda651e3d2bb4..363a7a88041ac97bfd207558fc4fa445af7d442b 100644 (file)
@@ -67,10 +67,12 @@ class MothurOut {
                vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
                vector<string> Treenames;
                //map<string, string> names;
                vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
                vector<string> Treenames;
                //map<string, string> names;
-               vector<string> binLabelsInFile;
-               vector<string> currentBinLabels;
+               vector<string> sharedBinLabelsInFile;
+               vector<string> currentSharedBinLabels;
+        vector<string> listBinLabelsInFile;
+        //vector<string> currentListBinLabels;
                string saveNextLabel, argv, sharedHeaderMode, groupMode;
                string saveNextLabel, argv, sharedHeaderMode, groupMode;
-               bool printedHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
+               bool printedSharedHeaders, printedListHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
                
                //functions from mothur.h
                //file operations
                
                //functions from mothur.h
                //file operations
@@ -270,7 +272,8 @@ class MothurOut {
             counttablefile = "";
             summaryfile = "";
                        gui = false;
             counttablefile = "";
             summaryfile = "";
                        gui = false;
-                       printedHeaders = false;
+                       printedSharedHeaders = false;
+            printedListHeaders = false;
                        commandInputsConvertError = false;
             mothurCalling = false;
             debug = false;
                        commandInputsConvertError = false;
             mothurCalling = false;
             debug = false;
index acd8208ea7ebb20a3d3810d254d0b24f5386d4d3..1000e4243e0c6fbf15f5e384871131f74d2a4ea5 100644 (file)
@@ -458,7 +458,7 @@ int NormalizeSharedCommand::execute(){
 int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
        try {
                //save mothurOut's binLabels to restore for next label
 int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
        try {
                //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
+               vector<string> saveBinLabels = m->currentSharedBinLabels;
                
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                
                
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                
@@ -540,7 +540,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
                
                out.close();
                
                
                out.close();
                
-               m->currentBinLabels = saveBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
                
                return 0;
        }
                
                return 0;
        }
@@ -555,7 +555,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLook
        try {
                
                //save mothurOut's binLabels to restore for next label
        try {
                
                //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
+               vector<string> saveBinLabels = m->currentSharedBinLabels;
                
         map<string, string> variables; 
         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
                
         map<string, string> variables; 
         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
@@ -629,7 +629,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLook
                
                out.close();
                
                
                out.close();
                
-               m->currentBinLabels = saveBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
                
                return 0;
        }
                
                return 0;
        }
@@ -675,7 +675,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thisl
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                newBinLabels.push_back(binLabel);
                        }
                                
                                newBinLabels.push_back(binLabel);
                        }
@@ -684,7 +684,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thisl
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
 
                thislookup = newLookup;
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
 
                thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
+               m->currentSharedBinLabels = newBinLabels;
                
                return 0;
  
                
                return 0;
  
@@ -731,7 +731,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                newBinLabels.push_back(binLabel);
                        }
                                
                                newBinLabels.push_back(binLabel);
                        }
@@ -740,7 +740,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
+               m->currentSharedBinLabels = newBinLabels;
                
                return 0;
                
                
                return 0;
                
index 9ccdeeaba28b54a899fd90dada402030e0d87c3f..705540c3a62564a14da7a7ed00262c4adb5f220b 100644 (file)
@@ -360,7 +360,7 @@ int OTUAssociationCommand::process(vector<SharedRAbundVector*>& lookup){
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
-                    if (sig < cutoff) { out << m->binLabelsInFile[i] << '\t' << m->binLabelsInFile[k] << '\t' << coef << '\t' << sig << endl; }
+                    if (sig < cutoff) { out << m->currentSharedBinLabels[i] << '\t' << m->currentSharedBinLabels[k] << '\t' << coef << '\t' << sig << endl; }
                 }
             }
                }else { //compare otus to metadata
                 }
             }
                }else { //compare otus to metadata
@@ -377,7 +377,7 @@ int OTUAssociationCommand::process(vector<SharedRAbundVector*>& lookup){
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], metadata[k], sig);     }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], metadata[k], sig);     }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
-                    if (sig < cutoff) { out << m->binLabelsInFile[i] << '\t' << metadataLabels[k] << '\t' << coef << '\t' << sig << endl; }
+                    if (sig < cutoff) { out << m->currentSharedBinLabels[i] << '\t' << metadataLabels[k] << '\t' << coef << '\t' << sig << endl; }
                 }
             }
 
                 }
             }
 
@@ -523,7 +523,7 @@ int OTUAssociationCommand::process(vector<SharedRAbundFloatVector*>& lookup){
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
-                    if (sig < cutoff) { out << m->binLabelsInFile[i] << '\t' << m->binLabelsInFile[k] << '\t' << coef << '\t' << sig << endl; }
+                    if (sig < cutoff) { out << m->currentSharedBinLabels[i] << '\t' << m->currentSharedBinLabels[k] << '\t' << coef << '\t' << sig << endl; }
                 }
             }
                }else { //compare otus to metadata
                 }
             }
                }else { //compare otus to metadata
@@ -540,7 +540,7 @@ int OTUAssociationCommand::process(vector<SharedRAbundFloatVector*>& lookup){
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], metadata[k], sig);     }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
                     else if (method == "kendall")      {       coef = linear.calcKendall(xy[i], metadata[k], sig);     }                   
                     else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
                     
-                    if (sig < cutoff) { out << m->binLabelsInFile[i] << '\t' << metadataLabels[k] << '\t' << coef << '\t' << sig << endl; }
+                    if (sig < cutoff) { out << m->currentSharedBinLabels[i] << '\t' << metadataLabels[k] << '\t' << coef << '\t' << sig << endl; }
                 }
             }
             
                 }
             }
             
index a294a77c69a8cd5582a38cf7394c510a1e5ccccb..07e3c1d0146ef521563697fe07deb38d7837b67d 100644 (file)
@@ -175,11 +175,11 @@ int OtuHierarchyCommand::execute(){
                }
                
                //map sequences to bin number in the "little" otu
                }
                
                //map sequences to bin number in the "little" otu
-               map<string, int> littleBins; 
+               map<string, int> littleBins;
+        vector<string> binLabels0 = lists[0].getLabels();
                for (int i = 0; i < lists[0].getNumBins(); i++) {
                
                        if (m->control_pressed) {  return 0; }
                for (int i = 0; i < lists[0].getNumBins(); i++) {
                
                        if (m->control_pressed) {  return 0; }
-                       
                        string bin = lists[0].get(i);
             vector<string> names; m->splitAtComma(bin, names);
                        for (int j = 0; j < names.size(); j++) { littleBins[names[j]] = i; }
                        string bin = lists[0].get(i);
             vector<string> names; m->splitAtComma(bin, names);
                        for (int j = 0; j < names.size(); j++) { littleBins[names[j]] = i; }
@@ -195,17 +195,17 @@ int OtuHierarchyCommand::execute(){
                m->openOutputFile(outputFileName, out);
                
                //go through each bin in "big" otu and output the bins in "little" otu which created it
                m->openOutputFile(outputFileName, out);
                
                //go through each bin in "big" otu and output the bins in "little" otu which created it
+        vector<string> binLabels1 = lists[1].getLabels();
                for (int i = 0; i < lists[1].getNumBins(); i++) {
                
                        if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; }
                        
                        string binnames = lists[1].get(i);
             vector<string> names; m->splitAtComma(binnames, names);
                for (int i = 0; i < lists[1].getNumBins(); i++) {
                
                        if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; }
                        
                        string binnames = lists[1].get(i);
             vector<string> names; m->splitAtComma(binnames, names);
-            
                        
                        //output column 1
                        if (output == "name")   {   out << binnames << '\t';    }
                        
                        //output column 1
                        if (output == "name")   {   out << binnames << '\t';    }
-                       else                                    {       out << (i+1) << '\t';           }
+                       else                                    {       out << binLabels1[i] << '\t';           }
                        
                        map<int, int> bins; //bin numbers in little that are in this bin in big
                        map<int, int>::iterator it;
                        
                        map<int, int> bins; //bin numbers in little that are in this bin in big
                        map<int, int>::iterator it;
@@ -216,7 +216,7 @@ int OtuHierarchyCommand::execute(){
                        string col2 = "";
                        for (it = bins.begin(); it != bins.end(); it++) {
                                if (output == "name")   {   col2 += lists[0].get(it->first) + "\t";     }
                        string col2 = "";
                        for (it = bins.begin(); it != bins.end(); it++) {
                                if (output == "name")   {   col2 += lists[0].get(it->first) + "\t";     }
-                               else                                    {       col2 += toString(it->first) + "\t";             }
+                               else                                    {       col2 += binLabels0[it->first] + "\t";           }
                        }
                        
                        //output column 2
                        }
                        
                        //output column 2
index d998de63ee8f31df493cd8546ecb5fb00b83311c..acf87dfebcd022d37cf6974f8331c7ad940a017a 100644 (file)
@@ -180,7 +180,7 @@ int RandomForest::calcForrestVariableImportance(string filename) {
         m->openOutputFile(filename, out);
         out <<"OTU\tMean decrease accuracy\n";
         for (int i = 0; i < globalVariableRanks.size(); i++) {
         m->openOutputFile(filename, out);
         out <<"OTU\tMean decrease accuracy\n";
         for (int i = 0; i < globalVariableRanks.size(); i++) {
-            out << m->currentBinLabels[(int)globalVariableRanks[i].first] << '\t' << globalVariableImportanceList[globalVariableRanks[i].first] << endl;
+            out << m->currentSharedBinLabels[(int)globalVariableRanks[i].first] << '\t' << globalVariableImportanceList[globalVariableRanks[i].first] << endl;
         }
         out.close();
         return 0;
         }
         out.close();
         return 0;
index 9eefa43c9f303249c812d27a1ccbc481dc6b7fcf..9db35cb4bcb1fb78daa9545ecf4464b29c09d2e2 100644 (file)
@@ -560,9 +560,9 @@ int RemoveGroupsCommand::readShared(){
                m->setGroups(groupsToKeep);
                m->clearAllGroups();
                m->saveNextLabel = "";
                m->setGroups(groupsToKeep);
                m->clearAllGroups();
                m->saveNextLabel = "";
-               m->printedHeaders = false;
-               m->currentBinLabels.clear();
-               m->binLabelsInFile.clear();
+               m->printedSharedHeaders = false;
+               m->currentSharedBinLabels.clear();
+               m->sharedBinLabelsInFile.clear();
                
                InputData input(sharedfile, "sharedfile");
                lookup = input.getSharedRAbundVectors();
                
                InputData input(sharedfile, "sharedfile");
                lookup = input.getSharedRAbundVectors();
index 01f45ca97329fbbe383c2157f12880ca05671a10..761de1426f180ed84986ce012625a26cdaf04016 100644 (file)
@@ -843,9 +843,9 @@ int RemoveLineageCommand::readShared(){
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
-            if (names.count(m->getSimpleLabel(m->currentBinLabels[i])) == 0) {
+            if (names.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) == 0) {
                 wroteSomething = true;
                 wroteSomething = true;
-                newLabels.push_back(m->currentBinLabels[i]);
+                newLabels.push_back(m->currentSharedBinLabels[i]);
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
@@ -865,7 +865,7 @@ int RemoveLineageCommand::readShared(){
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
-        m->currentBinLabels = newLabels;
+        m->currentSharedBinLabels = newLabels;
         
                newLookup[0]->printHeaders(out);
                
         
                newLookup[0]->printHeaders(out);
                
index 161c4bfb3553d52ceac6fd89b033152cf9fa8e43..a882f6bdd3cc1a5588fa4cc18476eca09e6f2153 100644 (file)
@@ -462,9 +462,9 @@ int RemoveOtuLabelsCommand::readShared(){
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
             if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
             
             //is this otu on the list
-            if (labels.count(m->getSimpleLabel(m->currentBinLabels[i])) == 0) {
+            if (labels.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) == 0) {
                 wroteSomething = true;
                 wroteSomething = true;
-                newLabels.push_back(m->currentBinLabels[i]);
+                newLabels.push_back(m->currentSharedBinLabels[i]);
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
                 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
                     newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
                 }
@@ -484,7 +484,7 @@ int RemoveOtuLabelsCommand::readShared(){
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
         
                for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
         
-        m->currentBinLabels = newLabels;
+        m->currentSharedBinLabels = newLabels;
         
                newLookup[0]->printHeaders(out);
                
         
                newLookup[0]->printHeaders(out);
                
index 2eb5f63da369828e4e67e0f0b262b1e786b75a88..c378e41447013ba021935d07e76af3ae029ad1b0 100644 (file)
@@ -850,7 +850,7 @@ int RemoveRareCommand::processLookup(vector<SharedRAbundVector*>& lookup){
                                
                                //eliminates zero otus
                                if (allZero) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
                                
                                //eliminates zero otus
                                if (allZero) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
-                else { headers.push_back(m->currentBinLabels[i]); }
+                else { headers.push_back(m->currentSharedBinLabels[i]); }
                        }
                }else {
                        //for each otu
                        }
                }else {
                        //for each otu
@@ -867,7 +867,7 @@ int RemoveRareCommand::processLookup(vector<SharedRAbundVector*>& lookup){
                                
                                //eliminates otus below rare cutoff
                                if (totalAbund <= nseqs) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
                                
                                //eliminates otus below rare cutoff
                                if (totalAbund <= nseqs) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
-                else { headers.push_back(m->currentBinLabels[i]); }
+                else { headers.push_back(m->currentSharedBinLabels[i]); }
                        }
                }
                
                        }
                }
                
index 1e078b3f82080ec554462a12f2564b5a5f470d04..3be9bb16f6cab3275edf0bbaf5f4372d002ff7b1 100644 (file)
@@ -60,7 +60,7 @@ string SharedCommand::getOutputPattern(string type) {
     try {
         string pattern = "";
         
     try {
         string pattern = "";
         
-        if (type == "shared") {  pattern = "[filename],shared"; } 
+        if (type == "shared") {  pattern = "[filename],shared-[filename],[distance],shared"; }
         else if (type == "rabund") {  pattern = "[filename],[group],rabund"; } 
         else if (type == "group") {  pattern = "[filename],[group],groups"; }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         else if (type == "rabund") {  pattern = "[filename],[group],rabund"; } 
         else if (type == "group") {  pattern = "[filename],[group],groups"; }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
@@ -249,21 +249,9 @@ int SharedCommand::execute(){
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-                       
-               //getting output filename
-        string filename = "";
-               if (listfile != "") { filename = listfile; }
-        else { filename = biomfile; }
-               
-               if (outputDir == "") { outputDir += m->hasPath(filename); }
-               
-        map<string, string> variables; 
-               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
-               filename = getOutputFileName("shared",variables);
-               outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
-               
-        if (listfile != "") {  createSharedFromListGroup(filename);  }
-        else {   createSharedFromBiom(filename);  }
+        
+        if (listfile != "") {  createSharedFromListGroup();  }
+        else {   createSharedFromBiom();  }
         
         if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  }
         
         
         if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  }
         
@@ -297,8 +285,17 @@ int SharedCommand::execute(){
        }
 }
 //**********************************************************************************************************************
        }
 }
 //**********************************************************************************************************************
-int SharedCommand::createSharedFromBiom(string filename) {
+int SharedCommand::createSharedFromBiom() {
        try {
        try {
+        //getting output filename
+        string filename = biomfile;
+               if (outputDir == "") { outputDir += m->hasPath(filename); }
+               
+        map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+               filename = getOutputFileName("shared",variables);
+               outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
+        
         ofstream out;
         m->openOutputFile(filename, out);
         
         ofstream out;
         m->openOutputFile(filename, out);
         
@@ -458,7 +455,7 @@ int SharedCommand::createSharedFromBiom(string filename) {
         if (it == fileLines.end()) { m->mothurOut("[ERROR]: you file does not have a data provided.\n"); }
         else {
             string thisLine = it->second;
         if (it == fileLines.end()) { m->mothurOut("[ERROR]: you file does not have a data provided.\n"); }
         else {
             string thisLine = it->second;
-            m->currentBinLabels = otuNames;
+            m->currentSharedBinLabels = otuNames;
             
             //read data
             vector<SharedRAbundVector*> lookup = readData(matrixFormat, thisLine, matrixElementType, groupNames, otuNames.size());
             
             //read data
             vector<SharedRAbundVector*> lookup = readData(matrixFormat, thisLine, matrixElementType, groupNames, otuNames.size());
@@ -611,7 +608,7 @@ int SharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
                     for (int h = 0; h < diff; h++) { binLabel += "0"; }
                 }
                 binLabel += sbinNumber; 
                     for (int h = 0; h < diff; h++) { binLabel += "0"; }
                 }
                 binLabel += sbinNumber; 
-                if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                 
                 newBinLabels.push_back(binLabel);
             }
                 
                 newBinLabels.push_back(binLabel);
             }
@@ -620,7 +617,7 @@ int SharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
         for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
         
         thislookup = newLookup;
         for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
         
         thislookup = newLookup;
-        m->currentBinLabels = newBinLabels;
+        m->currentSharedBinLabels = newBinLabels;
         
         return 0;
         
         
         return 0;
         
@@ -750,10 +747,8 @@ string SharedCommand::getTag(string& line) {
        }
 }
 //**********************************************************************************************************************
        }
 }
 //**********************************************************************************************************************
-int SharedCommand::createSharedFromListGroup(string filename) {
+int SharedCommand::createSharedFromListGroup() {
        try {
        try {
-        ofstream out;
-        m->openOutputFile(filename, out);
         
         GroupMap* groupMap = NULL;
         CountTable* countTable = NULL;
         
         GroupMap* groupMap = NULL;
         CountTable* countTable = NULL;
@@ -780,6 +775,20 @@ int SharedCommand::createSharedFromListGroup(string filename) {
             m->setGroups(Groups);
         }else { pickedGroups = true; }
         
             m->setGroups(Groups);
         }else { pickedGroups = true; }
         
+        
+        ofstream out;
+        string filename = "";
+        if (!pickedGroups) {
+            string filename = listfile;
+            if (outputDir == "") { outputDir += m->hasPath(filename); }
+            
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+            filename = getOutputFileName("shared",variables);
+            outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
+            m->openOutputFile(filename, out);
+        }
+        
         //fill filehandles with neccessary ofstreams
         int i;
         ofstream* temp;
         //fill filehandles with neccessary ofstreams
         int i;
         ofstream* temp;
@@ -814,7 +823,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         if (m->control_pressed) { 
             delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
             for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
         if (m->control_pressed) { 
             delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
             for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-            out.close(); m->mothurRemove(filename); 
+            out.close(); if (!pickedGroups) { m->mothurRemove(filename); }
             for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                 string rabundFIleName = getOutputFileName("rabund",variables);
                 m->mothurRemove(rabundFIleName);               }
             for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                 string rabundFIleName = getOutputFileName("rabund",variables);
                 m->mothurRemove(rabundFIleName);               }
@@ -831,7 +840,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         if ((!pickedGroups) && (SharedList->getNumSeqs() != numGroupNames)) {  //if the user has not specified any groups and their files don't match exit with error
             m->mothurOut("Your group file contains " + toString(numGroupNames) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); m->control_pressed = true;
             
         if ((!pickedGroups) && (SharedList->getNumSeqs() != numGroupNames)) {  //if the user has not specified any groups and their files don't match exit with error
             m->mothurOut("Your group file contains " + toString(numGroupNames) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); m->control_pressed = true;
             
-            out.close(); m->mothurRemove(filename); //remove blank shared file you made
+            out.close(); if (!pickedGroups) { m->mothurRemove(filename); } //remove blank shared file you made
             
             //delete memory
             for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
             
             //delete memory
             for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
@@ -845,9 +854,10 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         if ((pickedGroups) && (m->groupMode == "group")) { //make new group file
             string groups = "";
             if (m->getNumGroups() < 4) {
         if ((pickedGroups) && (m->groupMode == "group")) { //make new group file
             string groups = "";
             if (m->getNumGroups() < 4) {
-                for (int i = 0; i < m->getNumGroups(); i++) {
+                for (int i = 0; i < m->getNumGroups()-1; i++) {
                     groups += (m->getGroups())[i] + ".";
                 }
                     groups += (m->getGroups())[i] + ".";
                 }
+                groups+=(m->getGroups())[m->getNumGroups()-1];
             }else { groups = "merge"; }
             map<string, string> variables; 
             variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
             }else { groups = "merge"; }
             map<string, string> variables; 
             variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
@@ -877,7 +887,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
             if (m->control_pressed) { 
                 delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
             if (m->control_pressed) { 
                 delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                out.close(); m->mothurRemove(filename); 
+                if (!pickedGroups) { out.close(); m->mothurRemove(filename); }
                 for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                     string rabundFIleName = getOutputFileName("rabund",variables);
                     m->mothurRemove(rabundFIleName);           }
                 for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                     string rabundFIleName = getOutputFileName("rabund",variables);
                     m->mothurRemove(rabundFIleName);           }
@@ -889,23 +899,42 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 lookup = SharedList->getSharedRAbundVector();
                 
                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                 lookup = SharedList->getSharedRAbundVector();
                 
                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                if (pickedGroups) { //check for otus with no seqs in them
-                    eliminateZeroOTUS(lookup);
-                }
                 
                 if (m->control_pressed) { 
                     delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
                 
                 if (m->control_pressed) { 
                     delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                    out.close(); m->mothurRemove(filename); 
+                    if (!pickedGroups) { out.close(); m->mothurRemove(filename); }
                     for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                         string rabundFIleName = getOutputFileName("rabund",variables);
                         m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
                     for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                         string rabundFIleName = getOutputFileName("rabund",variables);
                         m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
-                if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                printSharedData(lookup, out); //prints info to the .shared file
+                //if picked groups must split the shared file by label
+                if (pickedGroups) {
+                    string filename = listfile;
+                    if (outputDir == "") { outputDir += m->hasPath(filename); }
+                    
+                    map<string, string> variables;
+                    variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+                    variables["[distance]"] = lookup[0]->getLabel();
+                    filename = getOutputFileName("shared",variables);
+                    outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
+                    ofstream out2;
+                    m->openOutputFile(filename, out2);
+                    
+                    vector<string> savedLabels = m->currentSharedBinLabels;
+                    eliminateZeroOTUS(lookup);
+                    lookup[0]->printHeaders(out2);
+                    printSharedData(lookup, out2);
+                    out2.close();
+                    m->currentSharedBinLabels = savedLabels; //restore old labels
+
+                }else {
+                    if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
+                    printSharedData(lookup, out); //prints info to the .shared file
+                }
                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                 
                 processedLabels.insert(SharedList->getLabel());
                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                 
                 processedLabels.insert(SharedList->getLabel());
@@ -920,24 +949,43 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 
                 lookup = SharedList->getSharedRAbundVector();
                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                 
                 lookup = SharedList->getSharedRAbundVector();
                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                if (pickedGroups) { //check for otus with no seqs in them
-                    eliminateZeroOTUS(lookup);
-                }
-                
                 
                 if (m->control_pressed) { 
                     delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
                 
                 if (m->control_pressed) { 
                     delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                    out.close(); m->mothurRemove(filename); 
+                    if (!pickedGroups) { out.close(); m->mothurRemove(filename); }
                     for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                         string rabundFIleName = getOutputFileName("rabund",variables);
                         m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
                     for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                         string rabundFIleName = getOutputFileName("rabund",variables);
                         m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
-                if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                printSharedData(lookup, out); //prints info to the .shared file
+                //if picked groups must split the shared file by label
+                if (pickedGroups) {
+                    string filename = listfile;
+                    if (outputDir == "") { outputDir += m->hasPath(filename); }
+                    
+                    map<string, string> variables;
+                    variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+                    variables["[distance]"] = lookup[0]->getLabel();
+                    filename = getOutputFileName("shared",variables);
+                    outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
+                    ofstream out2;
+                    m->openOutputFile(filename, out2);
+                    
+                    vector<string> savedLabels = m->currentSharedBinLabels;
+                    eliminateZeroOTUS(lookup);
+                    lookup[0]->printHeaders(out2);
+                    printSharedData(lookup, out2);
+                    out2.close();
+                    m->currentSharedBinLabels = savedLabels; //restore old labels
+                    
+                }else {
+                    if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
+                    printSharedData(lookup, out); //prints info to the .shared file
+                }
+
                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                 
                 processedLabels.insert(SharedList->getLabel());
                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                 
                 processedLabels.insert(SharedList->getLabel());
@@ -970,27 +1018,46 @@ int SharedCommand::createSharedFromListGroup(string filename) {
             
             lookup = SharedList->getSharedRAbundVector();
             m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
             
             lookup = SharedList->getSharedRAbundVector();
             m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-            if (pickedGroups) { //check for otus with no seqs in them
-                eliminateZeroOTUS(lookup);
-            }
             
             if (m->control_pressed) { 
                 if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;   }
             
             if (m->control_pressed) { 
                 if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;   }
-                out.close(); m->mothurRemove(filename); 
+                if (!pickedGroups) { out.close(); m->mothurRemove(filename); }
                 for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                     string rabundFIleName = getOutputFileName("rabund",variables);
                     m->mothurRemove(rabundFIleName);           }
                 return 0; 
             }
             
                 for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                     string rabundFIleName = getOutputFileName("rabund",variables);
                     m->mothurRemove(rabundFIleName);           }
                 return 0; 
             }
             
-            if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-            printSharedData(lookup, out); //prints info to the .shared file
+            //if picked groups must split the shared file by label
+            if (pickedGroups) {
+                string filename = listfile;
+                if (outputDir == "") { outputDir += m->hasPath(filename); }
+                
+                map<string, string> variables;
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+                variables["[distance]"] = lookup[0]->getLabel();
+                filename = getOutputFileName("shared",variables);
+                outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
+                ofstream out2;
+                m->openOutputFile(filename, out2);
+                
+                vector<string> savedLabels = m->currentSharedBinLabels;
+                eliminateZeroOTUS(lookup);
+                lookup[0]->printHeaders(out2);
+                printSharedData(lookup, out2);
+                out2.close();
+                m->currentSharedBinLabels = savedLabels; //restore old labels
+                
+            }else {
+                if (!m->printedSharedHeaders) { lookup[0]->printHeaders(out); }
+                printSharedData(lookup, out); //prints info to the .shared file
+            }
             for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
             delete SharedList;
         }
         
             for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
             delete SharedList;
         }
         
-        out.close();
+        if (!pickedGroups) { out.close(); }
         
         for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
             delete it3->second;
         
         for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
             delete it3->second;
@@ -999,7 +1066,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                
         if (m->control_pressed) { 
         if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                
         if (m->control_pressed) { 
-            m->mothurRemove(filename); 
+            if (!pickedGroups) { m->mothurRemove(filename); }
             for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                 string rabundFIleName = getOutputFileName("rabund",variables);
                 m->mothurRemove(rabundFIleName);               }
             for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
                 string rabundFIleName = getOutputFileName("rabund",variables);
                 m->mothurRemove(rabundFIleName);               }
index 39ef9a7a1ebc17f830103cf33d84520aca975f97..a916c854280c74d035968bfc84ec4ab88a4f70e6 100644 (file)
@@ -45,8 +45,8 @@ private:
        bool isValidGroup(string, vector<string>);
        int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
        int ListGroupSameSeqs(vector<string>&, SharedListVector*);
        bool isValidGroup(string, vector<string>);
        int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
        int ListGroupSameSeqs(vector<string>&, SharedListVector*);
-    int createSharedFromListGroup(string);
-    int createSharedFromBiom(string);
+    int createSharedFromListGroup();
+    int createSharedFromBiom();
     string getTag(string&);
     vector<string> readRows(string, int&); 
     int getDims(string, int&, int&);
     string getTag(string&);
     vector<string> readRows(string, int&); 
     int getDims(string, int&, int&);
index 2ce250ba908b4b45fa200b845275af22c3ca3be6..8fabc5b605b40f06ea1e7217a766f36bc8bfded9 100644 (file)
@@ -35,16 +35,70 @@ SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numB
             countTable->readTable(m->getCountTableFile(), true, false);
         }
 
             countTable->readTable(m->getCountTableFile(), true, false);
         }
 
-               int hold;
-               string inputData;
-               f >> label >> hold;
-       
-               data.assign(hold, "");
+        int hold;
+        
+               //are we at the beginning of the file??
+               if (m->saveNextLabel == "") {
+                       f >> label;
+            
+                       //is this a shared file that has headers
+                       if (label == "label") {
+                               
+                               //gets "numOtus"
+                               f >> label; m->gobble(f);
+                               
+                               //eat rest of line
+                               label = m->getline(f); m->gobble(f);
+                               
+                               //parse labels to save
+                               istringstream iStringStream(label);
+                               m->listBinLabelsInFile.clear();
+                               while(!iStringStream.eof()){
+                                       if (m->control_pressed) { break; }
+                                       string temp;
+                                       iStringStream >> temp;  m->gobble(iStringStream);
+                    
+                                       m->listBinLabelsInFile.push_back(temp);
+                               }
+                               
+                               f >> label >> hold;
+                       }else {
+                //read in first row
+                f >> hold;
+                
+                //make binlabels because we don't have any
+                string snumBins = toString(hold);
+                m->listBinLabelsInFile.clear();
+                for (int i = 0; i < hold; i++) {
+                    //if there is a bin label use it otherwise make one
+                    string binLabel = "Otu";
+                    string sbinNumber = toString(i+1);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    m->listBinLabelsInFile.push_back(binLabel);
+                }
+            }
+            m->saveNextLabel = label;
+               }else {
+            f >> label >> hold;
+            m->saveNextLabel = label;
+        }
+        
+        binLabels.assign(m->listBinLabelsInFile.begin(), m->listBinLabelsInFile.begin()+hold);
                
                
+               data.assign(hold, "");
+               string inputData = "";
+        
                for(int i=0;i<hold;i++){
                        f >> inputData;
                        set(i, inputData);
                }
                for(int i=0;i<hold;i++){
                        f >> inputData;
                        set(i, inputData);
                }
+               m->gobble(f);
+        
+        if (f.eof()) { m->saveNextLabel = ""; }
                
        }
        catch(exception& e) {
                
        }
        catch(exception& e) {
@@ -79,7 +133,59 @@ void SharedListVector::set(int binNumber, string seqNames){
 string SharedListVector::get(int index){
        return data[index];
 }
 string SharedListVector::get(int index){
        return data[index];
 }
+/***********************************************************************/
+
+void SharedListVector::setLabels(vector<string> labels){
+       try {
+               binLabels = labels;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedListVector", "setLabels");
+               exit(1);
+       }
+}
 
 
+/***********************************************************************/
+//could potentially end up with duplicate binlabel names with code below.
+//we don't currently use them in a way that would do that.
+//if you had a listfile that had been subsampled and then added to it, dup names would be possible.
+vector<string> SharedListVector::getLabels(){
+    try {
+        string tagHeader = "Otu";
+        if (m->sharedHeaderMode == "tax") { tagHeader = "PhyloType"; }
+        
+        if (binLabels.size() < data.size()) {
+            string snumBins = toString(numBins);
+            
+            for (int i = 0; i < numBins; i++) {
+                string binLabel = tagHeader;
+                
+                if (i < binLabels.size()) { //label exists, check leading zeros length
+                    string sbinNumber = m->getSimpleLabel(binLabels[i]);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    binLabels[i] = binLabel;
+                }else{
+                    string sbinNumber = toString(i+1);
+                    if (sbinNumber.length() < snumBins.length()) {
+                        int diff = snumBins.length() - sbinNumber.length();
+                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
+                    }
+                    binLabel += sbinNumber;
+                    binLabels.push_back(binLabel);
+                }
+            }
+        }
+        return binLabels;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "SharedListVector", "getLabels");
+               exit(1);
+       }
+}
 /***********************************************************************/
 
 void SharedListVector::push_back(string seqNames){
 /***********************************************************************/
 
 void SharedListVector::push_back(string seqNames){
@@ -237,6 +343,8 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){
 /***********************************************************************/
 SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
        try {
 /***********************************************************************/
 SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
        try {
+        m->currentSharedBinLabels = binLabels;
+        
                SharedRAbundVector rav(data.size());
                
                for(int i=0;i<numBins;i++){
                SharedRAbundVector rav(data.size());
                
                for(int i=0;i<numBins;i++){
@@ -272,6 +380,8 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
 /***********************************************************************/
 vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
        try {
 /***********************************************************************/
 vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
        try {
+        m->currentSharedBinLabels = binLabels;
+        
                SharedUtil* util;
                util = new SharedUtil();
                vector<SharedRAbundVector*> lookup;  //contains just the groups the user selected
                SharedUtil* util;
                util = new SharedUtil();
                vector<SharedRAbundVector*> lookup;  //contains just the groups the user selected
index 81779257346d4b25dbecf092a6c730162d7d4991..13fed9791fb347806f33723893aacd15eb535690 100644 (file)
@@ -33,7 +33,7 @@ public:
        SharedListVector();
        SharedListVector(int);
        SharedListVector(ifstream&);
        SharedListVector();
        SharedListVector(int);
        SharedListVector(ifstream&);
-       SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){ groupmap = NULL; countTable = NULL; };
+       SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs), binLabels(lv.binLabels) { groupmap = NULL; countTable = NULL; };
        ~SharedListVector(){ if (groupmap != NULL) { delete groupmap; } if (countTable != NULL) { delete countTable; } };
        
        int getNumBins()                                                        {       return numBins;         }
        ~SharedListVector(){ if (groupmap != NULL) { delete groupmap; } if (countTable != NULL) { delete countTable; } };
        
        int getNumBins()                                                        {       return numBins;         }
@@ -42,6 +42,8 @@ public:
 
        void set(int, string);  
        string get(int);
 
        void set(int, string);  
        string get(int);
+    vector<string> getLabels();
+    void setLabels(vector<string>);
        void push_back(string);
        void resize(int);
        void clear();
        void push_back(string);
        void resize(int);
        void clear();
@@ -63,6 +65,7 @@ private:
        int maxRank;
        int numBins;
        int numSeqs;
        int maxRank;
        int numBins;
        int numSeqs;
+    vector<string> binLabels;
 
 };
 
 
 };
 
index 5231b3cd654ff6f1321bbc12f2cf4fe602a30553..80b8fb9bd45a8596e91afe30fdec3984b2411de6 100644 (file)
@@ -55,13 +55,13 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                                
                                //parse labels to save
                                istringstream iStringStream(label);
                                
                                //parse labels to save
                                istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
+                               m->sharedBinLabelsInFile.clear();
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                                        
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                                        
-                                       m->binLabelsInFile.push_back(temp);
+                                       m->sharedBinLabelsInFile.push_back(temp);
                                }
                                
                                f >> label;
                                }
                                
                                f >> label;
@@ -69,7 +69,7 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                }else { label = m->saveNextLabel; }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
                }else { label = m->saveNextLabel; }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
+               m->currentSharedBinLabels = m->sharedBinLabelsInFile;
                
                //read in first row since you know there is at least 1 group.
                f >> groupN >> num;
                
                //read in first row since you know there is at least 1 group.
                f >> groupN >> num;
index 71c868b158ab41c2b8d72e7dac301998e2c39537..9eeb0f21bf3626620806c49372ab36efd0ff0831 100644 (file)
@@ -62,13 +62,13 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma
                                
                                //parse labels to save
                                istringstream iStringStream(label);
                                
                                //parse labels to save
                                istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
+                               m->sharedBinLabelsInFile.clear();
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                     
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                     
-                                       m->binLabelsInFile.push_back(temp);
+                                       m->sharedBinLabelsInFile.push_back(temp);
                                }
                                
                                f >> label >> groupN >> num;
                                }
                                
                                f >> label >> groupN >> num;
@@ -78,7 +78,7 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma
                 
                 //make binlabels because we don't have any
                 string snumBins = toString(num);
                 
                 //make binlabels because we don't have any
                 string snumBins = toString(num);
-                m->binLabelsInFile.clear();
+                m->sharedBinLabelsInFile.clear();
                 for (int i = 0; i < num; i++) {  
                     //if there is a bin label use it otherwise make one
                     string binLabel = "Otu";
                 for (int i = 0; i < num; i++) {  
                     //if there is a bin label use it otherwise make one
                     string binLabel = "Otu";
@@ -88,7 +88,7 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma
                         for (int h = 0; h < diff; h++) { binLabel += "0"; }
                     }
                     binLabel += sbinNumber;
                         for (int h = 0; h < diff; h++) { binLabel += "0"; }
                     }
                     binLabel += sbinNumber;
-                    m->binLabelsInFile.push_back(binLabel);
+                    m->sharedBinLabelsInFile.push_back(binLabel);
                 }
             }
                }else { 
                 }
             }
                }else { 
@@ -99,7 +99,7 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma
         }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
         }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
+               m->currentSharedBinLabels = m->sharedBinLabelsInFile;
                
                holdLabel = label;
                
                
                holdLabel = label;
                
@@ -295,7 +295,7 @@ void SharedRAbundFloatVector::printHeaders(ostream& output){
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                output << binLabel << '\t'; 
                        }
                                
                                output << binLabel << '\t'; 
                        }
@@ -310,7 +310,7 @@ void SharedRAbundFloatVector::printHeaders(ostream& output){
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                output << binLabel << '\t'; 
                        }
                                
                                output << binLabel << '\t'; 
                        }
@@ -318,7 +318,7 @@ void SharedRAbundFloatVector::printHeaders(ostream& output){
                        output << endl;
                }
                
                        output << endl;
                }
                
-               m->printedHeaders = true;
+               m->printedSharedHeaders = true;
        }
        catch(exception& e) {
                m->errorOut(e, "SharedRAbundVector", "printHeaders");
        }
        catch(exception& e) {
                m->errorOut(e, "SharedRAbundVector", "printHeaders");
@@ -550,7 +550,7 @@ int SharedRAbundFloatVector::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                newBinLabels.push_back(binLabel);
                        }
                                
                                newBinLabels.push_back(binLabel);
                        }
@@ -559,7 +559,7 @@ int SharedRAbundFloatVector::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
                for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                
                thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
+               m->currentSharedBinLabels = newBinLabels;
                
                return 0;
                
                
                return 0;
                
index 9b2bb678ca7688777aa87a9f60015baba5d336d9..0f2e48e8ac7bbdc18b10f15f1b764aed7ee58890 100644 (file)
@@ -86,13 +86,13 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                                
                                //parse labels to save
                                istringstream iStringStream(label);
                                
                                //parse labels to save
                                istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
+                               m->sharedBinLabelsInFile.clear();
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                
                                while(!iStringStream.eof()){
                                        if (m->control_pressed) { break; }
                                        string temp;
                                        iStringStream >> temp;  m->gobble(iStringStream);
                
-                                       m->binLabelsInFile.push_back(temp);
+                                       m->sharedBinLabelsInFile.push_back(temp);
                                }
                                
                                f >> label >> groupN >> num;
                                }
                                
                                f >> label >> groupN >> num;
@@ -102,7 +102,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                 
                 //make binlabels because we don't have any
                 string snumBins = toString(num);
                 
                 //make binlabels because we don't have any
                 string snumBins = toString(num);
-                m->binLabelsInFile.clear();
+                m->sharedBinLabelsInFile.clear();
                 for (int i = 0; i < num; i++) {  
                     //if there is a bin label use it otherwise make one
                     string binLabel = "Otu";
                 for (int i = 0; i < num; i++) {  
                     //if there is a bin label use it otherwise make one
                     string binLabel = "Otu";
@@ -112,7 +112,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                         for (int h = 0; h < diff; h++) { binLabel += "0"; }
                     }
                     binLabel += sbinNumber;
                         for (int h = 0; h < diff; h++) { binLabel += "0"; }
                     }
                     binLabel += sbinNumber;
-                    m->binLabelsInFile.push_back(binLabel);
+                    m->sharedBinLabelsInFile.push_back(binLabel);
                 }
             }
                }else { 
                 }
             }
                }else { 
@@ -125,7 +125,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
         }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
         }
                
                //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
+               m->currentSharedBinLabels = m->sharedBinLabelsInFile;
                
                holdLabel = label;
                
                
                holdLabel = label;
                
@@ -385,7 +385,7 @@ void SharedRAbundVector::printHeaders(ostream& output){
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                output << binLabel << '\t'; 
                        }
                                
                                output << binLabel << '\t'; 
                        }
@@ -400,14 +400,14 @@ void SharedRAbundVector::printHeaders(ostream& output){
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                output << binLabel << '\t'; 
                        }
                        
                        output << endl;
                }
                                
                                output << binLabel << '\t'; 
                        }
                        
                        output << endl;
                }
-               m->printedHeaders = true;
+               m->printedSharedHeaders = true;
        }
        catch(exception& e) {
                m->errorOut(e, "SharedRAbundVector", "printHeaders");
        }
        catch(exception& e) {
                m->errorOut(e, "SharedRAbundVector", "printHeaders");
@@ -533,7 +533,7 @@ int SharedRAbundVector::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislooku
                                                for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                        }
                                        binLabel += sbinNumber; 
                                                for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                        }
                                        binLabel += sbinNumber; 
-                                       if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                                       if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                        
                                        newBinLabels.push_back(binLabel);
                                }
                                        
                                        newBinLabels.push_back(binLabel);
                                }
@@ -542,7 +542,7 @@ int SharedRAbundVector::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislooku
                        for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                        
                        thislookup = newLookup;
                        for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
                        
                        thislookup = newLookup;
-                       m->currentBinLabels = newBinLabels;
+                       m->currentSharedBinLabels = newBinLabels;
                        
                        return 0;
                        
                        
                        return 0;
                        
index b53b09afc0091e91baf6609aa9c8d5b0ab528b63..204b61c64d779ebe2946d537e5803d9ed36d3d76 100644 (file)
@@ -57,7 +57,7 @@ EstOutput SharedSobsCS::getValues(vector<SharedRAbundVector*> shared, vector<str
                        }
                        
                        //they are shared
                        }
                        
                        //they are shared
-                       if (sharedByAll == true) {  observed++;  labels.push_back(m->currentBinLabels[i]); }
+                       if (sharedByAll == true) {  observed++;  labels.push_back(m->currentSharedBinLabels[i]); }
                }
         
                data[0] = observed;
                }
         
                data[0] = observed;
index a7f5d78ad37c4c515821fd4686fb769d74ecd68f..4c9049a8ebf6247a5be965f21317aba881e82e51 100644 (file)
@@ -317,7 +317,7 @@ int SparccCommand::process(vector<SharedRAbundVector*>& lookup){
         cout.setf(ios::showpoint);
         
         vector<vector<float> > sharedVector;
         cout.setf(ios::showpoint);
         
         vector<vector<float> > sharedVector;
-        vector<string> otuNames = m->currentBinLabels;
+        vector<string> otuNames = m->currentSharedBinLabels;
         
         //fill sharedVector to pass to CalcSparcc
         for (int i = 0; i < lookup.size(); i++) {
         
         //fill sharedVector to pass to CalcSparcc
         for (int i = 0; i < lookup.size(); i++) {
index 392f97bd51f1d2ac67d6d0a810a408ab507fdcee..2eb1d497494849e316b58103f84a2c95a475a832 100644 (file)
@@ -108,7 +108,7 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
        try {
                
                //save mothurOut's binLabels to restore for next label
        try {
                
                //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
+               vector<string> saveBinLabels = m->currentSharedBinLabels;
                
                int numBins = thislookup[0]->getNumBins();
                for (int i = 0; i < thislookup.size(); i++) {           
                
                int numBins = thislookup[0]->getNumBins();
                for (int i = 0; i < thislookup.size(); i++) {           
@@ -136,7 +136,7 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
                                
                                for (int j = 0; j < size; j++) {
                                        
                                
                                for (int j = 0; j < size; j++) {
                                        
-                                       if (m->control_pressed) {  return m->currentBinLabels; }
+                                       if (m->control_pressed) {  return m->currentSharedBinLabels; }
                                        
                                        int bin = order.get(j);
                                        
                                        
                                        int bin = order.get(j);
                                        
@@ -149,11 +149,11 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
                //subsampling may have created some otus with no sequences in them
                eliminateZeroOTUS(thislookup);
         
                //subsampling may have created some otus with no sequences in them
                eliminateZeroOTUS(thislookup);
         
-               if (m->control_pressed) { return m->currentBinLabels; }
+               if (m->control_pressed) { return m->currentSharedBinLabels; }
                
                //save mothurOut's binLabels to restore for next label
                
                //save mothurOut's binLabels to restore for next label
-        vector<string> subsampleBinLabels = m->currentBinLabels;
-               m->currentBinLabels = saveBinLabels;
+        vector<string> subsampleBinLabels = m->currentSharedBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
                
                return subsampleBinLabels;
                
                
                return subsampleBinLabels;
                
@@ -200,7 +200,7 @@ int SubSample::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
                                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
                                }
                                binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
+                               if (i < m->currentSharedBinLabels.size()) {  binLabel = m->currentSharedBinLabels[i]; }
                                
                                newBinLabels.push_back(binLabel);
                        }
                                
                                newBinLabels.push_back(binLabel);
                        }
@@ -210,7 +210,7 @@ int SubSample::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
                thislookup.clear();
                
                thislookup = newLookup;
                thislookup.clear();
                
                thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
+               m->currentSharedBinLabels = newBinLabels;
                
                return 0;
                
                
                return 0;
                
index 6c0d1bcbe71a3c3c2a7fccda9695f7aef6aec25b..a89d191a9127065922c3d498edce5cab41030f27 100644 (file)
@@ -947,7 +947,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
        try {
                
                //save mothurOut's binLabels to restore for next label
        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);  }
                
                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->openOutputFile(outputFileName, out);
                outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
                
-        m->currentBinLabels = subsampledLabels;
+        m->currentSharedBinLabels = subsampledLabels;
         
                thislookup[0]->printHeaders(out);
                
         
                thislookup[0]->printHeaders(out);
                
@@ -977,7 +977,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
         
         
         //save mothurOut's binLabels to restore for next label
         
         
         //save mothurOut's binLabels to restore for next label
-               m->currentBinLabels = saveBinLabels;
+               m->currentSharedBinLabels = saveBinLabels;
                
                return 0;
                
                
                return 0;