-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkphase_summary
executable file
·91 lines (85 loc) · 2.67 KB
/
checkphase_summary
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
#!/bin/bash
#
# Copyright (C) 2018-2023 by Lars Wienbrandt,
# Institute of Clinical Molecular Biology, Kiel University
#
# This file is part of Checkphase.
#
# Checkphase is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Checkphase is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkphase. If not, see <https://www.gnu.org/licenses/>.
#
# summarizes information from checkphase sample-wise outputs
if [[ $# == 0 ]]; then
echo "Usage: checkphase_summary <list of checkphase sample-wise output files>"
exit 1
fi
awk 'BEGIN {
Mcheck=0
Totswerr=0
Totgterr=0
Totgterrsoft=0.0
Nquery=0
}
# add checked variants from this file
/Checked variants:/{Mcheck += $3; next}
# ignore header
/Idx/{next}
# general
{
# number of samples based on indices
if ($1 >= Nquery) Nquery = $1
# sum up errors
Totswerr += $2
Totgterr += $3
Totgterrsoft += $4
# sum up per ID
swerr[$1] += $2
gterr[$1] += $3
gterrsoft[$1] += $4
}
END {
Nquery++ # indices are 0-based
# Summary output of:
# - Number of files
# - Number of samples
# - Number of (checked) variants
# - Total sw errors
# - Av. sw errors
# - Av. sw error rate
# - Total gt errors
# - Av. gt errors
# - Av. gt error rate
print "# Num files:\t" ARGC-1 # first argument is the awk program itself
print "# Num samples:\t" Nquery
print "# Num (checked) variants:\t" Mcheck
print "# Total sw errors:\t" Totswerr
print "# Av. sw errors:\t" (Totswerr/Nquery)
print "# Av. sw error rate:\t" (Totswerr/Nquery/Mcheck)
print "# Total gt errors (hard):\t" Totgterr
print "# Av. gt errors (hard):\t" (Totgterr/Nquery)
print "# Av. gt error rate (hard):\t" (Totgterr/Nquery/Mcheck)
print "# Total gt errors (soft):\t" Totgterrsoft
print "# Av. gt errors (soft):\t" (Totgterrsoft/Nquery)
print "# Av. gt error rate (soft):\t" (Totgterrsoft/Nquery/Mcheck)
# Per samples output of:
# - sw errors
# - sw error rate
# - gt errors (hard)
# - gt error rate (hard)
# - gt errors (soft)
# - gt error rate (soft)
print "Idx\tsw err\tsw err rate\tgt err (hard)\tgt err rate (hard)\tgt err (soft)\tgt err rate (soft)"
for (idx=0; idx<Nquery; idx++) {
print idx "\t" swerr[idx] "\t" swerr[idx]/Mcheck "\t" gterr[idx] "\t" gterr[idx]/Mcheck "\t" gterrsoft[idx] "\t" gterrsoft[idx]/Mcheck
}
}' $@