]> git.donarmstrong.com Git - mothur.git/blob - getlinecommand.cpp
added mothur.h and fixed includes in many files
[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 GetlineCommand::GetlineCommand(){
14         try {
15                 globaldata = GlobalData::getInstance();
16         }
17         catch(exception& e) {
18                 cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
19                 exit(1);
20         }
21         catch(...) {
22                 cout << "An unknown error has occurred in the GetlineCommand class function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
23                 exit(1);
24         }       
25                         
26 }
27
28 //**********************************************************************************************************************
29
30 GetlineCommand::~GetlineCommand(){
31 }
32
33 //**********************************************************************************************************************
34
35 int GetlineCommand::execute(){
36         try {
37                 filename = globaldata->inputFileName;
38                 ifstream in;
39                 openInputFile(filename, in);
40                 string label;
41                 int numBins = 0;
42                 int count = -1;
43                 int line = 1;
44                 while(in.good())
45                 {
46                         if(count > numBins)
47                                 count = 0;
48                         if(count == 0)
49                         {
50                                 cout << line << "\n";
51                                 in >> numBins;
52                                 line++;
53                         }
54                         in >> label;
55                         count++;
56                 }
57                 return 0;               
58         }
59
60         catch(exception& e) {
61                 cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62                 exit(1);
63         }
64         catch(...) {
65                 cout << "An unknown error has occurred in the GetlineCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
66                 exit(1);
67         }       
68 }
69
70
71