forked from WGS-standards-and-analysis/datasets
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreadChecksum_MT.sh
More file actions
executable file
·42 lines (35 loc) · 958 Bytes
/
readChecksum_MT.sh
File metadata and controls
executable file
·42 lines (35 loc) · 958 Bytes
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
#!/bin/bash
function logmsg(){
echo -e "$1" >&2
}
READS=$1
NUMCPUS=12
if [ "$READS" == "" ]; then
logmsg "Gets a checksum from a fastq.gz or a fastq file";
logmsg "Usage: $0 file.fastq.gz";
exit 1;
fi;
IS_GZIP=$(file $READS| grep gzip)
if [ "$IS_GZIP" == "" ]; then
CAT="cat"
else
CAT="zcat"
fi
# 1. cat the file to perl
# 2. keep only the seq and qual
# 3. sort
# 4. sha256sum
# 5. remove any whitespace and the dash from the sha256sum stdin printout
CHECKSUM=$($CAT $READS |\
perl -Mthreads -e '
my $i=0;
while(<>){
$seq=<>;
<>;
$qual=<>;
print "$seq$qual";
}' |\
sort | sha256sum |\
perl -lane 's/^\s+|\s+$//; s/\s+.*$//; print;'
);
echo -e "$READS\t$CHECKSUM";