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