InputData::InputData(string fName, string f) : format(f){
m = MothurOut::getInstance();
- openInputFile(fName, fileHandle);
+ m->openInputFile(fName, fileHandle);
filename = fName;
-
+ m->saveNextLabel = "";
}
-
/***********************************************************************/
-
InputData::~InputData(){
fileHandle.close();
-// delete output;
-
+ m->saveNextLabel = "";
}
/***********************************************************************/
try {
m = MothurOut::getInstance();
ifstream ofHandle;
- openInputFile(orderFileName, ofHandle);
+ m->openInputFile(orderFileName, ofHandle);
string name;
int count = 0;
ofHandle >> name;
orderMap[name] = count;
count++;
- gobble(ofHandle);
+ m->gobble(ofHandle);
}
ofHandle.close();
- openInputFile(fName, fileHandle);
+ m->openInputFile(fName, fileHandle);
+ m->saveNextLabel = "";
+
}
catch(exception& e) {
m->errorOut(e, "InputData", "InputData");
list = new ListVector(fileHandle);
}else{ list = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return list;
}
else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete list; }
- gobble(in);
+ m->gobble(in);
}
}else{ list = NULL; }
while (fileHandle.eof() != true) {
- list = new ListVector(fileHandle); gobble(fileHandle);
+ list = new ListVector(fileHandle); m->gobble(fileHandle);
thisLabel = list->getLabel();
//if you are at the last label
SharedList = new SharedListVector(fileHandle);
}else{ SharedList = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return SharedList;
}
else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete SharedList; }
- gobble(in);
+ m->gobble(in);
}
}else{ SharedList = NULL; }
SharedOrder = new SharedOrderVector(fileHandle);
}else{ SharedOrder = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return SharedOrder;
}else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete SharedOrder; }
- gobble(in);
+ m->gobble(in);
}
}else{ SharedOrder = NULL; }
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
}
-
- gobble(fileHandle);
+
+ m->gobble(fileHandle);
output = new OrderVector();
*output = (input->getOrderVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if((format == "list") || (format == "listorder")) {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
-
+
in.close();
output = new OrderVector();
}
}else if (format == "shared") {
SharedList = new SharedListVector(fileHandle);
+
if (SharedList != NULL) {
return SharedList->getSharedRAbundVector();
}
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
//this is created to signal to calling function that the input file is at eof
ifstream in;
string thisLabel;
- openInputFile(filename, in);
-
+ 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 {
delete SharedRAbund;
}
}else{ break; }
- gobble(in);
+ m->gobble(in);
}
}else if (format == "shared") {
while (in.eof() != true) {
SharedList = new SharedListVector(in);
+
if (SharedList != NULL) {
thisLabel = SharedList->getLabel();
//if you are at the last label
delete SharedList;
}
}else{ break; }
- gobble(in);
+ m->gobble(in);
}
}
}
-
+/***********************************************************************/
+//this is used when you don't need the order vector
+vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(){
+ try {
+ if(fileHandle){
+ if (format == "relabund") {
+ SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(fileHandle);
+ 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);
+ }
+
+ //this is created to signal to calling function that the input file is at eof
+ vector<SharedRAbundFloatVector*> null; null.push_back(NULL);
+ return null;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
+ exit(1);
+ }
+}
+/***********************************************************************/
+vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(string label){
+ try {
+ ifstream in;
+ string thisLabel;
+
+ m->openInputFile(filename, in);
+ m->saveNextLabel = "";
+
+ if(in){
+ if (format == "relabund") {
+ 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<SharedRAbundFloatVector*> lookup = SharedRelAbund->getSharedRAbundFloatVectors();
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ delete SharedRelAbund;
+ }
+ }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);
+ in.close();
+ return null;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
+ exit(1);
+ }
+}
/***********************************************************************/
SAbundVector* InputData::getSAbundVector(){
}
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
- }
-
- gobble(fileHandle);
+ }
+ m->gobble(fileHandle);
sabund = new SAbundVector();
*sabund = (input->getSAbundVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (format == "list") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
else if(format == "sabund"){
input = new SAbundVector(fileHandle);
}
-
- gobble(fileHandle);
+
+ m->gobble(fileHandle);
rabund = new RAbundVector();
*rabund = (input->getRAbundVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (format == "list") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
- }
+ }
+
in.close();