]> git.donarmstrong.com Git - mothur.git/blob - inputdata.cpp
283fb7edc33856613612e10b0d293d0eea1f056d
[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         globaldata = GlobalData::getInstance();
20         m->openInputFile(fName, fileHandle);
21         filename = fName;
22         
23 }
24
25 /***********************************************************************/
26
27
28 InputData::~InputData(){
29         fileHandle.close();
30         globaldata = GlobalData::getInstance();
31         globaldata->saveNextLabel = "";
32 //      delete output;
33         
34 }
35
36 /***********************************************************************/
37
38 InputData::InputData(string fName, string orderFileName, string f) : format(f){
39         try {
40                 m = MothurOut::getInstance();
41                 globaldata = GlobalData::getInstance();
42                 ifstream ofHandle;
43                 m->openInputFile(orderFileName, ofHandle);
44                 string name;
45
46                 int count = 0;
47         
48                 while(ofHandle){
49                         ofHandle >> name;
50                         orderMap[name] = count;
51                         count++;
52                         m->gobble(ofHandle);
53                 }
54                 ofHandle.close();
55         
56                 m->openInputFile(fName, fileHandle);
57         }
58         catch(exception& e) {
59                 m->errorOut(e, "InputData", "InputData");
60                 exit(1);
61         }
62 }
63 /***********************************************************************/
64
65 ListVector* InputData::getListVector(){
66         try {
67                 if(!fileHandle.eof()){
68                         if(format == "list") {
69                                 list = new ListVector(fileHandle);
70                         }else{ list = NULL;  }
71                                         
72                         m->gobble(fileHandle);
73                         return list;
74                 }
75                 else{
76                         return NULL;
77                 }
78         }
79         catch(exception& e) {
80                 m->errorOut(e, "InputData", "getListVector");
81                 exit(1);
82         }
83 }
84
85 /***********************************************************************/
86 ListVector* InputData::getListVector(string label){
87         try {
88                 ifstream in;
89                 string  thisLabel;
90                 m->openInputFile(filename, in);
91                 
92                 if(in){
93
94                         if (format == "list") {
95                         
96                                 while (in.eof() != true) {
97                                         
98                                         list = new ListVector(in);
99                                         thisLabel = list->getLabel();
100                                         
101                                         //if you are at the last label
102                                         if (thisLabel == label) {  break;  }
103                                         //so you don't loose this memory
104                                         else {  delete list;    }
105                                         m->gobble(in);
106                                 }
107                         }else{ list = NULL;  }
108                         
109                         in.close();
110                         return list;
111                 }
112                 else{
113                         return NULL;
114                 }
115         }
116         catch(exception& e) {
117                 m->errorOut(e, "InputData", "getListVector");
118                 exit(1);
119         }
120 }
121 /***********************************************************************/
122 ListVector* InputData::getListVector(string label, bool resetFP){
123         try {
124                 string  thisLabel;
125                 fileHandle.clear();
126                 fileHandle.seekg(0);
127                 
128                 if(fileHandle){
129
130                         if (format == "list") {
131                         
132                                 while (fileHandle.eof() != true) {
133                                         
134                                         list = new ListVector(fileHandle); m->gobble(fileHandle);
135                                         thisLabel = list->getLabel();
136                                         
137                                         //if you are at the last label
138                                         if (thisLabel == label) {  break;  }
139                                         //so you don't loose this memory
140                                         else {  delete list;    }
141                                 }
142                         }else{ list = NULL;  }
143                 
144                         return list;
145                 }
146                 else{
147                         return NULL;
148                 }
149         }
150         catch(exception& e) {
151                 m->errorOut(e, "InputData", "getListVector");
152                 exit(1);
153         }
154 }
155
156 /***********************************************************************/
157
158 SharedListVector* InputData::getSharedListVector(){
159         try {
160                 if(fileHandle){
161                         if (format == "shared")  {
162                                 SharedList = new SharedListVector(fileHandle);
163                         }else{ SharedList = NULL;  }
164                                         
165                         m->gobble(fileHandle);
166                         return SharedList;
167                 }
168                 else{
169                         return NULL;
170                 }
171         }
172         catch(exception& e) {
173                 m->errorOut(e, "InputData", "getSharedListVector");
174                 exit(1);
175         }
176 }
177 /***********************************************************************/
178
179 SharedListVector* InputData::getSharedListVector(string label){
180         try {
181                 ifstream in;
182                 string  thisLabel;
183                 m->openInputFile(filename, in);
184                 
185                 if(in){
186
187                         if (format == "shared")  {
188                         
189                                 while (in.eof() != true) {
190                                         
191                                         SharedList = new SharedListVector(in);
192                                         thisLabel = SharedList->getLabel();
193                                         
194                                         //if you are at the last label
195                                         if (thisLabel == label) {  break;  }
196                                         //so you don't loose this memory
197                                         else {  delete SharedList;      }
198                                         m->gobble(in);
199                                 }
200
201                         }else{ SharedList = NULL;  }
202                                 
203                         in.close();
204                         return SharedList;
205                         
206                 }else{
207                         return NULL;
208                 }
209         }
210         catch(exception& e) {
211                 m->errorOut(e, "InputData", "getSharedListVector");
212                 exit(1);
213         }
214 }
215
216
217
218 /***********************************************************************/
219
220 SharedOrderVector* InputData::getSharedOrderVector(){
221         try {
222                 if(fileHandle){
223                         if (format == "sharedfile")  {
224                                 SharedOrder = new SharedOrderVector(fileHandle);
225                         }else{ SharedOrder = NULL;  }
226                                 
227                         m->gobble(fileHandle);
228                         return SharedOrder;
229                         
230                 }else{
231                         return NULL;
232                 }
233         }
234         catch(exception& e) {
235                 m->errorOut(e, "InputData", "getSharedOrderVector");
236                 exit(1);
237         }
238 }
239
240 /***********************************************************************/
241
242 SharedOrderVector* InputData::getSharedOrderVector(string label){
243         try {
244                 ifstream in;
245                 string  thisLabel;
246                 m->openInputFile(filename, in);
247                 
248                 if(in){
249
250                         if (format == "sharedfile")  {
251                         
252                                 while (in.eof() != true) {
253                                         
254                                         SharedOrder = new SharedOrderVector(in);
255                                         thisLabel = SharedOrder->getLabel();
256                                         
257                                         //if you are at the last label
258                                         if (thisLabel == label) {  break;  }
259                                         //so you don't loose this memory
260                                         else {  delete SharedOrder;     }
261                                         m->gobble(in);
262                                 }
263
264                         }else{ SharedOrder = NULL;  }
265                                 
266                         in.close();
267                         return SharedOrder;
268                         
269                 }else{
270                         return NULL;
271                 }
272         }
273         catch(exception& e) {
274                 m->errorOut(e, "InputData", "getSharedOrderVector");
275                 exit(1);
276         }
277 }
278
279
280
281 /***********************************************************************/
282
283 OrderVector* InputData::getOrderVector(){
284         try {
285                 if(fileHandle){
286                         if((format == "list") || (format == "listorder")) {
287                                 input = new ListVector(fileHandle);
288                         }
289                         else if (format == "shared")  {
290                                 input = new SharedListVector(fileHandle);
291                         }
292                         else if(format == "rabund"){
293                                 input = new RAbundVector(fileHandle);
294                         }
295                         else if(format == "order"){             
296                                 input = new OrderVector(fileHandle);
297                         }
298                         else if(format == "sabund"){
299                                 input = new SAbundVector(fileHandle);
300                         }
301                         
302                         m->gobble(fileHandle);
303                         
304                         output = new OrderVector();     
305                         *output = (input->getOrderVector());
306                 
307                         return output;
308                 }
309                 else{
310                         return NULL;
311                 }
312         }
313         catch(exception& e) {
314                 m->errorOut(e, "InputData", "getOrderVector");
315                 exit(1);
316         }
317 }
318
319 /***********************************************************************/
320 OrderVector* InputData::getOrderVector(string label){
321         try {
322         
323                 ifstream in;
324                 string  thisLabel;
325                 m->openInputFile(filename, in);
326                 
327                 if(in){
328                         if((format == "list") || (format == "listorder")) {
329                         
330                                 while (in.eof() != true) {
331                                         
332                                         input = new ListVector(in);
333                                         thisLabel = input->getLabel();
334                                         
335                                         //if you are at the last label
336                                         if (thisLabel == label) {  break;  }
337                                         //so you don't loose this memory
338                                         else {  delete input;   }
339                                         m->gobble(in);
340                                 }
341                         }
342                         else if (format == "shared")  {
343                                 
344                                 while (in.eof() != true) {
345                                         
346                                         input = new SharedListVector(in);
347                                         thisLabel = input->getLabel();
348                                         
349                                         //if you are at the last label
350                                         if (thisLabel == label) {  break;  }
351                                         //so you don't loose this memory
352                                         else {  delete input;   }
353                                         m->gobble(in);
354                                 }
355
356                         }
357                         else if(format == "rabund"){
358                                 
359                                 while (in.eof() != true) {
360                                         
361                                         input = new RAbundVector(in);
362                                         thisLabel = input->getLabel();
363                                         
364                                         //if you are at the last label
365                                         if (thisLabel == label) {  break;  }
366                                         //so you don't loose this memory
367                                         else {  delete input;   }
368                                         m->gobble(in);
369                                 }
370
371                         }
372                         else if(format == "order"){                     
373                                 
374                                 while (in.eof() != true) {
375                                         
376                                         input = new OrderVector(in);
377                                         thisLabel = input->getLabel();
378                                         
379                                         //if you are at the last label
380                                         if (thisLabel == label) {  break;  }
381                                         //so you don't loose this memory
382                                         else {  delete input;   }
383                                         m->gobble(in);
384                                 }
385
386                         }
387                         else if(format == "sabund"){
388                                 
389                                 while (in.eof() != true) {
390                                         
391                                         input = new SAbundVector(in);
392                                         thisLabel = input->getLabel();
393                                         
394                                         //if you are at the last label
395                                         if (thisLabel == label) {  break;  }
396                                         //so you don't loose this memory
397                                         else {  delete input;   }
398                                         m->gobble(in);
399                                         
400                                 }
401
402                         }
403                         
404                         in.close();             
405
406                         output = new OrderVector();
407                         *output = (input->getOrderVector());
408                         
409                         return output;
410
411                 }
412                 else{
413                         return NULL;
414                 }
415         }
416         catch(exception& e) {
417                 m->errorOut(e, "InputData", "getOrderVector");
418                 exit(1);
419         }
420 }
421
422 /***********************************************************************/
423 //this is used when you don't need the order vector
424 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
425         try {
426                 if(fileHandle){
427                         if (format == "sharedfile")  {
428                                 SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
429                                 if (SharedRAbund != NULL) {
430                                         return SharedRAbund->getSharedRAbundVectors();
431                                 }
432                         }else if (format == "shared") {
433                                 SharedList = new SharedListVector(fileHandle);
434                                 if (SharedList != NULL) {
435                                         return SharedList->getSharedRAbundVector();
436                                 }
437                         }
438                         m->gobble(fileHandle);
439                 }
440                                 
441                 //this is created to signal to calling function that the input file is at eof
442                 vector<SharedRAbundVector*> null;  null.push_back(NULL);
443                 return null;
444                 
445         }
446         catch(exception& e) {
447                 m->errorOut(e, "InputData", "getSharedRAbundVectors");
448                 exit(1);
449         }
450 }
451 /***********************************************************************/
452 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
453         try {
454                 ifstream in;
455                 string  thisLabel;
456                 
457                 m->openInputFile(filename, in);
458                 globaldata->saveNextLabel = "";
459         
460                 if(in){
461                         if (format == "sharedfile")  {
462                                 while (in.eof() != true) {
463                                         
464                                         SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
465                                         if (SharedRAbund != NULL) {
466                                                 thisLabel = SharedRAbund->getLabel();
467                                         
468                                                 //if you are at the last label
469                                                 if (thisLabel == label) {  in.close(); return SharedRAbund->getSharedRAbundVectors();  }
470                                                 else {
471                                                         //so you don't loose this memory
472                                                         vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
473                                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
474                                                         delete SharedRAbund;
475                                                 }
476                                         }else{  break;  }
477                                         m->gobble(in);
478                                         
479                                 }
480                         }else if (format == "shared") {
481                                 while (in.eof() != true) {
482                                         
483                                         SharedList = new SharedListVector(in);
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                 globaldata->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                                         
631                         m->gobble(fileHandle);
632
633                         sabund = new SAbundVector();
634                         *sabund = (input->getSAbundVector());
635
636                         return sabund;
637                 }
638                 else{
639                         return NULL;
640                 }
641         }
642         catch(exception& e) {
643                 m->errorOut(e, "InputData", "getSAbundVector");
644                 exit(1);
645         }
646 }
647 /***********************************************************************/
648 SAbundVector* InputData::getSAbundVector(string label){
649         try {
650         
651                 ifstream in;
652                 string  thisLabel;
653                 m->openInputFile(filename, in);
654                 
655                 if(in){
656                         if (format == "list") {
657                         
658                                 while (in.eof() != true) {
659                                         
660                                         input = new ListVector(in);
661                                         thisLabel = input->getLabel();
662                                         
663                                         //if you are at the last label
664                                         if (thisLabel == label) {  break;  }
665                                         //so you don't loose this memory
666                                         else {  delete input;   }
667                                         m->gobble(in);
668                                 }
669                         }
670                         else if (format == "shared")  {
671                                 
672                                 while (in.eof() != true) {
673                                         
674                                         input = new SharedListVector(in);
675                                         thisLabel = input->getLabel();
676                                         
677                                         //if you are at the last label
678                                         if (thisLabel == label) {  break;  }
679                                         //so you don't loose this memory
680                                         else {  delete input;   }
681                                         m->gobble(in);
682                                 }
683
684                         }
685                         else if(format == "rabund"){
686                                 
687                                 while (in.eof() != true) {
688                                         
689                                         input = new RAbundVector(in);
690                                         thisLabel = input->getLabel();
691                                         
692                                         //if you are at the last label
693                                         if (thisLabel == label) {  break;  }
694                                         //so you don't loose this memory
695                                         else {  delete input;   }
696                                         m->gobble(in);
697                                 }
698
699                         }
700                         else if(format == "order"){                     
701                                 
702                                 while (in.eof() != true) {
703                                         
704                                         input = new OrderVector(in);
705                                         thisLabel = input->getLabel();
706                                         
707                                         //if you are at the last label
708                                         if (thisLabel == label) {  break;  }
709                                         //so you don't loose this memory
710                                         else {  delete input;   }
711                                         m->gobble(in);
712                                 }
713
714                         }
715                         else if(format == "sabund"){
716                                 
717                                 while (in.eof() != true) {
718                                         
719                                         input = new SAbundVector(in);
720                                         thisLabel = input->getLabel();
721                                         
722                                         //if you are at the last label
723                                         if (thisLabel == label) {  break;  }
724                                         //so you don't loose this memory
725                                         else {  delete input;   }
726                                         m->gobble(in);
727                                         
728                                 }
729
730                         }
731                         
732                         in.close();             
733
734                         sabund = new SAbundVector();
735                         *sabund = (input->getSAbundVector());
736
737                         return sabund;
738
739                 }
740                 else{
741                         return NULL;
742                 }
743         }
744         catch(exception& e) {
745                 m->errorOut(e, "InputData", "getSAbundVector");
746                 exit(1);
747         }
748 }
749
750 /***********************************************************************/
751 RAbundVector* InputData::getRAbundVector(){
752         try {
753                 if(fileHandle){
754                         if (format == "list") {
755                                 input = new ListVector(fileHandle);
756                         }
757                         else if (format == "shared")  {
758                                 input = new SharedListVector(fileHandle);
759                         }
760                         else if(format == "rabund"){
761                                 input = new RAbundVector(fileHandle);
762                         }
763                         else if(format == "order"){                     
764                                 input = new OrderVector(fileHandle);
765                         }
766                         else if(format == "sabund"){
767                                 input = new SAbundVector(fileHandle);
768                         }
769                                         
770                         m->gobble(fileHandle);
771
772                         rabund = new RAbundVector();
773                         *rabund = (input->getRAbundVector());
774
775                         return rabund;
776                 }
777                 else{
778                         return NULL;
779                 }
780         }
781         catch(exception& e) {
782                 m->errorOut(e, "InputData", "getRAbundVector");
783                 exit(1);
784         }
785 }
786 /***********************************************************************/
787 RAbundVector* InputData::getRAbundVector(string label){
788         try {
789         
790                 ifstream in;
791                 string  thisLabel;
792                 m->openInputFile(filename, in);
793                 
794                 if(in){
795                         if (format == "list") {
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                                 
811                                 while (in.eof() != true) {
812                                         
813                                         input = new SharedListVector(in);
814                                         thisLabel = input->getLabel();
815                                         
816                                         //if you are at the last label
817                                         if (thisLabel == label) {  break;  }
818                                         //so you don't loose this memory
819                                         else {  delete input;   }
820                                         m->gobble(in);
821                                 }
822
823                         }
824                         else if(format == "rabund"){
825                                 
826                                 while (in.eof() != true) {
827                                         
828                                         input = new RAbundVector(in);
829                                         thisLabel = input->getLabel();
830                                         
831                                         //if you are at the last label
832                                         if (thisLabel == label) {  break;  }
833                                         //so you don't loose this memory
834                                         else {  delete input;   }
835                                         m->gobble(in);
836                                 }
837
838                         }
839                         else if(format == "order"){                     
840                                 
841                                 while (in.eof() != true) {
842                                         
843                                         input = new OrderVector(in);
844                                         thisLabel = input->getLabel();
845                                         
846                                         //if you are at the last label
847                                         if (thisLabel == label) {  break;  }
848                                         //so you don't loose this memory
849                                         else {  delete input;   }
850                                         m->gobble(in);
851                                 }
852
853                         }
854                         else if(format == "sabund"){
855                                 
856                                 while (in.eof() != true) {
857                                         
858                                         input = new SAbundVector(in);
859                                         thisLabel = input->getLabel();
860                                         
861                                         //if you are at the last label
862                                         if (thisLabel == label) {  break;  }
863                                         //so you don't loose this memory
864                                         else {  delete input;   }
865                                         m->gobble(in);
866                                         
867                                 }
868
869                         }
870                         
871                         in.close();             
872
873                         rabund = new RAbundVector();
874                         *rabund = (input->getRAbundVector());
875
876                         return rabund;
877                 }
878                 else{
879                         return NULL;
880                 }
881         }
882         catch(exception& e) {
883                 m->errorOut(e, "InputData", "getRAbundVector");
884                 exit(1);
885         }
886 }
887
888 /***********************************************************************/
889
890
891