-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcollect_HISAT2_mapping_stats.sh
53 lines (44 loc) · 1.58 KB
/
collect_HISAT2_mapping_stats.sh
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
#! /bin/bash
# from https://gist.github.com/slavailn/cafd7c50276a37b3aad61756ba994353
# 22498713 reads; of these:
# 22498713 (100.00%) were unpaired; of these:
# 1754404 (7.80%) aligned 0 times
# 17667104 (78.52%) aligned exactly 1 time
# 3077205 (13.68%) aligned >1 times
# 92.20% overall alignment rate
echo -e "sampleID\ttotal_reads\tunmapped\taligned_one_time\taligned_multiple\talignment_rate"
for file in ./*.summary
do
filename=`basename $file`
samplename=${filename%.summary}
total_reads=""
unmapped=""
aligned_one_time=""
aligned_multiple=""
alignment_rate=""
while IFS= read -r line
do
if [[ $line == *reads* ]];
then
total_reads=`echo $line | awk '{print $1}'`;
fi
if [[ $line == *aligned[[:space:]]*0[[:space:]]*times* ]];
then
unmapped_reads=`echo $line | awk '{print $1}'`;
fi
if [[ $line == *aligned[[:space:]]*exactly[[:space:]]*1[[:space:]]*time* ]]
then
aligned_one_time=`echo $line | awk '{print $1}'`;
fi
if [[ $line == *aligned[[:space:]]*\>1[[:space:]]*times* ]]
then
aligned_multiple=`echo $line | awk '{print $1}'`;
fi
if [[ $line == *overall[[:space:]]*alignment[[:space:]]*rate* ]]
then
alignment_rate=`echo $line | awk '{print $1}'`;
alignment_rate=`echo $alignment_rate | sed s/%//`;
fi
done < "$file"
echo -e "$samplename\t$total_reads\t$unmapped_reads\t$aligned_one_time\t$aligned_multiple\t$alignment_rate"
done