X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readotu.cpp;h=98a63f05cdbea47c62c9dc07d7fd8c65dec35319;hb=a3d9877d9c62058dbe167ceca159f4b76744f1cf;hp=971ed31ae005e15b3ec0785a9728311ef6ca12f8;hpb=d59f91eb1230d2c7867a92cb86138b7003100ab4;p=mothur.git diff --git a/readotu.cpp b/readotu.cpp index 971ed31..98a63f0 100644 --- a/readotu.cpp +++ b/readotu.cpp @@ -12,14 +12,15 @@ /***********************************************************************/ ReadOTUFile::ReadOTUFile(string pf): philFile(pf){ - - openInputFile(philFile, fileHandle); + m = MothurOut::getInstance(); + //openInputFile(philFile, fileHandle); } /***********************************************************************/ //This function reads the list, rabund or sabund files to be used by collect and rarefact command. void ReadOTUFile::read(GlobalData* globaldata){ try { + if (globaldata->getOrderFile() == "") { //you have two inputs because in the next if statement if you only have one then it moves ahead in the same file. //So when you run the collect or summary commands you miss a line. @@ -30,35 +31,46 @@ void ReadOTUFile::read(GlobalData* globaldata){ }else {//there is an orderfile input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat()); } - + //memory leak prevention //if (globaldata->ginput != NULL) { delete globaldata->ginput; } globaldata->ginput = input; //saving to be used by collector and rarefact commands. - + if ((globaldata->getFormat() == "list") || (globaldata->getFormat() == "rabund") || (globaldata->getFormat() == "sabund")) {//you are reading a list, rabund or sabund file for collect, rarefaction or summary. + +//cout << input << '\t' << globaldata << endl; order = input->getOrderVector(); //memory leak prevention + //if (globaldata->gorder != NULL) { delete globaldata->gorder; } globaldata->gorder = order; //saving to be used by collect and rarefact commands. sabund = inputSabund->getSAbundVector(); + //if (globaldata->sabund != NULL) { delete globaldata->sabund; } globaldata->sabund = sabund; //saving to be used by summary command. + delete inputSabund; + rabund = inputRabund->getRAbundVector(); - globaldata->rabund = rabund; //saving to be used by heatmap command. + //if (globaldata->rabund != NULL) { delete globaldata->rabund; } + globaldata->rabund = rabund; //saving to be used by heatmap.bin command. + delete inputRabund; + list = inputList->getListVector(); + //if (globaldata->gListVector != NULL) { delete globaldata->gListVector; } globaldata->gListVector = list; + delete inputList; + }else if (globaldata->getFormat() == "shared") { SharedList = input->getSharedListVector(); //you are reading for collect.shared, rarefaction.shared, summary.shared, parselist command, or shared commands. //memory leak prevention //if (globaldata->gSharedList != NULL) { delete globaldata->gSharedList; } globaldata->gSharedList = SharedList; + delete inputSabund; + delete inputRabund; + delete inputList; } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ReadOTUFile class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the ReadOTUFile class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "ReadOTUFile", "read"); exit(1); } }