//**********************************************************************************************************************
-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;
+ }
}
//**********************************************************************************************************************
lines.push_back(new linePair(0, numFastaSeqs));
driver(lines[0], alignFileName, reportFileName);
+
}
else{
vector<int> positions;
appendReportFiles((reportFileName + toString(processIDS[i]) + ".temp"), reportFileName);
remove((reportFileName + toString(processIDS[i]) + ".temp").c_str());
}
+
}
#else
ifstream inFASTA;
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());
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);
+ }
+}
/**************************************************************************************************/
public:
Alignment(int);
Alignment();
+ virtual ~Alignment();
virtual void align(string, string) = 0;
// float getAlignmentScore();
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...
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();
+ }
}
}
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; }
}
-
}
//**********************************************************************************************************************
//read fastafile
fasta->readFastaFile(in);
+ in.close();
+
//set format to list so input can get listvector
// globaldata->setFormat("list");
seqAaln += 'Z'; // again need ot pad the sequences so that they extend to the length
seqBaln += 'X'; // of the template sequence
}
+ blastFile.close();
}
//**************************************************************************************************/
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();
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");
}
/**************************************************************************************************/
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
/**************************************************************************************************/
-Sequence* BlastDB::findClosestSequence(Sequence* candidate){
+Sequence BlastDB::findClosestSequence(Sequence* candidate){
ofstream queryFile;
openOutputFile(queryFileName, queryFile);
searchScore = 0.00;
return emptySequence;
}
+ m8FileHandle.close();
}
/**************************************************************************************************/
public:
BlastDB(string, float, float, float, float);
~BlastDB();
- Sequence* findClosestSequence(Sequence*);
+ Sequence findClosestSequence(Sequence*);
private:
string dbFileName;
float gapExtend;
float match;
float misMatch;
- Sequence* emptySequence;
+ Sequence emptySequence;
GlobalData* globaldata;
};
BootSharedCommand::~BootSharedCommand(){
//made new in execute
if (abort == false) {
- delete input;
+ delete input; globaldata->ginput = NULL;
delete read;
delete util;
+ globaldata->gorder = NULL;
}
}
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;
//**********************************************************************************************************************
ClusterCommand::~ClusterCommand(){
- delete cluster;
- delete rabund;
+ if (abort == false) {
+ delete cluster;
+ delete rabund;
+ }
}
//**********************************************************************************************************************
globaldata->setNameFile("");
globaldata->setFormat("list");
+ sabundFile.close();
+ rabundFile.close();
+ listFile.close();
+
return 0;
}
catch(exception& e) {
//**********************************************************************************************************************
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;
+ }
}
//**********************************************************************************************************************
userLabels.erase(lastOrder->getLabel());
}
- if (count != 1) { delete lastOrder; }
+ if (count != 1) { delete lastOrder; }
lastOrder = order;
order = (input->getOrderVector());
count++;
if (abort == false) {
string fileNameRoot = getRootName(globaldata->inputFileName);
-// format = globaldata->getFormat();
+ format = globaldata->getFormat();
int i;
validCalculator = new ValidCalculators();
//**********************************************************************************************************************
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;
+ }
}
//**********************************************************************************************************************
#include "validparameter.h"
class Command {
+
public:
virtual int execute() = 0;
virtual void help() = 0;
+ virtual ~Command() { }
};
#endif
aligned += letter;
}
}
- templateSequences[i] = new Sequence(seqName, aligned);
+ templateSequences[i] = Sequence(seqName, aligned);
fastaFile.putback(letter);
}
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);
+ }
+}
/**************************************************************************************************/
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
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; }
fastamap->printNamesFile(out);
fastamap->printCondensedFasta(outFasta);
+ in.close();
out.close();
outFasta.close();
virtual void reset() = 0;
virtual void close() = 0;
virtual bool isCalcMultiple() = 0;
+ virtual ~Display() {}
private:
public:
Dist(){dist = 0;}
+ virtual ~Dist() {}
virtual void calcDist(Sequence, Sequence) = 0;
double getDist() { return dist; }
protected:
ifstream inFASTA;
openInputFile(fastafile, inFASTA);
alignDB = SequenceDB(inFASTA);
+ inFASTA.close();
}
//check for optional parameter and set defaults
}
}
#else
- ifstream inFASTA
+ ifstream inFASTA;
driver(0, numSeqs, outputFile, cutoff);
#endif
/**************************************************************************************************/
-Sequence* DistanceDB::findClosestSequence(Sequence* candidateSeq){
+Sequence DistanceDB::findClosestSequence(Sequence* candidateSeq){
hit simAccession = mostSimSequenceVector[searchIndex];
// string candidateSeqName, closestMatchSeqName, junk;
public:
DistanceDB(string, string);
- Sequence* findClosestSequence(Sequence*);
+ Sequence findClosestSequence(Sequence*);
private:
//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;
int quitCommandCalled = 0;
while(quitCommandCalled == 0){
-
+
if (inputBatchFile.eof()) { input = "quit()"; }
else { getline(inputBatchFile, input); }
}
gobble(inputBatchFile);
}
+
+ inputBatchFile.close();
return 1;
}
catch(exception& e) {
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) {
public:
FileOutput(){};
- ~FileOutput(){};
+ virtual ~FileOutput(){};
virtual void initFile(string) = 0;
virtual void initFile(string, vector<string>) = 0;
openInputFile(hard, fileHandle);
fileHandle >> filter;
+
+ fileHandle.close();
}
if (in.eof() != true) { in >> nextLabel; }
}
+ in.close();
out.close();
return 0;
}
in >> label;
count++;
}
+
+ in.close();
return 0;
}
in >> label;
count++;
}
+
+ in.close();
return 0;
}
//**********************************************************************************************************************
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;
+ }
}
}
//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 != "") {
//**********************************************************************************************************************
GetRAbundCommand::~GetRAbundCommand(){
+ if (abort == false) { globaldata->gListVector = NULL; }
}
//**********************************************************************************************************************
sabund->print(out);
delete sabund;
}
- delete lastOrder;
+ delete lastOrder; globaldata->gorder = NULL;
out.close();
return 0;
#include "globaldata.hpp"
+#include "sharedlistvector.h"
+#include "inputdata.h"
+#include "fullmatrix.h"
/*******************************************************/
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;
}
/*******************************************************/
/******************************************************/
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();
/******************************************************/
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);
+ }
}
/*******************************************************/
#include "listvector.hpp"
#include "tree.h"
#include "sparsematrix.hpp"
+#include "sequencedb.h"
+
class ListVector;
class SharedListVector;
public:
GotohOverlap(float, float, float, float, int);
void align(string, string);
+ ~GotohOverlap() {}
private:
float gapOpen;
//**********************************************************************************************************************
HeatMapCommand::~HeatMapCommand(){
-
- delete read;
- delete heatmap;
+ if (abort == false) {
+ delete read;
+ delete heatmap;
+ }
}
//**********************************************************************************************************************
heatmap->getPic(lastRAbund);
}
- delete lastRAbund;
+ delete lastRAbund; globaldata->rabund = NULL;
}
- delete input;
+ delete input; globaldata->ginput = NULL;
return 0;
}
catch(exception& e) {
//**********************************************************************************************************************
HeatMapSimCommand::~HeatMapSimCommand(){
- delete input;
- delete read;
- delete heatmap;
- delete validCalculator;
+ if (abort == false) {
+ delete input; globaldata->ginput = NULL;
+ delete read;
+ delete heatmap;
+ delete validCalculator;
+ }
}
//**********************************************************************************************************************
return list;
}
else{
- return 0;
+ return NULL;
}
}
catch(exception& e) {
return SharedList;
}
else{
- return 0;
+ return NULL;
}
}
catch(exception& e) {
return SharedOrder;
}else{
- return 0;
+ return NULL;
}
}
catch(exception& e) {
return output;
}
else{
- return 0;
+ return NULL;
}
}
catch(exception& e) {
return sabund;
}
else{
- return 0;
+ return NULL;
}
}
catch(exception& e) {
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);
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);
public:
KmerDB(string, int);
- Sequence* findClosestSequence(Sequence*);
+ ~KmerDB();
+ Sequence findClosestSequence(Sequence*);
private:
void generateKmerDB(string);
}
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";
}
}
-
+ 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";
//**********************************************************************************************************************
MatrixOutputCommand::~MatrixOutputCommand(){
- delete input;
- delete read;
- delete validCalculator;
+ if (abort == false) {
+ delete input; globaldata->ginput = NULL;
+ delete read;
+ delete validCalculator;
+ }
}
//**********************************************************************************************************************
inputFile.close();
}
+
+ outputFile.close();
return 0;
}
catch(exception& e) {
virtual void registerDisplay(Display*) = 0;
virtual void removeDisplay(Display*) = 0;
virtual void notifyDisplays() = 0;
+ virtual ~Observable() {}
};
/***********************************************************************/
//**********************************************************************************************************************
ParseListCommand::~ParseListCommand(){
- delete list;
- delete input;
- delete read;
+
+ globaldata->gSharedList = NULL;
+ delete input; globaldata->ginput = NULL;
+ delete read;
+
}
//**********************************************************************************************************************
void ParseListCommand::process(SharedListVector* thisList) {
//**********************************************************************************************************************
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;
+ }
}
//**********************************************************************************************************************
//**********************************************************************************************************************
RareFactSharedCommand::~RareFactSharedCommand(){
- delete input;
- delete rCurve;
- delete read;
- delete validCalculator;
+ if (abort == false) {
+ delete input; globaldata->ginput = NULL;
+ delete read;
+ delete validCalculator;
+ }
}
//**********************************************************************************************************************
/***********************************************************************/
ReadColumnMatrix::~ReadColumnMatrix(){
- delete D;
- delete list;
+ //delete D;
+ //delete list;
}
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);
//**********************************************************************************************************************
ReadDistCommand::~ReadDistCommand(){
- delete read;
- delete nameMap;
+ if (abort == false) {
+ if (format != "matrix") { delete read; delete nameMap; }
+ }
}
//**********************************************************************************************************************
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;
}
public:
ReadMatrix(){ D = new SparseMatrix(); }
+ virtual ~ReadMatrix() {}
virtual void read(NameAssignment*){};
virtual void read(GlobalData* globaldata){};
void setCutoff(float c) { cutoff = c; }
ReadOTUFile::ReadOTUFile(string pf): philFile(pf){
- openInputFile(philFile, fileHandle);
+ //openInputFile(philFile, fileHandle);
}
/***********************************************************************/
~ReadOTUFile();
void read(GlobalData* globaldata);
private:
- ifstream fileHandle;
+ //ifstream fileHandle;
string philFile;
InputData* input;
InputData* inputSabund;
/***********************************************************************/
ReadPhylipMatrix::~ReadPhylipMatrix(){
- delete D;
- delete list;
+ // delete D;
+ // delete list;
}
}
if (error != 0) { readOk = error; }
+
+ filehandle.close();
return readOk;
}
catch(exception& e) {
class ReadTree {
public:
ReadTree();
- ~ReadTree() {};
+ virtual ~ReadTree() {};
virtual int read() = 0;
int readSpecialChar(istream&, char, string);
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; }
if(groupfile != "") { screenGroupFile(badSeqNames); }
if(alignreport != "") { screenAlignReport(badSeqNames); }
+ goodSeqOut.close();
+ badSeqOut.close();
+ inFASTA.close();
return 0;
}
catch(exception& e) {
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) {
double f0 = ace[0]-rank->getNumBins();
data[0] = f0 * (1 - pow(1 - f1/n/f0, m));
-
+
+ delete calc;
+
return data;
}
catch(exception& e) {
/**************************************************************************************************/
-Sequence* SuffixDB::findClosestSequence(Sequence* candidateSeq){
+Sequence SuffixDB::findClosestSequence(Sequence* candidateSeq){
int minValue = 2000;
int closestSequenceNo = 0;
}
/**************************************************************************************************/
+
+SuffixDB::~SuffixDB(){
+
+ for (int i = (suffixForest.size()-1); i >= 0; i--) { suffixForest.pop_back(); }
+ // templateSequences.clear();
+
+}
+/**************************************************************************************************/
public:
SuffixDB(string);
- Sequence* findClosestSequence(Sequence*);
+ ~SuffixDB();
+ Sequence findClosestSequence(Sequence*);
private:
vector<SuffixTree> suffixForest;
public:
SuffixNode(int, int, int);
+ virtual ~SuffixNode() {}
virtual void print(string, int) = 0;
virtual void setChildren(char, int);
virtual int getNumChildren();
public:
SuffixLeaf(int, int, int); // we just need to define a constructor and
+ ~SuffixLeaf() {}
void print(string, int); // print method
};
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
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
~SuffixTree();
// SuffixTree(string, string);
- void loadSequence(Sequence*);
+ void loadSequence(Sequence);
string getSeqName();
void print();
int countSuffixes(string, int&);
//**********************************************************************************************************************
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;
+ }
}
//**********************************************************************************************************************
outputFileHandle << endl;
}
- if (count != 1) { delete lastSAbund; }
+ if (count != 1) { delete lastSAbund; }
lastSAbund = sabund;
sabund = input->getSAbundVector();
outputFileHandle << endl;
}
+ outputFileHandle.close();
+
delete lastSAbund;
return 0;
}
//**********************************************************************************************************************
SummarySharedCommand::~SummarySharedCommand(){
- delete read;
- delete validCalculator;
+ if (abort == false) {
+ delete read;
+ delete validCalculator;
+ }
}
//**********************************************************************************************************************
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
- delete input;
+ delete input; globaldata->ginput = NULL;
return 0;
}
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";
public:
TreeCalculator(){};
TreeCalculator(string n) : name(n) {};
- ~TreeCalculator(){};
+ virtual ~TreeCalculator(){};
virtual EstOutput getValues(Tree*) = 0;
virtual EstOutput getValues(Tree*, string, string) = 0;
//**********************************************************************************************************************
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;
+ }
}
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);
}
}
+ inOligos.close();
+
numFPrimers = forPrimer.size();
numRPrimers = revPrimer.size();
}
//**********************************************************************************************************************
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;
+ }
+
}
//**********************************************************************************************************************
delete lastSAbund;
}
+ for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; }
return 0;
}
catch(exception& e) {