*
*/
-
-using namespace std;
-
-
#include "sabundvector.hpp"
#include "rabundvector.hpp"
#include "ordervector.hpp"
/***********************************************************************/
-SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){};
+SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance(); groupmap = NULL; }
/***********************************************************************/
-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(); groupmap = NULL; }
/***********************************************************************/
SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
}
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";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "SharedListVector");
exit(1);
}
}
numSeqs += (nNames_new - nNames_old);
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "set");
exit(1);
}
}
numSeqs += nNames;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "push_back");
exit(1);
}
}
output << endl;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "print");
exit(1);
}
}
return rav;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "getRAbundVector");
exit(1);
}
}
return sav;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "getSAbundVector");
exit(1);
}
}
}
random_shuffle(order->begin(), order->end());
+ order->updateStats();
+
return order;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "getSharedOrderVector");
exit(1);
}
-
}
/***********************************************************************/
SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
rav.setLabel(label);
rav.setGroup(groupName);
+
return rav;
}
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";
+ errorOut(e, "SharedListVector", "getSharedRAbundVector");
exit(1);
}
}
SharedUtil* util;
util = new SharedUtil();
vector<SharedRAbundVector*> lookup;
+ map<string, SharedRAbundVector*> finder;
+ string group, names, name;
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);
+ SharedRAbundVector* temp = new SharedRAbundVector(data.size());
+ finder[globaldata->Groups[i]] = temp;
+ finder[globaldata->Groups[i]]->setLabel(label);
+ finder[globaldata->Groups[i]]->setGroup(globaldata->Groups[i]);
+ //*temp = getSharedRAbundVector(globaldata->Groups[i]);
+ lookup.push_back(finder[globaldata->Groups[i]]);
}
-
+
+ //fill vectors
+ for(int i=0;i<numBins;i++){
+ names = get(i);
+ while (names.find_first_of(',') != -1) {
+ name = names.substr(0,names.find_first_of(','));
+ names = names.substr(names.find_first_of(',')+1, names.length());
+ group = groupmap->getGroup(name);
+ finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in
+ }
+
+ //get last name
+ group = groupmap->getGroup(names);
+ finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in
+
+ }
+
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";
+ errorOut(e, "SharedListVector", "getSharedRAbundVector");
exit(1);
}
-
}
/***********************************************************************/
return sav;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "getSharedSAbundVector");
exit(1);
}
}
}
else{
if(orderMap->count(seqName) == 0){
- cerr << seqName << " not found, check *.names file\n";
+ mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
}
if(orderMap->count(seqName) == 0){
- cerr << seqName << " not found, check *.names file\n";
+ mothurOut(seqName + " not found, check *.names file\n");
exit(1);
}
ov.set((*orderMap)[seqName], i);
}
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SharedListVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "SharedListVector", "getOrderVector");
exit(1);
}
}