try{
globaldata = GlobalData::getInstance();
- if(globaldata->getSparseMatrix() != NULL) { matrix = new SparseMatrix(*globaldata->getSparseMatrix()); }
+ if(globaldata->gSparseMatrix != NULL) { matrix = new SparseMatrix(*globaldata->gSparseMatrix); }
// Not sure if we want the address or an entire new memory allocation. Might be nice to have new memory so data
// doesn't need to be re-read, but then again, it could suck up a ton of memory. Dunno.
// if(globaldata->getSparseMatrix() != NULL) { matrix = globaldata->getSparseMatrix(); }
- if(globaldata->getListVector() != NULL){
- list = new ListVector(*globaldata->getListVector());
+ if(globaldata->gListVector != NULL){
+ list = new ListVector(*globaldata->gListVector);
rabund = new RAbundVector(list->getRAbundVector());
//rabund->print(cout);
}
}
//delete globaldata's copy of the sparsematrix and listvector to free up memory
- SparseMatrix* clearM = NULL;
- globaldata->setSparseMatrix(clearM);
- ListVector* clearL = NULL;
- globaldata->setListVector(clearL);
-
+ delete globaldata->gSparseMatrix; globaldata->gSparseMatrix = NULL;
+ delete globaldata->gListVector; globaldata->gListVector = NULL;
//saves .list file so you can do the collect, rarefaction and summary commands without doing a read.list
if (globaldata->getFormat() == "phylip") { globaldata->setPhylipFile(""); }
}
//are you trying to cluster before you have read something
- if (((commandName == "cluster") && (globaldata->getSparseMatrix() == NULL)) ||
- ((commandName == "cluster") && (globaldata->getListVector() == NULL))) {
+ if (((commandName == "cluster") && (globaldata->gSparseMatrix == NULL)) ||
+ ((commandName == "cluster") && (globaldata->gListVector == NULL))) {
cout << "Before you use the cluster command, you first need to read in a distance matrix." << endl;
errorFree = false;
}
}
/*******************************************************/
-/******************************************************/
-
-ListVector* GlobalData::getListVector() { return gListVector; }
-/*******************************************************/
-
-/******************************************************/
-void GlobalData::setListVector(ListVector* lv){
- try {
- if(gListVector != NULL){ delete gListVector; }
- gListVector = new ListVector(*lv);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function setListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function setListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/*******************************************************/
-
-/******************************************************/
-
-SparseMatrix* GlobalData::getSparseMatrix() { return gSparseMatrix; }
-/*******************************************************/
-
-/******************************************************/
-void GlobalData::setSparseMatrix(SparseMatrix* sm){
- try{
- if(gSparseMatrix != NULL){ delete gSparseMatrix; }
- gSparseMatrix = new SparseMatrix(*sm);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function setSparseMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function setSparseMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/*******************************************************/
-
/******************************************************/
//This function parses through the option string of the command to remove its parameters
void GlobalData::parseGlobalData(string commandString, string optionText){
class GlobalData {
public:
static GlobalData* getInstance();
- ListVector* getListVector();
- SparseMatrix* getSparseMatrix();
+ ListVector* gListVector;
+ SparseMatrix* gSparseMatrix;
InputData* ginput;
OrderVector* gorder;
ListVector* glist;
void setGroups(string);
void setCalc(string);
-
- void setListVector(ListVector*);
- void setSparseMatrix(SparseMatrix*);
void clear();
void clearLabels();
void clearAbund();
void operator=( const GlobalData& ); // Disable assignment operator
GlobalData();
~GlobalData();
- ListVector* gListVector;
- SparseMatrix* gSparseMatrix;
void reset(); //clears all non filename parameters
globaldata->gMatrix = matrix; //save matrix for coverage commands
}else {
read->read(nameMap);
- globaldata->setListVector(read->getListVector());
- globaldata->setSparseMatrix(read->getMatrix());
+ globaldata->gListVector = read->getListVector();
+ globaldata->gSparseMatrix = read->getMatrix();
}
return 0;
}