]> git.donarmstrong.com Git - mothur.git/blob - inputdata.cpp
fixes while testing 1.33.0
[mothur.git] / inputdata.cpp
1 /*
2  *  inputdata.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 11/18/08.
6  *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "inputdata.h"
11 #include "ordervector.hpp"
12 #include "listvector.hpp"
13 #include "rabundvector.hpp"
14
15 /***********************************************************************/
16
17 InputData::InputData(string fName, string f) : format(f){
18         m = MothurOut::getInstance();
19         m->openInputFile(fName, fileHandle);
20         filename = fName;
21         m->saveNextLabel = "";
22 }
23 /***********************************************************************/
24
25 InputData::~InputData(){
26         fileHandle.close();
27         m->saveNextLabel = "";
28 }
29
30 /***********************************************************************/
31
32 InputData::InputData(string fName, string orderFileName, string f) : format(f){
33         try {
34                 m = MothurOut::getInstance();
35                 ifstream ofHandle;
36                 m->openInputFile(orderFileName, ofHandle);
37                 string name;
38
39                 int count = 0;
40         
41                 while(ofHandle){
42                         ofHandle >> name;
43                         orderMap[name] = count;
44                         count++;
45                         m->gobble(ofHandle);
46                 }
47                 ofHandle.close();
48         
49                 m->openInputFile(fName, fileHandle);
50                 m->saveNextLabel = "";
51                 
52         }
53         catch(exception& e) {
54                 m->errorOut(e, "InputData", "InputData");
55                 exit(1);
56         }
57 }
58 /***********************************************************************/
59
60 ListVector* InputData::getListVector(){
61         try {
62                 if(!fileHandle.eof()){
63                         if(format == "list") {
64                                 list = new ListVector(fileHandle);
65                         }else{ list = NULL;  }
66                                         
67                         m->gobble(fileHandle);
68                         return list;
69                 }
70                 else{
71                         return NULL;
72                 }
73         }
74         catch(exception& e) {
75                 m->errorOut(e, "InputData", "getListVector");
76                 exit(1);
77         }
78 }
79
80 /***********************************************************************/
81 ListVector* InputData::getListVector(string label){
82         try {
83                 ifstream in;
84                 string  thisLabel;
85                 m->openInputFile(filename, in);
86         m->saveNextLabel = "";
87                 
88                 if(in){
89
90                         if (format == "list") {
91                         
92                                 while (in.eof() != true) {
93                                         
94                                         list = new ListVector(in);
95                                         thisLabel = list->getLabel();
96                                         
97                                         //if you are at the last label
98                                         if (thisLabel == label) {  break;  }
99                                         //so you don't loose this memory
100                                         else {  delete list;    }
101                                         m->gobble(in);
102                                 }
103                         }else{ list = NULL;  }
104                         
105                         in.close();
106                         return list;
107                 }
108                 else{
109                         return NULL;
110                 }
111         }
112         catch(exception& e) {
113                 m->errorOut(e, "InputData", "getListVector");
114                 exit(1);
115         }
116 }
117 /***********************************************************************/
118 ListVector* InputData::getListVector(string label, bool resetFP){
119         try {
120                 string  thisLabel;
121                 fileHandle.clear();
122                 fileHandle.seekg(0);
123         m->saveNextLabel = "";
124                 
125                 if(fileHandle){
126
127                         if (format == "list") {
128                         
129                                 while (fileHandle.eof() != true) {
130                                         
131                                         list = new ListVector(fileHandle); m->gobble(fileHandle);
132                                         thisLabel = list->getLabel();
133                                         
134                                         //if you are at the last label
135                                         if (thisLabel == label) {  break;  }
136                                         //so you don't loose this memory
137                                         else {  delete list;    }
138                                 }
139                         }else{ list = NULL;  }
140                 
141                         return list;
142                 }
143                 else{
144                         return NULL;
145                 }
146         }
147         catch(exception& e) {
148                 m->errorOut(e, "InputData", "getListVector");
149                 exit(1);
150         }
151 }
152
153 /***********************************************************************/
154
155 SharedListVector* InputData::getSharedListVector(){
156         try {
157                 if(fileHandle){
158                         if (format == "shared")  {
159                                 SharedList = new SharedListVector(fileHandle);
160                         }else{ SharedList = NULL;  }
161                                         
162                         m->gobble(fileHandle);
163                         return SharedList;
164                 }
165                 else{
166                         return NULL;
167                 }
168         }
169         catch(exception& e) {
170                 m->errorOut(e, "InputData", "getSharedListVector");
171                 exit(1);
172         }
173 }
174 /***********************************************************************/
175
176 SharedListVector* InputData::getSharedListVector(string label){
177         try {
178                 ifstream in;
179                 string  thisLabel;
180                 m->openInputFile(filename, in);
181                 
182                 if(in){
183
184                         if (format == "shared")  {
185                         
186                                 while (in.eof() != true) {
187                                         
188                                         SharedList = new SharedListVector(in);
189                                         thisLabel = SharedList->getLabel();
190                                         
191                                         //if you are at the last label
192                                         if (thisLabel == label) {  break;  }
193                                         //so you don't loose this memory
194                                         else {  delete SharedList;      }
195                                         m->gobble(in);
196                                 }
197
198                         }else{ SharedList = NULL;  }
199                                 
200                         in.close();
201                         return SharedList;
202                         
203                 }else{
204                         return NULL;
205                 }
206         }
207         catch(exception& e) {
208                 m->errorOut(e, "InputData", "getSharedListVector");
209                 exit(1);
210         }
211 }
212
213
214
215 /***********************************************************************/
216
217 SharedOrderVector* InputData::getSharedOrderVector(){
218         try {
219                 if(fileHandle){
220                         if (format == "sharedfile")  {
221                                 SharedOrder = new SharedOrderVector(fileHandle);
222                         }else{ SharedOrder = NULL;  }
223                                 
224                         m->gobble(fileHandle);
225                         return SharedOrder;
226                         
227                 }else{
228                         return NULL;
229                 }
230         }
231         catch(exception& e) {
232                 m->errorOut(e, "InputData", "getSharedOrderVector");
233                 exit(1);
234         }
235 }
236
237 /***********************************************************************/
238
239 SharedOrderVector* InputData::getSharedOrderVector(string label){
240         try {
241                 ifstream in;
242                 string  thisLabel;
243                 m->openInputFile(filename, in);
244         m->saveNextLabel = "";
245                 
246                 if(in){
247
248                         if (format == "sharedfile")  {
249                         
250                                 while (in.eof() != true) {
251                                         
252                                         SharedOrder = new SharedOrderVector(in);
253                                         thisLabel = SharedOrder->getLabel();
254                                         
255                                         //if you are at the last label
256                                         if (thisLabel == label) {  break;  }
257                                         //so you don't loose this memory
258                                         else {  delete SharedOrder;     }
259                                         m->gobble(in);
260                                 }
261
262                         }else{ SharedOrder = NULL;  }
263                                 
264                         in.close();
265                         return SharedOrder;
266                         
267                 }else{
268                         return NULL;
269                 }
270         }
271         catch(exception& e) {
272                 m->errorOut(e, "InputData", "getSharedOrderVector");
273                 exit(1);
274         }
275 }
276
277
278
279 /***********************************************************************/
280
281 OrderVector* InputData::getOrderVector(){
282         try {
283                 if(fileHandle){
284                         if((format == "list") || (format == "listorder")) {
285                                 input = new ListVector(fileHandle);
286                         }
287                         else if (format == "shared")  {
288                                 input = new SharedListVector(fileHandle);
289                         }
290                         else if(format == "rabund"){
291                                 input = new RAbundVector(fileHandle);
292                         }
293                         else if(format == "order"){             
294                                 input = new OrderVector(fileHandle);
295                         }
296                         else if(format == "sabund"){
297                                 input = new SAbundVector(fileHandle);
298                         }
299                                                 
300                         m->gobble(fileHandle);
301                         
302                         output = new OrderVector();     
303                         *output = (input->getOrderVector());
304                 
305                         return output;
306                 }
307                 else{
308                         return NULL;
309                 }
310         }
311         catch(exception& e) {
312                 m->errorOut(e, "InputData", "getOrderVector");
313                 exit(1);
314         }
315 }
316
317 /***********************************************************************/
318 OrderVector* InputData::getOrderVector(string label){
319         try {
320         
321                 ifstream in;
322                 string  thisLabel;
323                 m->openInputFile(filename, in);
324                 
325                 if(in){
326                         if((format == "list") || (format == "listorder")) {
327                 m->saveNextLabel = "";
328                                 while (in.eof() != true) {
329                                         
330                                         input = new ListVector(in);
331                                         thisLabel = input->getLabel();
332                                         
333                                         //if you are at the last label
334                                         if (thisLabel == label) {  break;  }
335                                         //so you don't loose this memory
336                                         else {  delete input;   }
337                                         m->gobble(in);
338                                 }
339                         }
340                         else if (format == "shared")  {
341                                 m->saveNextLabel = "";
342                                 while (in.eof() != true) {
343                                         
344                                         input = new SharedListVector(in);
345                                         thisLabel = input->getLabel();
346                                         
347                                         //if you are at the last label
348                                         if (thisLabel == label) {  break;  }
349                                         //so you don't loose this memory
350                                         else {  delete input;   }
351                                         m->gobble(in);
352                                 }
353
354                         }
355                         else if(format == "rabund"){
356                                 
357                                 while (in.eof() != true) {
358                                         
359                                         input = new RAbundVector(in);
360                                         thisLabel = input->getLabel();
361                                         
362                                         //if you are at the last label
363                                         if (thisLabel == label) {  break;  }
364                                         //so you don't loose this memory
365                                         else {  delete input;   }
366                                         m->gobble(in);
367                                 }
368
369                         }
370                         else if(format == "order"){                     
371                                 
372                                 while (in.eof() != true) {
373                                         
374                                         input = new OrderVector(in);
375                                         thisLabel = input->getLabel();
376                                         
377                                         //if you are at the last label
378                                         if (thisLabel == label) {  break;  }
379                                         //so you don't loose this memory
380                                         else {  delete input;   }
381                                         m->gobble(in);
382                                 }
383
384                         }
385                         else if(format == "sabund"){
386                                 
387                                 while (in.eof() != true) {
388                                         
389                                         input = new SAbundVector(in);
390                                         thisLabel = input->getLabel();
391                                         
392                                         //if you are at the last label
393                                         if (thisLabel == label) {  break;  }
394                                         //so you don't loose this memory
395                                         else {  delete input;   }
396                                         m->gobble(in);
397                                         
398                                 }
399
400                         }
401                                                 
402                         in.close();             
403
404                         output = new OrderVector();
405                         *output = (input->getOrderVector());
406                         
407                         return output;
408
409                 }
410                 else{
411                         return NULL;
412                 }
413         }
414         catch(exception& e) {
415                 m->errorOut(e, "InputData", "getOrderVector");
416                 exit(1);
417         }
418 }
419
420 /***********************************************************************/
421 //this is used when you don't need the order vector
422 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
423         try {
424                 if(fileHandle){
425                         if (format == "sharedfile")  {
426                                 SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
427                                 if (SharedRAbund != NULL) {
428                                         return SharedRAbund->getSharedRAbundVectors();
429                                 }
430                         }else if (format == "shared") {
431                                 SharedList = new SharedListVector(fileHandle);
432                                 
433                                 if (SharedList != NULL) {
434                                         return SharedList->getSharedRAbundVector();
435                                 }
436                         }
437                         m->gobble(fileHandle);
438                 }
439                                 
440                 //this is created to signal to calling function that the input file is at eof
441                 vector<SharedRAbundVector*> null;  null.push_back(NULL);
442                 return null;
443                 
444         }
445         catch(exception& e) {
446                 m->errorOut(e, "InputData", "getSharedRAbundVectors");
447                 exit(1);
448         }
449 }
450 /***********************************************************************/
451 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
452         try {
453                 ifstream in;
454                 string  thisLabel;
455                 
456                 m->openInputFile(filename, in);
457                 m->saveNextLabel = "";
458         
459                 if(in){
460                         if (format == "sharedfile")  {
461                                 while (in.eof() != true) {
462                                         
463                                         SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
464                                         if (SharedRAbund != NULL) {
465                                                 thisLabel = SharedRAbund->getLabel();
466                                         
467                                                 //if you are at the last label
468                                                 if (thisLabel == label) {  in.close(); return SharedRAbund->getSharedRAbundVectors();  }
469                                                 else {
470                                                         //so you don't loose this memory
471                                                         vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
472                                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
473                                                         delete SharedRAbund;
474                                                 }
475                                         }else{  break;  }
476                                         m->gobble(in);
477                                         
478                                 }
479                         }else if (format == "shared") {
480                                 while (in.eof() != true) {
481                                         
482                                         SharedList = new SharedListVector(in);
483                                         
484                                         if (SharedList != NULL) {
485                                                 thisLabel = SharedList->getLabel();
486                                                 //if you are at the last label
487                                                 if (thisLabel == label) {  in.close(); return SharedList->getSharedRAbundVector();  }
488                                                 else {
489                                                         //so you don't loose this memory
490                                                         delete SharedList;
491                                                 }
492                                         }else{  break;  }
493                                         m->gobble(in);
494                                         
495                                 }
496                         
497                         }
498                 }
499                                 
500                 //this is created to signal to calling function that the input file is at eof
501                 vector<SharedRAbundVector*> null;  null.push_back(NULL);
502                 in.close();
503                 return null;
504         
505         }
506         catch(exception& e) {
507                 m->errorOut(e, "InputData", "getSharedRAbundVectors");
508                 exit(1);
509         }
510 }
511
512 /***********************************************************************/
513 //this is used when you don't need the order vector
514 vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(){
515         try {
516                 if(fileHandle){
517                         if (format == "relabund")  {
518                                 SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(fileHandle);
519                                 if (SharedRelAbund != NULL) {
520                                         return SharedRelAbund->getSharedRAbundFloatVectors();
521                                 }
522                         }else if (format == "sharedfile")  {
523                                 SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
524                                 if (SharedRAbund != NULL) {
525                                         vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
526                                         vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup); 
527                                         for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
528                                         return lookupFloat;  
529                                 }
530                                                 
531                         }
532                         m->gobble(fileHandle);
533                 }
534                                 
535                 //this is created to signal to calling function that the input file is at eof
536                 vector<SharedRAbundFloatVector*> null;  null.push_back(NULL);
537                 return null;
538                 
539         }
540         catch(exception& e) {
541                 m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
542                 exit(1);
543         }
544 }
545 /***********************************************************************/
546 vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(string label){
547         try {
548                 ifstream in;
549                 string  thisLabel;
550                 
551                 m->openInputFile(filename, in);
552                 m->saveNextLabel = "";
553                 
554                 if(in){
555                         if (format == "relabund")  {
556                                 while (in.eof() != true) {
557                                         
558                                         SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(in);
559                                         if (SharedRelAbund != NULL) {
560                                                 thisLabel = SharedRelAbund->getLabel();
561                                                 //if you are at the last label
562                                                 if (thisLabel == label) {  in.close(); return SharedRelAbund->getSharedRAbundFloatVectors();  }
563                                                 else {
564                                                         //so you don't loose this memory
565                                                         vector<SharedRAbundFloatVector*> lookup = SharedRelAbund->getSharedRAbundFloatVectors(); 
566                                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
567                                                         delete SharedRelAbund;
568                                                 }
569                                         }else{  break;  }
570                                         m->gobble(in);
571                                 }
572                         }else if (format == "sharedfile")  {
573                                 while (in.eof() != true) {
574                                         
575                                         SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
576                                         if (SharedRAbund != NULL) {
577                                                 thisLabel = SharedRAbund->getLabel();
578                                                 
579                                                 //if you are at the last label
580                                                 if (thisLabel == label) {  
581                                                         in.close(); 
582                                                         vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
583                                                         vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup); 
584                                                         for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
585                                                         return lookupFloat;  
586                                                 }else {
587                                                         //so you don't loose this memory
588                                                         vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
589                                                         for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
590                                                         delete SharedRAbund;
591                                                 }
592                                         }else{  break;  }
593                                         m->gobble(in);
594                                 }
595                         }       
596                 }
597                 
598                                 
599                 //this is created to signal to calling function that the input file is at eof
600                 vector<SharedRAbundFloatVector*> null;  null.push_back(NULL);
601                 in.close();
602                 return null;
603         
604         }
605         catch(exception& e) {
606                 m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
607                 exit(1);
608         }
609 }
610 /***********************************************************************/
611
612 SAbundVector* InputData::getSAbundVector(){
613         try {
614                 if(fileHandle){
615                         if (format == "list") {
616                                 input = new ListVector(fileHandle);
617                         }
618                         else if (format == "shared")  {
619                                 input = new SharedListVector(fileHandle);
620                         }
621                         else if(format == "rabund"){
622                                 input = new RAbundVector(fileHandle);
623                         }
624                         else if(format == "order"){                     
625                                 input = new OrderVector(fileHandle);
626                         }
627                         else if(format == "sabund"){
628                                 input = new SAbundVector(fileHandle);
629                         }                                       
630                         m->gobble(fileHandle);
631
632                         sabund = new SAbundVector();
633                         *sabund = (input->getSAbundVector());
634
635                         return sabund;
636                 }
637                 else{
638                         return NULL;
639                 }
640         }
641         catch(exception& e) {
642                 m->errorOut(e, "InputData", "getSAbundVector");
643                 exit(1);
644         }
645 }
646 /***********************************************************************/
647 SAbundVector* InputData::getSAbundVector(string label){
648         try {
649         
650                 ifstream in;
651                 string  thisLabel;
652                 m->openInputFile(filename, in);
653                 
654                 if(in){
655                         if (format == "list") {
656                 m->saveNextLabel = "";
657                                 while (in.eof() != true) {
658                                         
659                                         input = new ListVector(in);
660                                         thisLabel = input->getLabel();
661                                         
662                                         //if you are at the last label
663                                         if (thisLabel == label) {  break;  }
664                                         //so you don't loose this memory
665                                         else {  delete input;   }
666                                         m->gobble(in);
667                                 }
668                         }
669                         else if (format == "shared")  {
670                                 m->saveNextLabel = "";
671                                 while (in.eof() != true) {
672                                         
673                                         input = new SharedListVector(in);
674                                         thisLabel = input->getLabel();
675                                         
676                                         //if you are at the last label
677                                         if (thisLabel == label) {  break;  }
678                                         //so you don't loose this memory
679                                         else {  delete input;   }
680                                         m->gobble(in);
681                                 }
682
683                         }
684                         else if(format == "rabund"){
685                                 
686                                 while (in.eof() != true) {
687                                         
688                                         input = new RAbundVector(in);
689                                         thisLabel = input->getLabel();
690                                         
691                                         //if you are at the last label
692                                         if (thisLabel == label) {  break;  }
693                                         //so you don't loose this memory
694                                         else {  delete input;   }
695                                         m->gobble(in);
696                                 }
697
698                         }
699                         else if(format == "order"){                     
700                                 
701                                 while (in.eof() != true) {
702                                         
703                                         input = new OrderVector(in);
704                                         thisLabel = input->getLabel();
705                                         
706                                         //if you are at the last label
707                                         if (thisLabel == label) {  break;  }
708                                         //so you don't loose this memory
709                                         else {  delete input;   }
710                                         m->gobble(in);
711                                 }
712
713                         }
714                         else if(format == "sabund"){
715                                 
716                                 while (in.eof() != true) {
717                                         
718                                         input = new SAbundVector(in);
719                                         thisLabel = input->getLabel();
720                                         
721                                         //if you are at the last label
722                                         if (thisLabel == label) {  break;  }
723                                         //so you don't loose this memory
724                                         else {  delete input;   }
725                                         m->gobble(in);
726                                         
727                                 }
728
729                         }
730                         
731                         in.close();             
732
733                         sabund = new SAbundVector();
734                         *sabund = (input->getSAbundVector());
735
736                         return sabund;
737
738                 }
739                 else{
740                         return NULL;
741                 }
742         }
743         catch(exception& e) {
744                 m->errorOut(e, "InputData", "getSAbundVector");
745                 exit(1);
746         }
747 }
748
749 /***********************************************************************/
750 RAbundVector* InputData::getRAbundVector(){
751         try {
752                 if(fileHandle){
753                         if (format == "list") {
754                                 input = new ListVector(fileHandle);
755                         }
756                         else if (format == "shared")  {
757                                 input = new SharedListVector(fileHandle);
758                         }
759                         else if(format == "rabund"){
760                                 input = new RAbundVector(fileHandle);
761                         }
762                         else if(format == "order"){                     
763                                 input = new OrderVector(fileHandle);
764                         }
765                         else if(format == "sabund"){
766                                 input = new SAbundVector(fileHandle);
767                         }
768                         
769                         m->gobble(fileHandle);
770
771                         rabund = new RAbundVector();
772                         *rabund = (input->getRAbundVector());
773
774                         return rabund;
775                 }
776                 else{
777                         return NULL;
778                 }
779         }
780         catch(exception& e) {
781                 m->errorOut(e, "InputData", "getRAbundVector");
782                 exit(1);
783         }
784 }
785 /***********************************************************************/
786 RAbundVector* InputData::getRAbundVector(string label){
787         try {
788         
789                 ifstream in;
790                 string  thisLabel;
791                 m->openInputFile(filename, in);
792                 
793                 if(in){
794                         if (format == "list") {
795                 m->saveNextLabel = "";
796                         
797                                 while (in.eof() != true) {
798                                         
799                                         input = new ListVector(in);
800                                         thisLabel = input->getLabel();
801                                         
802                                         //if you are at the last label
803                                         if (thisLabel == label) {  break;  }
804                                         //so you don't loose this memory
805                                         else {  delete input;   }
806                                         m->gobble(in);
807                                 }
808                         }
809                         else if (format == "shared")  {
810                 m->saveNextLabel = "";
811                                 
812                                 while (in.eof() != true) {
813                                         
814                                         input = new SharedListVector(in);
815                                         thisLabel = input->getLabel();
816                                         
817                                         //if you are at the last label
818                                         if (thisLabel == label) {  break;  }
819                                         //so you don't loose this memory
820                                         else {  delete input;   }
821                                         m->gobble(in);
822                                 }
823
824                         }
825                         else if(format == "rabund"){
826                                 
827                                 while (in.eof() != true) {
828                                         
829                                         input = new RAbundVector(in);
830                                         thisLabel = input->getLabel();
831                                         
832                                         //if you are at the last label
833                                         if (thisLabel == label) {  break;  }
834                                         //so you don't loose this memory
835                                         else {  delete input;   }
836                                         m->gobble(in);
837                                 }
838
839                         }
840                         else if(format == "order"){                     
841                                 
842                                 while (in.eof() != true) {
843                                         
844                                         input = new OrderVector(in);
845                                         thisLabel = input->getLabel();
846                                         
847                                         //if you are at the last label
848                                         if (thisLabel == label) {  break;  }
849                                         //so you don't loose this memory
850                                         else {  delete input;   }
851                                         m->gobble(in);
852                                 }
853
854                         }
855                         else if(format == "sabund"){
856                                 
857                                 while (in.eof() != true) {
858                                         
859                                         input = new SAbundVector(in);
860                                         thisLabel = input->getLabel();
861                                         
862                                         //if you are at the last label
863                                         if (thisLabel == label) {  break;  }
864                                         //so you don't loose this memory
865                                         else {  delete input;   }
866                                         m->gobble(in);
867                                         
868                                 }
869
870                         }                       
871                         
872                         
873                         in.close();             
874
875                         rabund = new RAbundVector();
876                         *rabund = (input->getRAbundVector());
877
878                         return rabund;
879                 }
880                 else{
881                         return NULL;
882                 }
883         }
884         catch(exception& e) {
885                 m->errorOut(e, "InputData", "getRAbundVector");
886                 exit(1);
887         }
888 }
889
890 /***********************************************************************/
891
892
893