]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedrabundfloatvector.cpp
added headers to shared and relabund files
[mothur.git] / sharedrabundfloatvector.cpp
index 6c2dea195fdea527678277633ad08f9fbe4fc795..e7ab22565431d61a34d875322663ac107c9e21af 100644 (file)
@@ -44,8 +44,17 @@ SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), ma
                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
                lookup.clear();
                
-               if (m->saveNextLabel == "") {  f >> label;  }
-               else { label = m->saveNextLabel; }
+               //are we at the beginning of the file??
+               if (m->saveNextLabel == "") {  
+                       f >> label; 
+                       
+                       //is this a shared file that has headers
+                       if (label == "label") { 
+                               //eat rest of line
+                               label = m->getline(f); m->gobble(f);
+                               f >> label;
+                       }
+               }else { label = m->saveNextLabel; }
                
                //read in first row since you know there is at least 1 group.
                f >> groupN >> num;
@@ -218,6 +227,24 @@ int SharedRAbundFloatVector::size(){
        return data.size();
 }
 /***********************************************************************/
+void SharedRAbundFloatVector::printHeaders(ostream& output){
+       try {
+               output << "label\tGroup\tnumOtus\t";
+               if (m->sharedHeaderMode == "tax") {
+                       for (int i = 0; i < numBins; i++) {  output << "PhyloType" << (i+1) << '\t'; }
+                       output << endl;
+               }else {
+                       for (int i = 0; i < numBins; i++) {  output << "Otu" << (i+1) << '\t'; }
+                       output << endl;
+               }
+               m->printedHeaders = true;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedRAbundVector", "printHeaders");
+               exit(1);
+       }
+}
+/***********************************************************************/
 void SharedRAbundFloatVector::print(ostream& output){
        try {
                output << numBins << '\t';