-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCorrectRedundant.cpp
82 lines (56 loc) · 1.68 KB
/
CorrectRedundant.cpp
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
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;
string CutTail (string str) {
int L = str.length();
for(int i = str.length() - 1; i > 0; --i){
if(str[i] == '_'){
L = i;
break;
}
}
return str.substr(0,L);
}
int main (int argc, char **argv) {
cerr << "CorrectRedundant <read_subisoform_fltr.txt> <redundant_list.txt>" << endl;
ifstream subinf(argv[1]);
ifstream rddinf(argv[2]);
map<string,string> rdd_map;
map<string,string>::iterator it;
while(rddinf){
string strInput;
getline(rddinf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
rdd_map[CutTail(vec[0])] = CutTail(vec[1]);
}
}
//for(it = rdd_map.begin(); it != rdd_map.end(); ++it) cout << (it->first) << '\t' << (it->second) << endl;
while(subinf){
string strInput;
getline(subinf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
it = rdd_map.find(vec[2]);
if(it != rdd_map.end()){
vec[2] = (it->second);
cout << vec[0];
for(int i = 1; i < vec.size(); ++i) cout << '\t' << vec[i];
cout << endl;
}
else cout << strInput << endl;
}
}
subinf.close(); rddinf.close();
return 0;
}