X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=globaldata.cpp;h=74daaa2cc87cea237619fec03afdf28a8095f65f;hb=7ae40733a270f73ec8a331540cc7f28fd60b24fc;hp=68f7fc389bb70948c1a22255af0cec275ba0ca5a;hpb=0470f6d037aacb3563c3f7010708120a4a67d4e6;p=mothur.git diff --git a/globaldata.cpp b/globaldata.cpp index 68f7fc3..74daaa2 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -1,6 +1,9 @@ + + #include "globaldata.hpp" -#include "tree.h" -#include "sparsematrix.hpp" +#include "sharedlistvector.h" +#include "inputdata.h" +#include "fullmatrix.h" /*******************************************************/ @@ -23,25 +26,24 @@ string GlobalData::getSabundFile() { return sabundfile; } string GlobalData::getNameFile() { return namefile; } string GlobalData::getGroupFile() { return groupfile; } string GlobalData::getOrderFile() { return orderfile; } +string GlobalData::getOrderGroupFile() { return ordergroup; } string GlobalData::getTreeFile() { return treefile; } -string GlobalData::getSharedFile() { return sharedfile; } -string GlobalData::getFastaFile() { return fastafile; } +string GlobalData::getSharedFile() { return sharedfile; } +string GlobalData::getRelAbundFile() { return relAbundfile; } string GlobalData::getFormat() { return format; } -string GlobalData::getCandidateFile() { return candidatefile; } - void GlobalData::setListFile(string file) { listfile = file; inputFileName = file; } -void GlobalData::setFastaFile(string file) { fastafile = file; inputFileName = file; } void GlobalData::setTreeFile(string file) { treefile = file; inputFileName = file; } -void GlobalData::setCandidateFile(string file) { candidatefile = file; } void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file; } void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file; } void GlobalData::setPhylipFile(string file) { phylipfile = file; inputFileName = file; } void GlobalData::setColumnFile(string file) { columnfile = file; inputFileName = file; } void GlobalData::setGroupFile(string file) { groupfile = file; } void GlobalData::setSharedFile(string file) { sharedfile = file; inputFileName = file; } +void GlobalData::setRelAbundFile(string file) { relAbundfile = file; inputFileName = file; } void GlobalData::setNameFile(string file) { namefile = file; } void GlobalData::setOrderFile(string file) { orderfile = file; } +void GlobalData::setOrderGroupFile(string file) { ordergroup = file; } void GlobalData::setFormat(string Format) { format = Format; } @@ -49,50 +51,90 @@ void GlobalData::setFormat(string Format) { format = Format; } /******************************************************/ GlobalData::GlobalData() { + m = MothurOut::getInstance(); //option definitions should go here... 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; + nameMap = NULL; } /*******************************************************/ /******************************************************/ void GlobalData::clear() { //option definitions should go here... - phylipfile = ""; - columnfile = ""; + phylipfile = ""; //do we need this? + columnfile = ""; //do we need this? listfile = ""; rabundfile = ""; sabundfile = ""; - namefile = ""; - groupfile = ""; + namefile = ""; //do we need this? + groupfile = ""; //do we need this? orderfile = ""; - fastafile = ""; + ordergroup = ""; +// fastafile = ""; //do we need this? treefile = ""; sharedfile = ""; - candidatefile = ""; + relAbundfile = ""; + format = ""; } + + /*******************************************************/ /******************************************************/ 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;} + + if (nameMap != NULL) { delete nameMap; nameMap = NULL; } + + gTree.clear(); Treenames.clear(); - labels.clear(); lines.clear(); Groups.clear(); + labels.clear(); Groups.clear(); allLines = 1; runParse = true; + names.clear(); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the GlobalData class function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "GlobalData", "newRead"); exit(1); } } @@ -102,9 +144,25 @@ 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;} + if (nameMap != NULL) { delete nameMap; nameMap = NULL; } + } + catch(exception& e) { + m->errorOut(e, "GlobalData", "~GlobalData"); + exit(1); + } } /*******************************************************/