m = MothurOut::getInstance();
m->openInputFile(fName, fileHandle);
filename = fName;
+ m->saveNextLabel = "";
}
-
/***********************************************************************/
-
InputData::~InputData(){
fileHandle.close();
-// delete output;
-
+ m->saveNextLabel = "";
}
/***********************************************************************/
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
}
-
+
m->gobble(fileHandle);
output = new OrderVector();
}
}
-
+
in.close();
output = new OrderVector();
}
}else if (format == "shared") {
SharedList = new SharedListVector(fileHandle);
+
if (SharedList != NULL) {
return SharedList->getSharedRAbundVector();
}
string thisLabel;
m->openInputFile(filename, in);
-
+ m->saveNextLabel = "";
+
if(in){
if (format == "sharedfile") {
while (in.eof() != true) {
SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
if (SharedRAbund != NULL) {
thisLabel = SharedRAbund->getLabel();
+
//if you are at the last label
if (thisLabel == label) { in.close(); return SharedRAbund->getSharedRAbundVectors(); }
else {
while (in.eof() != true) {
SharedList = new SharedListVector(in);
+
if (SharedList != NULL) {
thisLabel = SharedList->getLabel();
//if you are at the last label
if (SharedRelAbund != NULL) {
return SharedRelAbund->getSharedRAbundFloatVectors();
}
+ }else if (format == "sharedfile") {
+ SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
+ if (SharedRAbund != NULL) {
+ vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors();
+ vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup);
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
+ return lookupFloat;
+ }
+
}
m->gobble(fileHandle);
}
string thisLabel;
m->openInputFile(filename, in);
+ m->saveNextLabel = "";
if(in){
- if (format == "sharedfile") {
+ if (format == "relabund") {
while (in.eof() != true) {
SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(in);
}else{ break; }
m->gobble(in);
}
- }
+ }else if (format == "sharedfile") {
+ while (in.eof() != true) {
+
+ SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
+ if (SharedRAbund != NULL) {
+ thisLabel = SharedRAbund->getLabel();
+
+ //if you are at the last label
+ if (thisLabel == label) {
+ in.close();
+ vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors();
+ vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup);
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
+ return lookupFloat;
+ }else {
+ //so you don't loose this memory
+ vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors();
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
+ delete SharedRAbund;
+ }
+ }else{ break; }
+ m->gobble(in);
+ }
+ }
}
+
//this is created to signal to calling function that the input file is at eof
vector<SharedRAbundFloatVector*> null; null.push_back(NULL);
}
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
- }
-
+ }
m->gobble(fileHandle);
sabund = new SAbundVector();
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
}
-
+
m->gobble(fileHandle);
rabund = new RAbundVector();
}
- }
+ }
+
in.close();