5 * Created by Sarah Westcott on 11/18/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "inputdata.h"
11 #include "ordervector.hpp"
12 #include "listvector.hpp"
13 #include "rabundvector.hpp"
15 /***********************************************************************/
17 InputData::InputData(string fName, string f) : format(f){
19 openInputFile(fName, fileHandle);
23 /***********************************************************************/
26 InputData::~InputData(){
32 /***********************************************************************/
34 InputData::InputData(string fName, string orderFileName, string f) : format(f){
38 openInputFile(orderFileName, ofHandle);
45 orderMap[name] = count;
51 openInputFile(fName, fileHandle);
54 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
58 cout << "An unknown error has occurred in the InputData class function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 /***********************************************************************/
64 ListVector* InputData::getListVector(){
67 if(format == "list") {
68 list = new ListVector(fileHandle);
79 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
83 cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
88 /***********************************************************************/
90 SharedListVector* InputData::getSharedListVector(){
93 if (format == "shared") {
94 SharedList = new SharedListVector(fileHandle);
104 catch(exception& e) {
105 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
109 cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
114 /***********************************************************************/
116 SharedOrderVector* InputData::getSharedOrderVector(){
119 if (format == "sharedfile") {
120 SharedOrder = new SharedOrderVector(fileHandle);
130 catch(exception& e) {
131 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
135 cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
142 /***********************************************************************/
144 OrderVector* InputData::getOrderVector(){
147 if(format == "list") {
148 input = new ListVector(fileHandle);
150 else if (format == "shared") {
151 input = new SharedListVector(fileHandle);
153 else if(format == "rabund"){
154 input = new RAbundVector(fileHandle);
156 else if(format == "order"){
157 input = new OrderVector(fileHandle);
159 else if(format == "sabund"){
160 input = new SAbundVector(fileHandle);
162 else if(format == "listorder"){
163 input = new ListVector(fileHandle);
167 output = new OrderVector();
168 *output = (input->getOrderVector());
176 catch(exception& e) {
177 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
181 cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
185 /***********************************************************************/
187 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
190 if (format == "sharedfile") {
191 SharedOrder = new SharedOrderVector(fileHandle);
192 if (SharedOrder != NULL) {
193 return SharedOrder->getSharedRAbundVector();
195 }else if (format == "shared") {
196 SharedList = new SharedListVector(fileHandle);
197 if (SharedList != NULL) {
198 return SharedList->getSharedRAbundVector();
204 //this is created to signal to calling function that the input file is at eof
205 vector<SharedRAbundVector*> null; null.push_back(NULL);
209 catch(exception& e) {
210 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
214 cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
219 /***********************************************************************/
221 SAbundVector* InputData::getSAbundVector(){
224 if (format == "list") {
225 input = new ListVector(fileHandle);
227 else if (format == "shared") {
228 input = new SharedListVector(fileHandle);
230 else if(format == "rabund"){
231 input = new RAbundVector(fileHandle);
233 else if(format == "order"){
234 input = new OrderVector(fileHandle);
236 else if(format == "sabund"){
237 input = new SAbundVector(fileHandle);
242 sabund = new SAbundVector();
243 *sabund = (input->getSAbundVector());
251 catch(exception& e) {
252 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
256 cout << "An unknown error has occurred in the InputData class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
261 /***********************************************************************/
262 RAbundVector* InputData::getRAbundVector(){
265 if (format == "list") {
266 input = new ListVector(fileHandle);
268 else if (format == "shared") {
269 input = new SharedListVector(fileHandle);
271 else if(format == "rabund"){
272 input = new RAbundVector(fileHandle);
274 else if(format == "order"){
275 input = new OrderVector(fileHandle);
277 else if(format == "sabund"){
278 input = new SAbundVector(fileHandle);
283 rabund = new RAbundVector();
284 *rabund = (input->getRAbundVector());
292 catch(exception& e) {
293 cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
297 cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
301 /***********************************************************************/