]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed memory issue with cluster command
authorwestcott <westcott>
Mon, 9 Mar 2009 12:18:46 +0000 (12:18 +0000)
committerwestcott <westcott>
Mon, 9 Mar 2009 12:18:46 +0000 (12:18 +0000)
clustercommand.cpp
errorchecking.cpp
globaldata.cpp
globaldata.hpp
readdistcommand.cpp

index f0ef51f05b846797a42c8e71cacce326db06f4bb..307b774b4ad36b364c92c0152310f560dee1089d 100644 (file)
@@ -15,13 +15,13 @@ ClusterCommand::ClusterCommand(){
        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);
                }
@@ -108,11 +108,8 @@ int ClusterCommand::execute(){
                }
                
                //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(""); }
index b76542aec7907c0cc3ef80b896c5308985c1c73d..d827929fd94290dbfb302d0fe36e76f4982874a0 100644 (file)
@@ -367,8 +367,8 @@ bool ErrorCheck::checkInput(string input) {
                }
                
                //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;
                } 
index b1ac4e87b986cee6380c997c6c40590b089067f7..60a106a17eb6ce31e75b51a088bb2261e1815361 100644 (file)
@@ -16,50 +16,6 @@ GlobalData* GlobalData::getInstance() {
 }
 /*******************************************************/
 
-/******************************************************/
-
-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){
index 0dc4c348584989f101567c229c8246158f5ca70c..6070dd7b2cdd6122b78c5833359ce487497fd0e3 100644 (file)
@@ -21,8 +21,8 @@ class SAbundVector;
 class GlobalData {
 public:
        static GlobalData* getInstance();
-       ListVector* getListVector();
-       SparseMatrix* getSparseMatrix();
+       ListVector* gListVector;
+       SparseMatrix* gSparseMatrix;
        InputData* ginput;
        OrderVector* gorder;
        ListVector* glist;
@@ -72,9 +72,6 @@ public:
        void setGroups(string);
        void setCalc(string);
 
-       
-       void setListVector(ListVector*);
-       void setSparseMatrix(SparseMatrix*);
        void clear(); 
        void clearLabels();
        void clearAbund();
@@ -90,8 +87,6 @@ private:
        void operator=( const GlobalData& ); // Disable assignment operator
        GlobalData();
        ~GlobalData();
-       ListVector* gListVector;
-       SparseMatrix* gSparseMatrix;
        void reset();   //clears all non filename parameters
        
        
index 116e670a6e36f20df403cabf0610f7d60b4bbb5a..a9d772183d253168e96d48aa6d979c94616bde0d 100644 (file)
@@ -72,8 +72,8 @@ int ReadDistCommand::execute(){
                        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;
        }