]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed some bugs
authorwestcott <westcott>
Thu, 18 Jun 2009 16:05:46 +0000 (16:05 +0000)
committerwestcott <westcott>
Thu, 18 Jun 2009 16:05:46 +0000 (16:05 +0000)
70 files changed:
aligncommand.cpp
alignment.cpp
alignment.hpp
binsequencecommand.cpp
blastalign.cpp
blastdb.cpp
blastdb.hpp
bootstrapsharedcommand.cpp
calculator.h
clustercommand.cpp
collectcommand.cpp
collectsharedcommand.cpp
command.hpp
database.cpp
database.hpp
datavector.hpp
deconvolutecommand.cpp
display.h
dist.h
distancecommand.cpp
distancedb.cpp
distancedb.hpp
engine.cpp
fileoutput.h
filterseqscommand.cpp
getgroupcommand.cpp
getlabelcommand.cpp
getlinecommand.cpp
getoturepcommand.cpp
getrabundcommand.cpp
getsabundcommand.cpp
globaldata.cpp
globaldata.hpp
gotohoverlap.hpp
heatmapcommand.cpp
heatmapsimcommand.cpp
inputdata.cpp
kmerdb.cpp
kmerdb.hpp
libshuffcommand.cpp
matrixoutputcommand.cpp
mergefilecommand.cpp
observable.h
parselistcommand.cpp
rarefactcommand.cpp
rarefactsharedcommand.cpp
readcolumn.cpp
readdistcommand.cpp
readmatrix.hpp
readotu.cpp
readotu.h
readphylip.cpp
readtree.cpp
readtree.h
readtreecommand.cpp
screenseqscommand.cpp
seqsummarycommand.cpp
shen.cpp
suffixdb.cpp
suffixdb.hpp
suffixnodes.hpp
suffixtree.cpp
suffixtree.hpp
summarycommand.cpp
summarysharedcommand.cpp
tree.cpp
treecalculator.h
treegroupscommand.cpp
trimseqscommand.cpp
venncommand.cpp

