00001 #include "phdparser.h"
00002 #include <sstream>
00003 #include <fstream>
00004 #include <iostream>
00005 using namespace std;
00006
00007 PhdParser::PhdParser(string infile) : filename(infile)
00008 {
00009
00010 }
00011
00012 TrapperVector<Q_UINT32> PhdParser::parse()
00013 {
00014 TrapperVector<Q_UINT32> phd;
00015
00016 string line;
00017
00018 ifstream inFile(filename.c_str());
00019
00020 while ( getline(inFile, line) ) {
00021 if ( line == "BEGIN_DNA" ) break;
00022 }
00023 while ( getline(inFile, line) ) {
00024 if ( line == "END_DNA" ) break;
00025
00026 istringstream is(line);
00027 char base;
00028 size_t qual;
00029 size_t index;
00030 if ( !(is>>base && is>>qual && is>>index) ) {
00031 cerr<<"PhdParser::parse(), input error"<<endl;
00032 cerr<<"Line is ill formated"<<endl;
00033 cerr<<line<<endl;
00034 return TrapperVector<Q_UINT32>();
00035 }
00036 phd.stlVector().push_back(index);
00037
00038 }
00039 inFile.close();
00040 return phd;
00041 }