-
Notifications
You must be signed in to change notification settings - Fork 1
/
StatTableIntact.cpp
108 lines (75 loc) · 2.38 KB
/
StatTableIntact.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#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;
struct STAT {
string gname;
int intact_num;
int compatible_num;
};
map<string,STAT> BuildIsoformStatMap (ifstream &inf) {
map<string,STAT> stat_map;
while(inf){
string strInput;
getline(inf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
string tname = vec[1];
stat_map[tname].gname = vec[0];
stat_map[tname].intact_num = 0;
stat_map[tname].compatible_num = 0;
}
}
return stat_map;
}
int main (int argc, char **argv) {
cerr << "StatTableIntact <assembly_final.gpd> <intact_reads_subisoforms_*.txt> <map_to_isoform_*.txt>" << endl;
ifstream annoinf(argv[1]);
ifstream intactinf(argv[2]);
ifstream compatibleinf(argv[3]);
map<string,STAT> stat_map = BuildIsoformStatMap(annoinf);
map<string,STAT>::iterator it;
while(intactinf){
string strInput;
getline(intactinf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
it = stat_map.find(vec[2]);
if(it == stat_map.end()){
cout << "Alert" << endl;
}
else{
++(it->second).intact_num;
}
}
}
while(compatibleinf){
string strInput;
getline(compatibleinf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
if(vec[2] == "Compatible"){
it = stat_map.find(vec[1]);
if(it == stat_map.end()) cout << "Alert" << endl;
else{
++(it->second).compatible_num;
}
}
}
}
for(it = stat_map.begin(); it != stat_map.end(); ++it){
cout << (it->second).gname << '\t' << (it->first) << '\t' << (it->second).intact_num << '\t' << ((it->second).compatible_num - (it->second).intact_num) << endl;
}
annoinf.close(); intactinf.close(); compatibleinf.close();
return 0;
}