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