]> git.donarmstrong.com Git - mothur.git/blob - getlinecommand.cpp
df14f5123d2bd2e8c6d02380520810211e19c461
[mothur.git] / getlinecommand.cpp
1 /*
2  *  GetlineCommand.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 "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                         if(count > numBins)
46                                 count = 0;
47                         if(count == 0) {
48                                 cout << line << "\n";
49                                 in >> numBins;
50                                 line++;
51                         }
52                         in >> label;
53                         count++;
54                 }
55                 return 0;               
56         }
57
58         catch(exception& e) {
59                 cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
60                 exit(1);
61         }
62         catch(...) {
63                 cout << "An unknown error has occurred in the GetlineCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
64                 exit(1);
65         }       
66 }
67
68
69