X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=inputdata.cpp;fp=inputdata.cpp;h=a4d66921629cc700f2042d676f9e52e50674ba56;hb=7ae40733a270f73ec8a331540cc7f28fd60b24fc;hp=7c9fbe9c0eeda1472e09ce03c80cd5853103833e;hpb=260ae19c36cb11a53ddc5a75b5e507f8dd8b31d6;p=mothur.git diff --git a/inputdata.cpp b/inputdata.cpp index 7c9fbe9..a4d6692 100644 --- a/inputdata.cpp +++ b/inputdata.cpp @@ -503,7 +503,70 @@ vector InputData::getSharedRAbundVectors(string label){ } } - +/***********************************************************************/ +//this is used when you don't need the order vector +vector InputData::getSharedRAbundFloatVectors(){ + try { + if(fileHandle){ + if (format == "relabund") { + SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(fileHandle); + if (SharedRelAbund != NULL) { + return SharedRelAbund->getSharedRAbundFloatVectors(); + } + } + m->gobble(fileHandle); + } + + //this is created to signal to calling function that the input file is at eof + vector null; null.push_back(NULL); + return null; + + } + catch(exception& e) { + m->errorOut(e, "InputData", "getSharedRAbundFloatVectors"); + exit(1); + } +} +/***********************************************************************/ +vector InputData::getSharedRAbundFloatVectors(string label){ + try { + ifstream in; + string thisLabel; + + m->openInputFile(filename, in); + + if(in){ + if (format == "sharedfile") { + while (in.eof() != true) { + + SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(in); + if (SharedRelAbund != NULL) { + thisLabel = SharedRelAbund->getLabel(); + //if you are at the last label + if (thisLabel == label) { in.close(); return SharedRelAbund->getSharedRAbundFloatVectors(); } + else { + //so you don't loose this memory + vector lookup = SharedRelAbund->getSharedRAbundFloatVectors(); + for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } + delete SharedRelAbund; + } + }else{ break; } + m->gobble(in); + } + } + } + + //this is created to signal to calling function that the input file is at eof + vector null; null.push_back(NULL); + in.close(); + return null; + + } + catch(exception& e) { + m->errorOut(e, "InputData", "getSharedRAbundFloatVectors"); + exit(1); + } +} /***********************************************************************/ SAbundVector* InputData::getSAbundVector(){