-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsv.cpp
80 lines (72 loc) · 1.95 KB
/
sv.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
#include "sv.hpp"
using namespace std;
SV::SV() { l = 0; }
SV::SV(const string type_, const string &chrom_, uint s_, const string &refall_,
const string &altall_, const uint w_, const uint cov_, const int ngaps_,
const int score_, bool imprecise_, uint l_, string cigar_) {
type = type_;
chrom = chrom_;
s = s_;
refall = refall_;
altall = altall_;
e = s + refall.size() - 1;
w = w_;
l = l_;
cov = cov_;
ngaps = ngaps_;
score = score_;
imprecise = imprecise_;
cigar = cigar_;
idx = type + "_" + chrom + ":" + to_string(s) + "-" + to_string(e);
idx += "_" + to_string(abs(l));
gt = "./.";
rvec = "";
}
void SV::add_reads(const vector<string> &names) {
for (const string &name : names)
reads += name + ",";
reads.pop_back();
}
void SV::set_cov(int _cov, int _cov0, int _cov1, int _cov2) {
cov = _cov;
cov0 = _cov0;
cov1 = _cov1;
cov2 = _cov2;
}
void SV::set_rvec(const vector<tuple<int, int>> &reads) {
for (const auto &r : reads)
rvec += to_string(get<0>(r)) + ":" + to_string(get<1>(r)) + "-";
rvec.pop_back();
}
void SV::set_gt(const string &_gt, int _gtq) {
gt = _gt;
gtq = _gtq;
}
ostream &operator<<(ostream &os, const SV &sv) {
os << sv.chrom << "\t" << sv.s << "\t" << sv.idx << "\t" << sv.refall << "\t"
<< sv.altall << "\t"
<< "."
<< "\t"
<< "PASS"
<< "\t"
// INFO
<< "VARTYPE=SV;"
<< "SVTYPE=" << sv.type << ";"
<< "SVLEN=" << (sv.type == "DEL" ? -sv.l : sv.l) << ";"
<< "END=" << sv.e << ";"
<< "WEIGHT=" << sv.w << ";"
<< "COV=" << sv.cov << ";"
<< "COV0=" << sv.cov0 << ";"
<< "COV1=" << sv.cov1 << ";"
<< "COV2=" << sv.cov2 << ";"
<< "AS=" << sv.score << ";"
<< "NV=" << sv.ngaps << ";"
<< "CIGAR=" << sv.cigar << ";"
<< "RVEC=" << sv.rvec << ";"
<< "READS=" << sv.reads
<< (sv.imprecise ? ";IMPRECISE\t" : "\t")
// -
<< "GT:GQ"
<< "\t" << sv.gt << ":" << sv.gtq;
return os;
}