]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedlistvector.cpp
fixing minor bugs
[mothur.git] / sharedlistvector.cpp
index 2bceace2565f404a08b85e5af59cf18e295bd41a..4774180dd6032c0de1b87597360af6d14e7c2a2d 100644 (file)
@@ -7,43 +7,41 @@
  *
  */
 
-
-using namespace std;
-
-#include <map>
-#include <exception>
 #include "sabundvector.hpp"
 #include "rabundvector.hpp"
 #include "ordervector.hpp"
-#include "datavector.hpp"
-#include "utilities.hpp"
 #include "sharedlistvector.h"
 #include "sharedordervector.h"
+#include "sharedutilities.h"
+
+/***********************************************************************/
 
+SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();}
 
 /***********************************************************************/
 
-SharedListVector::SharedListVector(int n):     DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){};
+SharedListVector::SharedListVector(int n):     DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();}
 
 /***********************************************************************/
 SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
                globaldata = GlobalData::getInstance();
-               
+
                //set up groupmap for later.
                groupmap = new GroupMap(globaldata->getGroupFile());
                groupmap->readMap();
 
                int hold;
+               string inputData;
                f >> label >> hold;
        
                data.assign(hold, "");
-               string inputData = "";
        
                for(int i=0;i<hold;i++){
                        f >> inputData;
                        set(i, inputData);
                }
+       
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -232,7 +230,10 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){
                        groupName = groupmap->getGroup(names);
                        order->push_back(i, binSize, groupName);
                }
+
                random_shuffle(order->begin(), order->end());
+               order->updateStats();
+               
                return order;
        }
        catch(exception& e) {
@@ -271,6 +272,7 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
                
                rav.setLabel(label);
                rav.setGroup(groupName);
+
                return rav;
                
        }
@@ -283,6 +285,35 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
                exit(1);
        }
 }
+/***********************************************************************/
+vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
+       try {
+               SharedUtil* util;
+               util = new SharedUtil();
+               vector<SharedRAbundVector*> lookup;
+               
+               util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
+               
+               delete util;
+
+               for (int i = 0; i < globaldata->Groups.size(); i++) {
+                       SharedRAbundVector* temp = new SharedRAbundVector();
+                       *temp = getSharedRAbundVector(globaldata->Groups[i]);
+                       lookup.push_back(temp);
+               }
+
+               return lookup;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       
+}
 
 /***********************************************************************/
 SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {