]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed memory leak of groupmap in reads
authorwestcott <westcott>
Thu, 19 Mar 2009 17:04:49 +0000 (17:04 +0000)
committerwestcott <westcott>
Thu, 19 Mar 2009 17:04:49 +0000 (17:04 +0000)
errorchecking.cpp
fullmatrix.cpp
libshuffcommand.cpp
parselistcommand.cpp
progress.cpp
readdistcommand.cpp
readmatrix.cpp
readotucommand.cpp

index 5f587a9b83a1a140409fc0cbdfa4bba0169ea518..9a0846214bb97a9f4cce7fa42540b0e4a642dda0 100644 (file)
@@ -171,8 +171,8 @@ bool ErrorCheck::checkInput(string input) {
                                errorFree = false;
                } 
                
-               if ((commandName == "libshuff") && (globaldata->gMatrix == NULL)) {
-                        cout << "You must read in a matrix before you use the libshuff command. " << endl; return false; 
+               if ((commandName == "libshuff") && ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL))) {
+                        cout << "You must read in a matrix and groupfile before you use the libshuff command. " << endl; return false; 
                }
                
                if (commandName == "parsimony") {
index 8eb48139a85c910e74881c15a050b8064c39dfbd..f4acd78c1132022b9bc22a6c878febe5a4df8c1c 100644 (file)
@@ -75,7 +75,7 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) {
        try {
        
                Progress* reading;
-               reading = new Progress("Reading matrix:    ", numSeqs * numSeqs);
+               reading = new Progress("Reading matrix:     ", numSeqs * numSeqs);
                
                int count = 0;
                
@@ -114,7 +114,7 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) {
 void FullMatrix::readLTMatrix(ifstream& filehandle) {
        try {
                Progress* reading;
-               reading = new Progress("Reading matrix:    ", numSeqs * (numSeqs - 1) / 2);
+               reading = new Progress("Reading matrix:     ", numSeqs * (numSeqs - 1) / 2);
                
                int count = 0;
                float distance;
index 2ed7ee5089691c5bf02e3e39589b2dc04cc5426f..9ab9108f23ca4d63c3479bb8c6a27d27e08704ea 100644 (file)
@@ -72,6 +72,8 @@ int LibShuffCommand::execute(){
        try {
                //deltaValues[0] = scores for the difference between AA and AB.
                //cValues[0][0][0] = AA at distance 0.0, cValues[0][0][1] = AB at distance 0.0, cValues[0][0][2] = AC at distance 0.0, cValues[0][1][0] = BA at distance 0.0, cValues[0][1][1] = BB...
+               Progress* reading;
+               reading = new Progress("Comparing to random:", iters);
                
                sumDelta.resize(numComp-numGroups, 0.0);
                
@@ -153,6 +155,7 @@ int LibShuffCommand::execute(){
                        }
 //cout << "iter " << m << endl;
                        //clear out old Values
+                       reading->update(m);
                        cValues.clear();
                        
 //cout << "random sum delta for iter " << m << endl;
@@ -163,6 +166,8 @@ int LibShuffCommand::execute(){
 
                }
                
+               reading->finish();
+               delete reading;
                                
                /**********************************************************/
                //find the signifigance of the user matrix' sumdelta values
index d9925ad40ecd02cc1580e7d087b6b5acb3514831..73fb56593c781bcd0cee4e432318fd9ba82b1577 100644 (file)
@@ -135,6 +135,7 @@ int ParseListCommand::execute(){
                        }
                        
                        //set groupmap for .shared commands
+                       if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; }
                        globaldata->gGroupmap = groupMap; 
                        
                        return 0;
index eec8f09c150efbd947511b898751b87e06d4d68f..9f3327fc4446beefd1d1a0d7165831f32e48a6d6 100644 (file)
@@ -20,7 +20,7 @@ const char marker = '|';
 
 Progress::Progress(string job, int end){
        try {
-               cout << "*******************#****#****#****#****#****#****#****#****#****#****#\n";
+               cout << "********************#****#****#****#****#****#****#****#****#****#****#\n";
                cout << job << marker;
                cout.flush();
        
@@ -72,7 +72,7 @@ void Progress::finish(){
        
        
                cout << endl;
-               cout << "**********************************************************************\n";
+               cout << "***********************************************************************\n";
                cout.flush();
        }
        catch(exception& e) {
index a9d772183d253168e96d48aa6d979c94616bde0d..6d38f4e4d55cde380570dd53aaa847f96600550f 100644 (file)
@@ -21,6 +21,7 @@ ReadDistCommand::ReadDistCommand(){
                else if (format == "matrix") { 
                                groupMap = new GroupMap(globaldata->getGroupFile());
                                groupMap->readMap();
+                               if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap;  }
                                globaldata->gGroupmap = groupMap;
                }
                
index 2d981243518004bccb81a0779762b824cf20f4c7..9a98d5c393390104abfacffde8ceae948d277ac3 100644 (file)
@@ -69,7 +69,7 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
        
                        if(square == 0){
 
-                               reading = new Progress("Reading matrix:    ", nseqs * (nseqs - 1) / 2);
+                               reading = new Progress("Reading matrix:     ", nseqs * (nseqs - 1) / 2);
                
                                int     index = 0;
                
@@ -111,7 +111,7 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
                        }
                        else{
 
-                               reading = new Progress("Reading matrix:    ", nseqs * nseqs);
+                               reading = new Progress("Reading matrix:     ", nseqs * nseqs);
                        
                                int index = nseqs;
                
@@ -202,7 +202,7 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){
 
                        list = new ListVector(nameMap->getListVector());
                
-                       Progress* reading = new Progress("Reading matrix:    ", nseqs * nseqs);
+                       Progress* reading = new Progress("Reading matrix:     ", nseqs * nseqs);
        
                        int lt = 1;
                        int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose
index eeb8cd6e3d910d30e7fde7b6d20947a693d739ed..2a0d33fe352b8e6f4621fd5d336b63ccfb5824b4 100644 (file)
@@ -43,6 +43,8 @@ int ReadOtuCommand::execute(){
                read->read(&*globaldata); 
                if (globaldata->getFormat() == "shared") {
                        groupMap->readMap();
+                       
+                       if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap;  }
                        globaldata->gGroupmap = groupMap;
                
                        shared = new SharedCommand();