1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include <iostream>
#include <iomanip>
#include <map>
#include <fstream>
#include <string>
//#include <unistd.h>
#include "common.h"
using namespace std;
class Record
{
public:
string seq;
string t_type;
string s_id;
string h_id;
string i_id;
string s_cnt;
string s_grp;
string s_nbr;
string s_score;
string h_cnt;
string h_grp;
string h_nbr;
string h_score;
string i_cnt;
string i_grp;
string i_nbr;
string i_score;
Record::Record()
{
(this->seq) ="";
(this->t_type) ="";
(this->s_id) ="";
(this->h_id) ="";
(this->i_id) ="";
(this->s_cnt) ="";
(this->s_grp) ="";
(this->s_nbr) ="";
(this->s_score) ="";
(this->h_cnt) ="";
(this->h_grp) ="";
(this->h_nbr) ="";
(this->h_score) ="";
(this->i_cnt) ="";
(this->i_grp) ="";
(this->i_nbr) ="";
(this->i_score) ="";
};
//virtual Record::~Record(){}
};
void process ()
{
long record_count (0);
bool first (true);
string buffer ("");
string inFile ("/home/daula/projects/test/new_duper_test_output.dat");
multimap < const string, Record * > myMap;
ifstream inputFile ( inFile.c_str() );
while (getline(inputFile, buffer))
{
Record * temp_rec = new Record;
temp_rec->seq = trim(buffer.substr( 0, 26));
temp_rec->t_type = trim(buffer.substr( 26, 1));
temp_rec->s_id = trim(buffer.substr( 27, 12));
temp_rec->h_id = trim(buffer.substr( 39, 12));
temp_rec->i_id = trim(buffer.substr( 51, 12));
temp_rec->s_cnt = trim(buffer.substr( 63, 5));
temp_rec->s_grp = trim(buffer.substr( 68, 10));
temp_rec->s_nbr = trim(buffer.substr( 78, 3));
temp_rec->s_score= trim(buffer.substr( 81, 3));
temp_rec->h_cnt = trim(buffer.substr( 84, 5));
temp_rec->h_grp = trim(buffer.substr( 89, 10));
temp_rec->h_nbr = trim(buffer.substr( 99, 3));
temp_rec->h_score= trim(buffer.substr( 102, 3));
temp_rec->i_cnt = trim(buffer.substr( 105, 5));
temp_rec->i_grp = trim(buffer.substr( 110,10));
temp_rec->i_nbr = trim(buffer.substr( 120, 3));
temp_rec->i_score= trim(buffer.substr( 123, 3));
myMap.insert ( std::make_pair( temp_rec->s_grp, temp_rec));
if ( (record_count%1000000) == 0 && !first )
{
cout << "Record count is: " << record_count << endl;
}
delete temp_rec;
++record_count;
first = false;
}
}
int main ()
{
process ();
return 0;
}
| |