-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrundata2arch.sh
executable file
·69 lines (52 loc) · 2.06 KB
/
rundata2arch.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# script rundata2arch.sh
# author:Stephane Plaisance (VIB-NC), 2019-12-17, v1.0
# create backup files from a gridion run
if [ $# -eq 0 ]; then
echo "# Please provide the path to the run folder as argument"
exit 1
fi
# get runfolder as argument 1
runf=${1}
pfx=$(basename ${runf})
# check for valid runfolder
fqp=$(find ${runf} -type d -name fastq_pass -printf '%d\n' | sort -rn | head -1)
if (( ${fqp} != 1 )); then
echo "# please provide a valid run-folder as input"
echo "# current path is:"
ls -lah ${runf}
exit
fi
# get enclosing folder name
projf=$(basename $(dirname $(find ../ -name "${runf}")))
# create run folder_archive for transfer
tmpf=${projf}_data
mkdir -p ${tmpf}
# copy and rename gridion run-report
echo "# copying the ONT run report"
cp ${runf}/report_*.pdf ${tmpf}/${pfx}_report.pdf
# archive gridion run stat files
echo "# archiving run stat files to ${pfx}_run_info.tgz"
find ${runf} -maxdepth 1 -type f -exec tar -czvf ${tmpf}/${pfx}_run_info.tgz {} \;
# concat and archive fastq_pass
echo "# concatenating all reads to a single fastq.gz file"
cat $(find ${runf}/fastq_pass -name *.fastq | sort -k 1V,1) \
| bgzip -c > ${tmpf}/${pfx}_pass.fq.gz
echo "# creating checksum and checking it"
md5sum ${tmpf}/${pfx}_pass.fq.gz > ${tmpf}/${pfx}_pass.fq.gz_md5.txt && \
md5sum -c ${tmpf}/${pfx}_pass.fq.gz_md5.txt
# copy Nanopore_SumStatQC files if present
if [ -d "Nanopore_SumStatQC" ]; then
cp Nanopore_SumStatQC/config.yaml ${tmpf}/
cp Nanopore_SumStatQC/Nanopore_SumStatQC.{pdf,html} ${tmpf}/
fi
echo "# data in ${tmpf} is ready for copy to the T: drive"
# check that the transfer drive is mounted
if grep -qs '/mnt/nuc-transfer ' /proc/mounts; then
echo "# nuc-transfer (T:) is mounted. You can run the last command to copy the data to T:"
else
echo "# nuc-transfer (T:) is NOT mounted, mount it first before issuing the next command."
fi
echo "# rsync -avr ${tmpf}/* /mnt/nuc-transfer/0003_Runs/GridION/${runf:0:4}-${runf:4:2}/${tmpf%%_data}"
echo "# after copy, please delete the local copy with:"
echo "# rm -rf ${tmpf}"