]> git.donarmstrong.com Git - mothur.git/blob - getlinecommand.cpp
Added get.line command.
[mothur.git] / getlinecommand.cpp
1 /*
2  *  GetlineCommand.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 "getlinecommand.h"
11
12
13
14
15
16
17 GetlineCommand::GetlineCommand(){
18         try {
19                 globaldata = GlobalData::getInstance();
20         }
21         catch(exception& e) {
22                 cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function GetlineCommand. 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 GetlineCommand class function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
27                 exit(1);
28         }       
29                         
30 }
31
32 //**********************************************************************************************************************
33
34 GetlineCommand::~GetlineCommand(){
35 }
36
37 //**********************************************************************************************************************
38
39 int GetlineCommand::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                 int line = 1;
48                 while(in.good())
49                 {
50                         if(count > numBins)
51                                 count = 0;
52                         if(count == 0)
53                         {
54                                 cout << line << "\n";
55                                 in >> numBins;
56                                 line++;
57                         }
58                         in >> label;
59                         count++;
60                 }
61                 return 0;               
62         }
63
64         catch(exception& e) {
65                 cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
66                 exit(1);
67         }
68         catch(...) {
69                 cout << "An unknown error has occurred in the GetlineCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
70                 exit(1);
71         }       
72 }
73
74
75