forked from Parsoa/SVDSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sv.cpp
63 lines (58 loc) · 1.41 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
#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_) {
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_;
idx = type + "_" + chrom + ":" + to_string(s) + "-" + to_string(e);
idx += "_" + to_string(abs(l));
gt = "./.";
genotype();
}
void SV::genotype() {
if (imprecise) {
gt = "./.";
} else {
float p = float(w) / float(cov);
if (p >= 0.9)
gt = "1/1";
else
gt = "0/1";
// if (p <= 0.1)
// gt = "0/0";
}
}
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 << ";"
<< "AS=" << sv.score << ";"
<< "NV=" << sv.ngaps
<< (sv.imprecise ? ";IMPRECISE\t" : "\t")
// -
<< "GT"
<< "\t" << sv.gt;
return os;
}