]> git.donarmstrong.com Git - mothur.git/blob - getlabelcommand.cpp
*** empty log message ***
[mothur.git] / getlabelcommand.cpp
1 /*
2  *  GetlabelCommand.cpp
3  *  Mothur
4  *
5  *  Created by Thomas Ryabin on 1/30/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "getlabelcommand.h"
11
12
13
14 GetlabelCommand::GetlabelCommand(){
15         try {
16                 globaldata = GlobalData::getInstance();
17         }
18         catch(exception& e) {
19                 cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
20                 exit(1);
21         }
22         catch(...) {
23                 cout << "An unknown error has occurred in the GetlabelCommand class function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
24                 exit(1);
25         }       
26                         
27 }
28
29 //**********************************************************************************************************************
30
31 GetlabelCommand::~GetlabelCommand(){
32 }
33
34 //**********************************************************************************************************************
35
36 int GetlabelCommand::execute(){
37         try {
38                 filename = globaldata->inputFileName;
39                 ifstream in;
40                 openInputFile(filename, in);
41                 string label;
42                 int numBins = 0;
43                 int count = -1;
44                 while(in.good()) {
45                         if(count > numBins)
46                                 count = 0;
47                         if(count == 0) {
48                                 cout << label << "\n";
49                                 in >> numBins;
50                         }
51                         in >> label;
52                         count++;
53                 }       
54                 return 0;       
55         }
56
57         catch(exception& e) {
58                 cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
59                 exit(1);
60         }
61         catch(...) {
62                 cout << "An unknown error has occurred in the GetlabelCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
63                 exit(1);
64         }       
65 }
66