]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedlistvector.cpp
added smart distance feature and optimized all commands using line by line processing
[mothur.git] / sharedlistvector.cpp
index 62e37885d165c0abcd800f189c656664acb3f63b..2dc4502cd4523a3b679abcc3d3e3156ea60b0ab9 100644 (file)
 
 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"
 
 /***********************************************************************/
 
@@ -32,21 +30,22 @@ SharedListVector::SharedListVector(int n):  DataVector(), data(n, "") , maxRank(0
 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";
@@ -235,7 +234,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) {
@@ -286,6 +288,33 @@ 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);
+
+               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) {