index ccfd9bbec751e3000afd318d063a094c9745ec4a..064189b1423434f24e88fb05df3ad67a7ea4967f 100644 (file)
@@ -104,9 +104,13 @@ AlignCommand::AlignCommand(string option){
 
 //**********************************************************************************************************************
 
-AlignCommand::~AlignCommand(){                 
-       delete templateDB;
-       delete alignment;
+AlignCommand::~AlignCommand(){ 
+
+       if (abort == false) {
+               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
+               delete templateDB;
+               delete alignment;
+       }
 }
 
 //**********************************************************************************************************************
@@ -178,6 +182,7 @@ int AlignCommand::execute(){
                        lines.push_back(new linePair(0, numFastaSeqs));
                        
                        driver(lines[0], alignFileName, reportFileName);
+                       
                }
                else{
                        vector<int> positions;
@@ -216,6 +221,7 @@ int AlignCommand::execute(){
                                appendReportFiles((reportFileName + toString(processIDS[i]) + ".temp"), reportFileName);
                                remove((reportFileName + toString(processIDS[i]) + ".temp").c_str());
                        }
+                       
                }
 #else
                ifstream inFASTA;
@@ -262,7 +268,9 @@ int AlignCommand::driver(linePair* line, string alignFName, string reportFName){
                        Sequence* candidateSeq = new Sequence(inFASTA);
                        report.setCandidate(candidateSeq);
                        
-                       Sequence* templateSeq = templateDB->findClosestSequence(candidateSeq);
+                       Sequence temp = templateDB->findClosestSequence(candidateSeq);
+                       Sequence* templateSeq = &temp;
+                       
                        report.setTemplate(templateSeq);
                        report.setSearchParameters(search, templateDB->getSearchScore());
                        
index 95e9dc2b115888a9cd38353aeb67353c1fb71806..d64d8b20bb61d7a1718c5965a41729b0b6640255 100644 (file)
@@ -87,6 +87,23 @@ void Alignment::traceBack(){                 //      This traceback routine is used by the dynamic
        seqBend = seqB.length() - seqBend - 1;
 
 }
+/**************************************************************************************************/
+
+Alignment::~Alignment(){
+       try {
+               for (int i = 0; i < alignment.size(); i++) {
+                       for (int j = (alignment[i].size()-1); j >= 0; j--) {  alignment[i].pop_back();  }
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the Alignment class Function ~Alignment. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the Alignment class function ~Alignment. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
 
 /**************************************************************************************************/
 
index c033d62cbd8aa94d8ce6b7bc0b429015fd5c3d50..215e4b32f77e1fc21df19ffd61b493b84d89acc6 100644 (file)
@@ -23,6 +23,7 @@ class Alignment {
 public:
        Alignment(int);
        Alignment();
+       virtual ~Alignment();
        virtual void align(string, string) = 0;
        
 //     float getAlignmentScore();
index abe000fbe4ed191b13389420899389e17bcc7cd4..1627b42d7bec5090a708c77d7491b93fa3bc7cdd 100644 (file)
@@ -44,11 +44,6 @@ BinSeqCommand::BinSeqCommand(string option){
                        fastafile = validParameter.validFile(parameters, "fasta", true);
                        if (fastafile == "not found") { cout << "fasta is a required parameter for the bin.seqs command." << endl; abort = true; }
                        else if (fastafile == "not open") { abort = true; }     
-                       else { 
-                               openInputFile(fastafile, in);
-                               fasta = new FastaMap();
-                       }
-               
                
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -82,10 +77,14 @@ BinSeqCommand::BinSeqCommand(string option){
                        groupfile = validParameter.validFile(parameters, "group", true);
                        if (groupfile == "not open") { abort = true; }
                        else if (groupfile == "not found") { groupfile = ""; }
-                       else {
-                               //read in group map info.
-                               groupMap = new GroupMap(groupfile);
-                               groupMap->readMap();
+                       
+                       if (abort == false) { 
+                               openInputFile(fastafile, in);
+                               fasta = new FastaMap();
+                               if (groupfile != "") {
+                                       groupMap = new GroupMap(groupfile);
+                                       groupMap->readMap();
+                               }
                        }
        
                }
@@ -130,17 +129,12 @@ void BinSeqCommand::help(){
 BinSeqCommand::~BinSeqCommand(){
        //made new in execute
        if (abort == false) {
-               delete input;
+               delete input;  globaldata->ginput = NULL;
                delete read;
-               delete list;
-       }
-       
-       //made new in constructor
-       delete fasta;
-       if (groupfile != "") {
-                       delete groupMap;
+               globaldata->gListVector = NULL;
+               delete fasta;
+               if (groupfile != "") {  delete groupMap;  globaldata->gGroupmap = NULL; }
        }
-
 }
 
 //**********************************************************************************************************************
@@ -155,6 +149,8 @@ int BinSeqCommand::execute(){
                //read fastafile
                fasta->readFastaFile(in);
                
+               in.close();
+               
                //set format to list so input can get listvector
 //             globaldata->setFormat("list");
                
index e4d5e8ac039d60f9f1352d6408121246f9d9864d..cb6abf97b8840aa32bfc4e9bf95315e30e4dbf10 100644 (file)
@@ -154,6 +154,7 @@ void BlastAlignment::setPairwiseSeqs(){     //      This method call assigns the blast ge
                seqAaln += 'Z';                                                 //      again need ot pad the sequences so that they extend to the length
                seqBaln += 'X';                                                 //      of the template sequence
        }
+       blastFile.close();
 }
 
 //**************************************************************************************************/
index 6f4ebcc1fa84028113e150c39e028e340ae86c26..e442fa229b49e08d5c7b80495d3c8a10d75d9430 100644 (file)
@@ -32,7 +32,7 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
        
        for(int i=0;i<numSeqs;i++){                                                                     //      generating a fasta file with unaligned template
                unalignedFastaFile << '>' << i << endl;                                 //      sequences, which will be input to formatdb
-               unalignedFastaFile << templateSequences[i]->getUnaligned() << endl;
+               unalignedFastaFile << templateSequences[i].getUnaligned() << endl;
        }
        unalignedFastaFile.close();
        
@@ -43,10 +43,10 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
        system(formatdbCommand.c_str());                                                                //      to get the right sequence names, i think. -p F
                                                                                                                                        //      option tells formatdb that seqs are DNA, not prot
        cout << "DONE." << endl << endl;        cout.flush();
-       emptySequence = new Sequence();
-       emptySequence->setName("no_match");
-       emptySequence->setUnaligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
-       emptySequence->setAligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+       emptySequence = Sequence();
+       emptySequence.setName("no_match");
+       emptySequence.setUnaligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+       emptySequence.setAligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
 
 
 }
@@ -54,6 +54,10 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
 /**************************************************************************************************/
 
 BlastDB::~BlastDB(){
+       //for (int i = 0; i < templateSequences.size(); i++) {  delete templateSequences[i];   }
+       //templateSequences.clear();
+       //delete emptySequence;
+       
        remove(queryFileName.c_str());                          //      let's clean stuff up and remove the temp files
        remove(dbFileName.c_str());                                     //      let's clean stuff up and remove the temp files
        remove(blastFileName.c_str());                          //      let's clean stuff up and remove the temp files
@@ -61,7 +65,7 @@ BlastDB::~BlastDB(){
 
 /**************************************************************************************************/
 
-Sequence* BlastDB::findClosestSequence(Sequence* candidate){
+Sequence BlastDB::findClosestSequence(Sequence* candidate){
 
        ofstream queryFile;
        openOutputFile(queryFileName, queryFile);
@@ -93,6 +97,7 @@ Sequence* BlastDB::findClosestSequence(Sequence* candidate){
                searchScore = 0.00;
                return emptySequence;
        }
+       m8FileHandle.close();
 }
 
 /**************************************************************************************************/
index dfb2a2ced94ae71623856930ee0c348802530acd..f0f17f9ce58bc8ee2b466cc9be6b95ddf53e207a 100644 (file)
@@ -18,7 +18,7 @@ class BlastDB : public Database {
 public:
        BlastDB(string, float, float, float, float);
        ~BlastDB();
-       Sequence* findClosestSequence(Sequence*);
+       Sequence findClosestSequence(Sequence*);
 
 private:
        string dbFileName;
@@ -30,7 +30,7 @@ private:
        float gapExtend;
        float match;
        float misMatch;
-       Sequence* emptySequence;
+       Sequence emptySequence;
        GlobalData* globaldata;
 };
 
index 5e7c0c63c8944d3be0ecc08b9761c334a74520b1..a94954ae6541e509723dd233ec235b7b384abb4e 100644 (file)
@@ -179,9 +179,10 @@ void BootSharedCommand::help(){
 BootSharedCommand::~BootSharedCommand(){
        //made new in execute
        if (abort == false) {
-               delete input;
+               delete input; globaldata->ginput = NULL;
                delete read;
                delete util;
+               globaldata->gorder = NULL;
        }
 }
 
index 8b21f7071a40df4a7202176d4132d3f2d6173adc..5dc081296748412a8e61e883d11ac60d70cfd864 100644 (file)
@@ -21,6 +21,7 @@ class Calculator {
 
 public:
        Calculator(){};
+       virtual ~Calculator(){};
        Calculator(string n, int c, bool m) : name(n), cols(c), multiple(m) {};
        virtual EstOutput getValues(SAbundVector*) = 0; 
        virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
index 4db95b45d00e3857513606383f05810f31a30ecd..eeba407eefc7bfb39a6bc60428a796f7bfb47068 100644 (file)
@@ -120,8 +120,10 @@ void ClusterCommand::help(){
 //**********************************************************************************************************************
 
 ClusterCommand::~ClusterCommand(){
-       delete cluster;
-       delete rabund;
+       if (abort == false) {
+               delete cluster;
+               delete rabund;
+       }
 }
 
 //**********************************************************************************************************************
@@ -177,6 +179,10 @@ int ClusterCommand::execute(){
                globaldata->setNameFile("");
                globaldata->setFormat("list");
                
+               sabundFile.close();
+               rabundFile.close();
+               listFile.close();
+               
                return 0;
        }
        catch(exception& e) {
index 2dd843f68f83d2eeec882253b8e50cda1ee9236b..c65080fd32022bcd9abb8d3cf10f73de8f181351 100644 (file)
@@ -195,11 +195,13 @@ void CollectCommand::help(){
 //**********************************************************************************************************************
 
 CollectCommand::~CollectCommand(){
-       delete order;
-       delete input;
-       delete cCurve;
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               //delete order;
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+               delete validCalculator;
+               globaldata->gorder = NULL;
+       }
 }
 
 //**********************************************************************************************************************
@@ -252,7 +254,7 @@ int CollectCommand::execute(){
                                userLabels.erase(lastOrder->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
+                       if (count != 1) { delete lastOrder;  }
                        lastOrder = order;                      
                        order = (input->getOrderVector());
                        count++;
index 6127c2d6da7717112fb2c7fdb5c82910f03f8323..86d5ffca4278cc8ce14f5ef9a1071d25cb850fab 100644 (file)
@@ -117,7 +117,7 @@ CollectSharedCommand::CollectSharedCommand(string option){
                        if (abort == false) {
                        
                                string fileNameRoot = getRootName(globaldata->inputFileName);
-//                             format = globaldata->getFormat();
+                               format = globaldata->getFormat();
                                int i;
                                
                                validCalculator = new ValidCalculators();
@@ -214,12 +214,13 @@ void CollectSharedCommand::help(){
 //**********************************************************************************************************************
 
 CollectSharedCommand::~CollectSharedCommand(){
-       delete order;
-       delete input;
-       delete cCurve;
-       delete read;
-       delete util;
-       delete validCalculator;
+       if (abort == false) {
+               delete input; globaldata->ginput = NULL;
+               delete read;
+               delete util;
+               delete validCalculator;
+               globaldata->gorder = NULL;
+       }
 }
 
 //**********************************************************************************************************************
index 27355dddd933834108371d18cf66c27c4a29763b..1dd5e871aaa66362e02e997c9ff26b427ed9178a 100644 (file)
 #include "validparameter.h"
 
 class Command {
+       
        public:
                virtual int execute() = 0;
                virtual void help() = 0;
+               virtual ~Command() { }
 };
 
 #endif
index f8491469a3fec224f299125fdd960a38343f921b..852e2d294a3887c747fa8a95bb56f36151d2890e 100644 (file)
@@ -41,7 +41,7 @@ Database::Database(string fastaFileName){             //      This assumes that the template dat
                                aligned += letter;
                        }
                }
-               templateSequences[i] = new Sequence(seqName, aligned);
+               templateSequences[i] = Sequence(seqName, aligned);
                fastaFile.putback(letter);
        }
        
@@ -51,6 +51,24 @@ Database::Database(string fastaFileName){            //      This assumes that the template dat
        cout << "DONE." << endl;        cout.flush();
 
 }
+/**************************************************************************************************/
+
+Database::~Database(){                                                                                                         
+       try {
+               
+               //for (int i = 0; i < templateSequences.size(); i++) {  delete templateSequences[i];    }
+               templateSequences.clear();
+
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the Database class Function ~Database. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the Database class function ~Database. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
 
 /**************************************************************************************************/
 
index 2fced3fcfb80ea3367a9116f5aca858d7baf88f1..02cad03d0e34e33fac8324541266758d91f8693d 100644 (file)
@@ -20,12 +20,13 @@ class Sequence;
 class Database {
 public:
        Database(string);
-       virtual Sequence* findClosestSequence(Sequence*) = 0;
+       virtual ~Database();
+       virtual Sequence findClosestSequence(Sequence*) = 0;
        virtual float getSearchScore();
 protected:
        int numSeqs;
        float searchScore;
-       vector<Sequence*> templateSequences;
+       vector<Sequence> templateSequences;
 };
 
 #endif
index 692332f445aa76b0ff7ebe5ac1281c34b3a8f967..b3c7c90d018ee960e02b281b4f72b1e39601d51b 100644 (file)
@@ -23,7 +23,7 @@ public:
        DataVector(string l) : label(l) {};
        DataVector(const DataVector& dv) : label(dv.label){};//, maxRank(dv.maxRank), numBins(dv.numBins), numSeqs(dv.numSeqs) {};
        DataVector(ifstream&);
-       ~DataVector(){};
+       virtual ~DataVector(){};
        
 //     virtual int getNumBins()        {       return numBins;         }
 //     virtual int getNumSeqs()        {       return numSeqs;         }
index 3ec5f734eebb393c6ff630a1adc8d7e94ab6729f..2fe7a251ca41a5d833ad7f643970a1d9847a8361 100644 (file)
@@ -96,6 +96,7 @@ int DeconvoluteCommand::execute() {
                fastamap->printNamesFile(out);
                fastamap->printCondensedFasta(outFasta);
                
+               in.close();
                out.close();
                outFasta.close();
        
index 0207bbfe2186228c324dcf25ba1a7909ed703fdf..ee827e51ff66a3faa7f2d3cd05ff82d131579345 100644 (file)
--- a/display.h
+++ b/display.h
@@ -18,6 +18,7 @@ public:
        virtual void reset() = 0;
        virtual void close() = 0;
        virtual bool isCalcMultiple() = 0;
+       virtual ~Display() {}
        
 private:
 
diff --git a/dist.h b/dist.h
index 4200bf9f291223d91758c482318415e8409a8e5e..6e42ae33d095be047bffc222cbf07bde85a8424e 100644 (file)
--- a/dist.h
+++ b/dist.h
@@ -18,6 +18,7 @@ class Dist {
        
 public:
        Dist(){dist = 0;}
+       virtual ~Dist() {}
        virtual void calcDist(Sequence, Sequence) = 0;
        double getDist()        {       return dist;    }
 protected:
index 065c14a1671a8abe78e1dda115208936185f496e..0c9d011503370886d2f802d2903c72f985cbc40e 100644 (file)
@@ -47,6 +47,7 @@ DistanceCommand::DistanceCommand(string option){
                                ifstream inFASTA;
                                openInputFile(fastafile, inFASTA);
                                alignDB = SequenceDB(inFASTA); 
+                               inFASTA.close();
                        }
 
                        //check for optional parameter and set defaults
@@ -195,7 +196,7 @@ int DistanceCommand::execute(){
                        }
                }
 #else
-               ifstream inFASTA
+               ifstream inFASTA;
                driver(0, numSeqs, outputFile, cutoff);
 #endif
                
index 3cb739db9496dd64b01d24b31900edd5ecc9fb88..25c95c7a32a2523080bac92b41722ed1f1b91e6d 100644 (file)
@@ -40,7 +40,7 @@ DistanceDB::DistanceDB(string fastaFileName, string distanceFileName) : Database
 
 /**************************************************************************************************/
 
-Sequence* DistanceDB::findClosestSequence(Sequence* candidateSeq){
+Sequence DistanceDB::findClosestSequence(Sequence* candidateSeq){
        
        hit simAccession = mostSimSequenceVector[searchIndex];
 //     string candidateSeqName, closestMatchSeqName, junk;
index 9c13faffdb778cbebca30454b1372625a24de502..8da1d102ac8db9c9e485a2e9c774672fdcd0cc98 100644 (file)
@@ -17,7 +17,7 @@ class DistanceDB : public Database {
        
 public:
        DistanceDB(string, string);
-       Sequence* findClosestSequence(Sequence*);
+       Sequence findClosestSequence(Sequence*);
        
 private:
 
index 03422e20790a96159eaa68ad569ae4a15a5d94aa..a2d525011ad2823d1c72e07e24a6c4974d98644c 100644 (file)
@@ -47,8 +47,8 @@ bool InteractEngine::getInput(){
                //bool errorFree;
                //ErrorCheck* errorCheckor = new ErrorCheck();
                
-               cout << "mothur v.1.3.0" << endl;
-               cout << "Last updated: 5/29/2009" << endl << endl;
+               cout << "mothur v.1.4.0" << endl;
+               cout << "Last updated: 6/21/2009" << endl << endl;
                cout << "by" << endl;
                cout << "Patrick D. Schloss" << endl << endl;
                cout << "Department of Microbiology" << endl;
@@ -147,7 +147,7 @@ bool BatchEngine::getInput(){
                int quitCommandCalled = 0;
        
                while(quitCommandCalled == 0){
-               
+       
                        if (inputBatchFile.eof()) { input = "quit()"; }
                        else { getline(inputBatchFile, input); }
                        
@@ -175,6 +175,8 @@ bool BatchEngine::getInput(){
                        }
                        gobble(inputBatchFile);
                }
+               
+               inputBatchFile.close();
                return 1;
        }
        catch(exception& e) {
@@ -280,12 +282,14 @@ string ScriptEngine::getNextCommand(string& commandString) {
                        commandString = commandString.substr(commandString.find_first_of(';')+1, commandString.length());
                }else { commandString = ""; } //you have reached the last command.
                
-               //get rid of any extra spaces in between commands
-               //string space = " ";
-               
-               //while(commandString.at(0) == ' ')
-                       //commandString = commandString.substr(1, commandString.length());
-                       
+               //get rid of spaces in between commands if any
+               if (commandString.length() > 0) {
+                       while (commandString[0] == ' ') {  
+                               commandString = commandString.substr(1,commandString.length());
+                               if (commandString.length() == 0) {  break;  }
+                       }
+               }
+                                       
                return nextcommand;
        }
        catch(exception& e) {
index 7dfb0c00b48b93e9d6cb121ba905de7cdc8a5dcb..a047a20cffd5cb9c4ac50fbf2cf0b1bb335180cb 100644 (file)
@@ -9,7 +9,7 @@ class FileOutput {
        
 public:
        FileOutput(){};
-       ~FileOutput(){};
+       virtual ~FileOutput(){};
        
        virtual void initFile(string) = 0;
        virtual void initFile(string, vector<string>) = 0;
index 95d51f329f30d8a639d0772844e54be5246e5005..c38bfcb5f83eb3b607b42616174cf650b0de8952 100644 (file)
@@ -104,6 +104,8 @@ void FilterSeqsCommand::doHard() {
        openInputFile(hard, fileHandle);
        
        fileHandle >> filter;
+       
+       fileHandle.close();
 
 }
 
index ea6ef1760a763f6962f1f259a512b519fc659956..4fa84136001aefaeb051ee592a41e54b081b0885 100644 (file)
@@ -115,6 +115,7 @@ int GetgroupCommand::execute(){
                        if (in.eof() != true) { in >> nextLabel; }
                }
                
+               in.close();
                out.close();
                return 0;       
        }
index e0c17204e7c732ed180fd134a1a7c0d05a105c40..40c656bb0286122f013ec9dfe65a6da2ea42244a 100644 (file)
@@ -84,6 +84,8 @@ int GetlabelCommand::execute(){
                        in >> label;
                        count++;
                }       
+               
+               in.close();
                return 0;       
        }
 
index 6802978a0c3e527aed6a30a7a8ecce1726c19b57..800f9d816eab2230d2f543321d0ddb5c97e1ee63 100644 (file)
@@ -84,6 +84,8 @@ int GetlineCommand::execute(){
                        in >> label;
                        count++;
                }
+               
+               in.close();
                return 0;               
        }
 
index 35e6924414931a11a5b476e5ecd77a9622bad8c2..65c18061cec3193da3de5e4f9678aa9655ba18d9 100644 (file)
@@ -156,11 +156,13 @@ void GetOTURepCommand::help(){
 //**********************************************************************************************************************
 
 GetOTURepCommand::~GetOTURepCommand(){
-       delete input;
-       delete read;
-       delete fasta;
-       if (groupfile != "") {
-               delete groupMap;
+       if (abort == false) {
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+               delete fasta;
+               if (groupfile != "") {
+                       delete groupMap;  globaldata->gGroupmap = NULL;
+               }
        }
 }
 
@@ -177,8 +179,10 @@ int GetOTURepCommand::execute(){
                //read fastafile
                fasta->readFastaFile(in);
                
+               in.close();
+               
                //set format to list so input can get listvector
-//             globaldata->setFormat("list");
+               globaldata->setFormat("list");
                
                //if user gave a namesfile then use it
                if (namesfile != "") {
index c978bb19439db11e9fada887112ab708d7551fd2..0dfaa63129e8269b7446bad82ae38290760643a0 100644 (file)
@@ -108,6 +108,7 @@ void GetRAbundCommand::help(){
 //**********************************************************************************************************************
 
 GetRAbundCommand::~GetRAbundCommand(){
+       if (abort == false) {  globaldata->gListVector = NULL; }
 }
 
 //**********************************************************************************************************************
index 6670980dde157a7740f9984309123b2a63625475..1e10736f281b76f59c0e74374ba1b8afd4d36646 100644 (file)
@@ -186,7 +186,7 @@ int GetSAbundCommand::execute(){
                        sabund->print(out);
                        delete sabund;
                }
-               delete lastOrder;
+               delete lastOrder;  globaldata->gorder = NULL;
 
                out.close();
                return 0;               
index fe3c11b87dba7519ebec6c1e39168b764563233e..0d728a128bd8fc43f0314c21894faf813533c7e2 100644 (file)
@@ -1,6 +1,9 @@
 
 
 #include "globaldata.hpp"
+#include "sharedlistvector.h"
+#include "inputdata.h"
+#include "fullmatrix.h"
 
 /*******************************************************/
 
@@ -50,6 +53,16 @@ GlobalData::GlobalData() {
        clear();
        gListVector = NULL;             
        gSparseMatrix = NULL;   
+       ginput = NULL;
+       gorder = NULL;
+       glist = NULL;
+       gSharedList = NULL;
+       sabund = NULL;
+       rabund = NULL;
+       gGroupmap = NULL;
+       gMatrix = NULL;
+       gTreemap = NULL;
+       gSequenceDB = NULL;
 }
 /*******************************************************/
 
@@ -74,11 +87,24 @@ void GlobalData::clear() {
 
 /******************************************************/
 void GlobalData::newRead() {
-       try{
+       try{    
+                       //remove old file names
                        clear();
-                       gGroupmap = NULL;
-                       gListVector = NULL;
-                       gSparseMatrix = NULL;
+                       
+                       //free memory
+                       if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
+                       if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
+                       if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
+                       if (ginput != NULL) { delete ginput; ginput = NULL;}
+                       if (gorder != NULL) { delete gorder; gorder = NULL; }
+                       if (glist != NULL) { delete glist; glist = NULL;}
+                       if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
+                       if (sabund != NULL) { delete sabund; sabund = NULL;}
+                       if (rabund != NULL) { delete rabund; rabund = NULL; }
+                       if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
+                       if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
+                       if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
+
                        gTree.clear();
                        Treenames.clear();
                        labels.clear(); lines.clear(); Groups.clear();
@@ -100,9 +126,28 @@ void GlobalData::newRead() {
 /******************************************************/
 GlobalData::~GlobalData() {
        _uniqueInstance = 0;
-       if(gListVector != NULL)         {       delete gListVector;             }
-       if(gSparseMatrix != NULL)       {       delete gSparseMatrix;   }
-       if(gorder != NULL)                      {       delete gorder;          }
+       try {
+               if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
+               if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
+               if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
+               if (ginput != NULL) { delete ginput; ginput = NULL;}
+               if (gorder != NULL) { delete gorder; gorder = NULL; }
+               if (glist != NULL) { delete glist; glist = NULL;}
+               if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
+               if (sabund != NULL) { delete sabund; sabund = NULL;}
+               if (rabund != NULL) { delete rabund; rabund = NULL; }
+               if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
+               if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
+               if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function ~GlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the GlobalData class function ~GlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
 }
 /*******************************************************/
 
index 6515521768bfe2291775965e80eb94eac4d7a760..6f66cbe8bbd09577ff0ce709e7fc882d79eb8874 100644 (file)
@@ -9,6 +9,8 @@
 #include "listvector.hpp"
 #include "tree.h"
 #include "sparsematrix.hpp"
+#include "sequencedb.h"
+
 
 class ListVector;
 class SharedListVector;
index bf3c636e42e702ad2e6f2aca03db13cdcd88ac18..85176efc4c86031a60034910196f0a1a56fc5e45 100644 (file)
@@ -30,6 +30,7 @@ class GotohOverlap : public Alignment {
 public:
        GotohOverlap(float, float, float, float, int);
        void align(string, string);
+       ~GotohOverlap() {}
        
 private:
        float gapOpen;
index d4e893b27edbda150ea961ddc3e6484d268a78c8..7a729c68b1fa1574d3f99d04f832d9e1a8c9aecf 100644 (file)
@@ -128,9 +128,10 @@ void HeatMapCommand::help(){
 //**********************************************************************************************************************
 
 HeatMapCommand::~HeatMapCommand(){
-       
-       delete read;
-       delete heatmap;
+       if (abort == false) {
+               delete read;
+               delete heatmap;
+       }
 }
 
 //**********************************************************************************************************************
@@ -272,11 +273,11 @@ int HeatMapCommand::execute(){
                                heatmap->getPic(lastRAbund);
                        }
                
-                       delete lastRAbund;
+                       delete lastRAbund; globaldata->rabund = NULL;
 
                }
                
-               delete input;
+               delete input; globaldata->ginput = NULL;
                return 0;
        }
        catch(exception& e) {
index 3b0d7984bc1d0be02cb66c9d816f72df94e48f36..f3329945e0fa3fb6b24c77960717ff51e7cb0de0 100644 (file)
@@ -171,10 +171,12 @@ void HeatMapSimCommand::help(){
 //**********************************************************************************************************************
 
 HeatMapSimCommand::~HeatMapSimCommand(){
-       delete input;
-       delete read;
-       delete heatmap;
-       delete validCalculator;
+       if (abort == false) {
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+               delete heatmap;
+               delete validCalculator;
+       }
 }
 
 //**********************************************************************************************************************
index b237bb4fc55b0bacafa3815f9619f0345bd31492..b4373c9ea057636634929f4b8e1e3d63398fdeec 100644 (file)
@@ -72,7 +72,7 @@ ListVector* InputData::getListVector(){
                        return list;
                }
                else{
-                       return 0;
+                       return NULL;
                }
        }
        catch(exception& e) {
@@ -98,7 +98,7 @@ SharedListVector* InputData::getSharedListVector(){
                        return SharedList;
                }
                else{
-                       return 0;
+                       return NULL;
                }
        }
        catch(exception& e) {
@@ -124,7 +124,7 @@ SharedOrderVector* InputData::getSharedOrderVector(){
                        return SharedOrder;
                        
                }else{
-                       return 0;
+                       return NULL;
                }
        }
        catch(exception& e) {
@@ -170,7 +170,7 @@ OrderVector* InputData::getOrderVector(){
                        return output;
                }
                else{
-                       return 0;
+                       return NULL;
                }
        }
        catch(exception& e) {
@@ -246,7 +246,7 @@ SAbundVector* InputData::getSAbundVector(){
                        return sabund;
                }
                else{
-                       return 0;
+                       return NULL;
                }
        }
        catch(exception& e) {
index 572acdae5d0da9b7d51b7df94cecf8680771dc57..40cc1f6612504aef61f24dff4830611fa770727a 100644 (file)
@@ -50,10 +50,17 @@ KmerDB::KmerDB(string fastaFileName, int kSize) : Database(fastaFileName), kmerS
        cout << "DONE." << endl << endl;        cout.flush();
 
 }
+/**************************************************************************************************/
+
+KmerDB::~KmerDB(){                                                                                                             
+       
+               //for (int i = 0; i < templateSequences.size(); i++) {  delete templateSequences[i]; }
+               // templateSequences.clear(); 
+}
 
 /**************************************************************************************************/
 
-Sequence* KmerDB::findClosestSequence(Sequence* candidateSeq){
+Sequence KmerDB::findClosestSequence(Sequence* candidateSeq){
        
        Kmer kmer(kmerSize);
        
@@ -94,7 +101,7 @@ void KmerDB::generateKmerDB(string kmerDBName){
        
        for(int i=0;i<numSeqs;i++){                                                             //      for all of the template sequences...
 
-               string seq = templateSequences[i]->getUnaligned();      //      ...take the unaligned sequence...
+               string seq = templateSequences[i].getUnaligned();       //      ...take the unaligned sequence...
                int numKmers = seq.length() - kmerSize + 1;
                
                vector<int> seenBefore(maxKmer+1,0);
index eb10061c9c36eab1053a07fe2cc7d0f4e3eb90cd..5019858dcf477c2e27bcc9ad3007617e26d3ce96 100644 (file)
@@ -25,7 +25,8 @@ class KmerDB : public Database {
        
 public:
        KmerDB(string, int);
-       Sequence* findClosestSequence(Sequence*);
+       ~KmerDB();
+       Sequence findClosestSequence(Sequence*);
 
 private:
        void generateKmerDB(string);
index 75e613719f9a819dc9cf4882b6442feb031cf296..fd4139100bf3155fd3d9bfb1020e03d5c9056b7c 100644 (file)
@@ -256,7 +256,7 @@ void LibShuffCommand::printCoverageFile() {
                        }
                        outCov << endl;
                }
-               
+               outCov.close();
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function printCoverageFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -305,7 +305,7 @@ void LibShuffCommand::printSummaryFile() {
                        }
                }
                
-               
+               outSum.close();
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function printSummaryFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
index e848647997c1a522f6a583d2144646ac20f7ac51..4ae8e244031a5ea194724fcb4581bbd677e4bc9c 100644 (file)
@@ -170,9 +170,11 @@ void MatrixOutputCommand::help(){
 //**********************************************************************************************************************
 
 MatrixOutputCommand::~MatrixOutputCommand(){
-       delete input;
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               delete input; globaldata->ginput = NULL;
+               delete read;
+               delete validCalculator;
+       }
 }
 
 //**********************************************************************************************************************
index 3342c489d9f54a55abda3bac79b60511402eaf4c..497d535e4810fac221b6ae399d59a7b1ff457d46 100644 (file)
@@ -88,6 +88,8 @@ int MergeFileCommand::execute(){
                        
                        inputFile.close();
                }
+               
+               outputFile.close();
                return 0;
        }
        catch(exception& e) {
index 457a176b8089e5638d41f98de0797756255fd8a6..05e537ac03c1e5ee6210f390e9c7c0945592b676 100644 (file)
@@ -13,6 +13,7 @@ public:
        virtual void registerDisplay(Display*) = 0;
        virtual void removeDisplay(Display*) = 0;
        virtual void notifyDisplays() = 0;      
+       virtual ~Observable() {}
 };
 
 /***********************************************************************/
index 332074d14ee990c00e6a444e235af111121d778d..c12bd47aa0152bf266d0e3445f0f42b67b6bed39 100644 (file)
@@ -184,9 +184,11 @@ int ParseListCommand::execute(){
 //**********************************************************************************************************************
 
 ParseListCommand::~ParseListCommand(){
-       delete list;
-       delete input;
-       delete read;    
+       
+               globaldata->gSharedList = NULL;
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+       
 }
 //**********************************************************************************************************************
 void ParseListCommand::process(SharedListVector* thisList) {
index 6bf42fc8a2e7d33374f73ba04d0df4f8eff57e1a..8820328461fcc2b403bbb9f01b8e44776d0a5750 100644 (file)
@@ -171,11 +171,12 @@ void RareFactCommand::help(){
 //**********************************************************************************************************************
 
 RareFactCommand::~RareFactCommand(){
-       delete order;
-       delete input;
-       delete rCurve;
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               globaldata->gorder = NULL;
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+               delete validCalculator;
+       }
 }
 
 //**********************************************************************************************************************
index fdc967856043fc8e191c9b3167fb83634f82ec0a..6461b3bc22922af68cba684893eb00f76e35a598 100644 (file)
@@ -154,10 +154,11 @@ void RareFactSharedCommand::help(){
 //**********************************************************************************************************************
 
 RareFactSharedCommand::~RareFactSharedCommand(){
-       delete input;
-       delete rCurve;
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               delete input;   globaldata->ginput = NULL;
+               delete read;
+               delete validCalculator;
+       }
 }
 
 //**********************************************************************************************************************
index 1d2920820076fd6c8597abedb2c59bf58f687daf..59c3bd5520929f40086279d744c666ab18fe6d8b 100644 (file)
@@ -153,8 +153,8 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){
 /***********************************************************************/
 
 ReadColumnMatrix::~ReadColumnMatrix(){
-       delete D;
-       delete list;
+       //delete D;
+       //delete list;
 }
 
 
index b03f12e7f711c471043f879cb172cf7e99a60929..392d12b059d52b2cee4d8f5a4f97037403203943 100644 (file)
@@ -53,8 +53,8 @@ ReadDistCommand::ReadDistCommand(string option){
                        else if (groupfile == "not found") { groupfile = ""; }
                        else {  
                                globaldata->setGroupFile(groupfile); 
-                               groupMap = new GroupMap(groupfile);
-                               groupMap->readMap();
+                               //groupMap = new GroupMap(groupfile);
+                               //groupMap->readMap();
                        }
 
                        namefile = validParameter.validFile(parameters, "name", true);
@@ -150,8 +150,9 @@ void ReadDistCommand::help(){
 //**********************************************************************************************************************
 
 ReadDistCommand::~ReadDistCommand(){
-       delete read;
-       delete nameMap;
+       if (abort == false) {
+               if (format != "matrix") { delete read; delete nameMap; }
+       }
 }
 
 //**********************************************************************************************************************
@@ -164,16 +165,20 @@ int ReadDistCommand::execute(){
                        ifstream in;
                        openInputFile(distFileName, in);
                        matrix = new FullMatrix(in); //reads the matrix file
+                       in.close();
                        //memory leak prevention
-                       //if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix;  }
+                       if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix;  }
                        globaldata->gMatrix = matrix; //save matrix for coverage commands
                }else {
                        read->read(nameMap);
                        //to prevent memory leak
-                       if (globaldata->gListVector != NULL) { delete globaldata->gListVector;  }
+
+                       if (globaldata->gListVector != NULL) {  delete globaldata->gListVector;  }
                        globaldata->gListVector = read->getListVector();
+
                        if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix;  }
                        globaldata->gSparseMatrix = read->getMatrix();
+
                }
                return 0;
        }
index 66480e7a6999ed90830f45a730c49ab4b850c73f..d8f9bd11eff62b07593c29e728c35c5ddcf2ac2f 100644 (file)
@@ -22,6 +22,7 @@ class ReadMatrix {
 
 public:
        ReadMatrix(){   D = new SparseMatrix(); }
+       virtual ~ReadMatrix() {}
        virtual void read(NameAssignment*){};
        virtual void read(GlobalData* globaldata){};
        void setCutoff(float c)                 {       cutoff = c;             }
index 286a2be271a4a7bb2225a71c7081b1a5c8eb4571..b97c902d7712e957ea44819d24cd7af0ae22cd4a 100644 (file)
@@ -13,7 +13,7 @@
 
 ReadOTUFile::ReadOTUFile(string pf): philFile(pf){
        
-       openInputFile(philFile, fileHandle);
+       //openInputFile(philFile, fileHandle);
 }
 
 /***********************************************************************/
index e318af4b872e36eb243900d9de10f5b3fe9092fd..b259733875eb201fbceb87778a6ecd89d8f6c62b 100644 (file)
--- a/readotu.h
+++ b/readotu.h
@@ -27,7 +27,7 @@ public:
        ~ReadOTUFile();
        void read(GlobalData* globaldata);
 private:
-       ifstream fileHandle;
+       //ifstream fileHandle;
        string philFile;
        InputData* input;
        InputData* inputSabund;
index bc39b52ca071d126bc9adc671e8d202c9a112dd6..a1063e94d3d94f241f172bfe33a39ae54d5da7cb 100644 (file)
@@ -180,6 +180,6 @@ void ReadPhylipMatrix::read(NameAssignment* nameMap){
 /***********************************************************************/
 
 ReadPhylipMatrix::~ReadPhylipMatrix(){
-        delete D;
-        delete list;
+       // delete D;
+       // delete list;
 }
index d3790df170ab0651c24987bc3541b62f48197c5f..670c6e0a3126ba73370d2520be2b7ac9e1728dd3 100644 (file)
@@ -177,6 +177,8 @@ int ReadNewickTree::read() {
                }
                
                if (error != 0) { readOk = error; } 
+               
+               filehandle.close();
                return readOk;
        }
        catch(exception& e) {
index c8e866aa476695c45cbfded4652fa1d4aef24dbe..0cdf8b1fb8b426f6e358143e492a7c6cae64146e 100644 (file)
@@ -23,7 +23,7 @@ class Tree;
 class ReadTree {
        public:
                ReadTree(); 
-               ~ReadTree() {};
+               virtual ~ReadTree() {};
                
                virtual int read() = 0;
                int readSpecialChar(istream&, char, string);
index 88e34ff5c7e3f2c243eb7e0dac56b7d11fcb39b4..d301b1366d5f8965a2c84151940d5773b5d71854 100644 (file)
@@ -33,14 +33,13 @@ ReadTreeCommand::ReadTreeCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
-                       globaldata->runParse = true;
                        globaldata->newRead();
                        
                        //check for required parameters
                        treefile = validParameter.validFile(parameters, "tree", true);
                        if (treefile == "not open") { abort = true; }
                        else if (treefile == "not found") { treefile = ""; cout << "tree is a required parameter for the read.tree command." << endl; abort = true;  }  
-//                     else {  globaldata->setTreeFile(treefile);  globaldata->setFormat("tree");      }
+                       else {  globaldata->setTreeFile(treefile);  globaldata->setFormat("tree");      }
                        
                        groupfile = validParameter.validFile(parameters, "group", true);
                        if (groupfile == "not open") { abort = true; }  
index 1c70a2b5a9723b64a4b9edd34cb2fc81e374e42d..ca1d616a867c33a3d42dd98131960db6d2224177 100644 (file)
@@ -160,6 +160,9 @@ int ScreenSeqsCommand::execute(){
                if(groupfile != "")             {       screenGroupFile(badSeqNames);           }
                if(alignreport != "")   {       screenAlignReport(badSeqNames);         }
                
+               goodSeqOut.close();
+               badSeqOut.close();
+               inFASTA.close();
                return 0;
        }
        catch(exception& e) {
index 24ef1d12e08262a335f7c29104120f7cddc81e1b..3259931a1fe04dfeaca2c6d981af48018e9f377d 100644 (file)
@@ -139,6 +139,7 @@ int SeqSummaryCommand::execute(){
                cout << "Maximum:\t" << startPosition[ptile100] << '\t' << endPosition[ptile100] << '\t' << seqLength[ptile100] << '\t' << ambigBases[ptile100] << '\t' << longHomoPolymer[ptile100] << endl;
                cout << "# of Seqs:\t" << numSeqs << endl;
                
+               outSummary.close();
                return 0;
        }
        catch(exception& e) {
index 152a138c279a101038566ced46339d970caef9bd..3d1c2778387a0beec550a0c6086b9fb06281338d 100644 (file)
--- a/shen.cpp
+++ b/shen.cpp
@@ -27,7 +27,9 @@ EstOutput Shen::getValues(SAbundVector* rank){
                double f0 = ace[0]-rank->getNumBins();
                
                data[0] = f0 * (1 - pow(1 - f1/n/f0, m));
-
+               
+               delete calc;
+               
                return data;
        }
        catch(exception& e) {
index 15f7753b65291f897103e5e7b75fe79a2d139b99..5e6fd10455ce5557033234a470d7bd68fed37c41 100644 (file)
@@ -35,7 +35,7 @@ SuffixDB::SuffixDB(string fastaFileName) : Database(fastaFileName) {
 
 /**************************************************************************************************/
 
-Sequence* SuffixDB::findClosestSequence(Sequence* candidateSeq){
+Sequence SuffixDB::findClosestSequence(Sequence* candidateSeq){
 
        int minValue = 2000;
        int closestSequenceNo = 0;
@@ -52,3 +52,11 @@ Sequence* SuffixDB::findClosestSequence(Sequence* candidateSeq){
 }
 
 /**************************************************************************************************/
+
+SuffixDB::~SuffixDB(){                                                                                                         
+       
+       for (int i = (suffixForest.size()-1); i >= 0; i--) {  suffixForest.pop_back();  }
+       // templateSequences.clear();
+
+}
+/**************************************************************************************************/
index 15114cf9a103707b67486864fd0d8b40f96e95c7..f211aa7ba7f612613419c54e551cb0755d2dffc7 100644 (file)
@@ -27,7 +27,8 @@ class SuffixDB : public Database {
        
 public:
        SuffixDB(string);
-       Sequence* findClosestSequence(Sequence*);
+       ~SuffixDB();
+       Sequence findClosestSequence(Sequence*);
 
 private:
        vector<SuffixTree> suffixForest;
index 82d4be9f40ead561f2e50b84bbd43fbf7d8f7e9e..63918fa6acf5f5c5f81124403e387cb61c7634b3 100644 (file)
@@ -24,6 +24,7 @@ class SuffixNode {
        
 public:
        SuffixNode(int, int, int);
+       virtual ~SuffixNode() {}
        virtual void print(string, int) = 0;
        virtual void setChildren(char, int);
        virtual int getNumChildren();
@@ -49,6 +50,7 @@ class SuffixLeaf : public SuffixNode {        //      most of the methods are already set in
        
 public:
        SuffixLeaf(int, int, int);              //      we just need to define a constructor and
+       ~SuffixLeaf() {}
        void print(string, int);                //      print method
 };
 
@@ -58,6 +60,7 @@ class SuffixBranch : public SuffixNode {
        
 public:
        SuffixBranch(int, int, int);
+       ~SuffixBranch() {}
        void print(string, int);                //      need a special method for printing the node because there are children
        void eraseChild(char);                  //      need a special method for erasing the children
        void setChildren(char, int);    //      need a special method for setting children
index 492460d4dd68f4f025504b58acbc80fad09b09b7..0dbe2c0e41e6bd68df024f411c0883bdd306fe8b 100644 (file)
@@ -41,16 +41,17 @@ SuffixTree::SuffixTree(){}
 
 SuffixTree::~SuffixTree(){
        for(int i=0;i<nodeVector.size();i++){   delete nodeVector[i];   }       
+       nodeVector.clear();
 }
 
 //********************************************************************************************************************
 
-void SuffixTree::loadSequence(Sequence* seq){
+void SuffixTree::loadSequence(Sequence seq){
        nodeCounter = 0;                                                        //      initially there are 0 nodes in the tree
        activeStartPosition = 0;
        activeEndPosition = -1;                                         
-       seqName = seq->getName();
-       sequence = seq->convert2ints();
+       seqName = seq.getName();
+       sequence = seq.convert2ints();
        sequence += '5';                                                        //      this essentially concatenates a '$' to the end of the sequence to
        int seqLength = sequence.length();                      //      make it a cononical suffix tree
        
index 28b6fd10772f12c5c712705fb22b414a79b4cb32..b85cee90f93cd59cc34a604840de9d8d6c613a61 100644 (file)
@@ -38,7 +38,7 @@ public:
        ~SuffixTree();
 //     SuffixTree(string, string);
 
-       void loadSequence(Sequence*);
+       void loadSequence(Sequence);
        string getSeqName();
        void print();   
        int countSuffixes(string, int&);
index fa6d11ade6a27c69655e4b383b37f27f4a87f3bc..ee4ba9f760c656f84cbe13da9ed6da0cccb73e60 100644 (file)
@@ -194,10 +194,12 @@ void SummaryCommand::help(){
 //**********************************************************************************************************************
 
 SummaryCommand::~SummaryCommand(){
-       delete sabund;
-       delete input;
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               delete input;  globaldata->ginput = NULL;
+               delete read;
+               delete validCalculator;
+               globaldata->sabund = NULL;
+       }
 }
 
 //**********************************************************************************************************************
@@ -272,7 +274,7 @@ int SummaryCommand::execute(){
                                outputFileHandle << endl;
                        }               
 
-                       if (count != 1) { delete lastSAbund; }
+                       if (count != 1) { delete lastSAbund;  }
                        lastSAbund = sabund;                    
 
                        sabund = input->getSAbundVector();
@@ -304,6 +306,8 @@ int SummaryCommand::execute(){
                        outputFileHandle << endl;
                }
                
+               outputFileHandle.close();
+               
                delete lastSAbund;
                return 0;
        }
index 7c1275f3a8ea9977a39e5294fa7ac330de59d857..4006b2d661ab02dc01c1e0f2c0a1fbee9f147fa7 100644 (file)
@@ -204,8 +204,10 @@ void SummarySharedCommand::help(){
 //**********************************************************************************************************************
 
 SummarySharedCommand::~SummarySharedCommand(){
-       delete read;
-       delete validCalculator;
+       if (abort == false) {
+               delete read;
+               delete validCalculator;
+       }
 }
 
 //**********************************************************************************************************************
@@ -335,7 +337,7 @@ int SummarySharedCommand::execute(){
                
                for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
                
-               delete input;
+               delete input;  globaldata->ginput = NULL;
 
                return 0;
        }
index c078f4f0728f0f35a9f2bc75f6174fb3eef38979..ee17e6f37f6417d24546697e3247c21f34d1d0aa 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -668,7 +668,7 @@ void Tree::parseTreeFile() {
                                if(number == ";") { globaldata->Treenames.pop_back(); }  //in case ';' from translation is on next line instead of next to last name
                        }
                }
-               
+               filehandle.close();
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function parseTreeFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
index 16663bf161afbb61c92722c27facdd8885a0dad5..35d061c382f9857e7cfac0c965fb4f1935c7715c 100644 (file)
@@ -24,7 +24,7 @@ class TreeCalculator {
 public:
        TreeCalculator(){};
        TreeCalculator(string n) : name(n) {};
-       ~TreeCalculator(){};
+       virtual ~TreeCalculator(){};
        virtual EstOutput getValues(Tree*) = 0; 
        virtual EstOutput getValues(Tree*, string, string) = 0;
        
index 0f106c493d1d55f7e742ed1195e1557f435d6e49..88b1b46997a4e52d215bf2f5c2b67a75bdf300d3 100644 (file)
@@ -205,11 +205,13 @@ void TreeGroupCommand::help(){
 //**********************************************************************************************************************
 
 TreeGroupCommand::~TreeGroupCommand(){
-       delete input;
-       if (format == "sharedfile") {delete read;}
-       else { delete readMatrix;  delete matrix; delete list; }
-       delete tmap;
-       delete validCalculator;
+       if (abort == false) {
+               
+               if (format == "sharedfile") { delete read;  delete input; globaldata->ginput = NULL;}
+               else { delete readMatrix;  delete matrix; delete list; }
+               delete tmap;
+               delete validCalculator;
+       }
        
 }
 
index e616b744b2ec04d52639eca24cef8fb2af65e783..1989365a5a2a653d54c6b4258f65deaceac079c6 100644 (file)
@@ -179,6 +179,7 @@ int TrimSeqsCommand::execute(){
                                if(qThreshold != 0)             {       success = stripQualThreshold(currSeq, qFile);   }
                                else if(qAverage != 0)  {       success = cullQualAverage(currSeq, qFile);              }
                                if(!success)                    {       trashCode += 'q';                                                               }
+                               qFile.close();
                        }
                        if(barcodes.size() != 0){
                                success = stripBarcode(currSeq, group);
@@ -308,6 +309,8 @@ void TrimSeqsCommand::getOligos(vector<ofstream*>& outFASTAVec){
                }
        }
        
+       inOligos.close();
+       
        numFPrimers = forPrimer.size();
        numRPrimers = revPrimer.size();
 }
index 70c136b8cb56f59aeeef41cba2d1c1fa75e83b54..343461af0a697c72af7a00a3fc219a5a544e707c 100644 (file)
@@ -181,10 +181,13 @@ void VennCommand::help(){
 //**********************************************************************************************************************
 
 VennCommand::~VennCommand(){
-       delete input;
-       delete read;
-       delete venn;
-       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
+       if (abort == false) {
+               delete input; globaldata->ginput = NULL;
+               delete read;
+               delete venn;
+               globaldata->sabund = NULL;
+       }
+       
 }
 
 //**********************************************************************************************************************
@@ -342,6 +345,7 @@ int VennCommand::execute(){
                        delete lastSAbund;
                }
                
+               for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
                return 0;
        }
        catch(exception& e) {