-
Notifications
You must be signed in to change notification settings - Fork 4
/
minimap2-samtools.pbs.sh
executable file
·62 lines (46 loc) · 1.7 KB
/
minimap2-samtools.pbs.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
#!/bin/bash
#PBS -P ox63
#PBS -N MINIMAP2_SAMTOOLS
#PBS -q normal
#PBS -l ncpus=16
#PBS -l mem=64GB
#PBS -l walltime=48:00:00
#PBS -l wd
#PBS -l storage=gdata/if89+gdata/ox63
###################################################################
###################################################################
# Make sure to change:
# 1. ox63 to your own projects
# to run:
# qsub -v REF=/path/to/ref.fa,FASTQ=/path/to/reads.fastq,OUT_DIR=/path/to/outdir ./minimap2_samtools.pbs.sh
###################################################################
usage() {
echo "Usage: qsub -v REF=/path/to/ref.fa,FASTQ=/path/to/reads.fastq,OUT_DIR=/path/to/outdir ./minimap2_samtools.pbs.sh" >&2
echo
exit 1
}
#directory where BAM output should be written to
[ -z "${OUT_DIR}" ] && usage
#fastq
[ -z "${FASTQ}" ] && usage
#ref
[ -z "${REF}" ] && usage
module load minimap2/2.24
module load samtools/1.12
###################################################################
# terminate script
die() {
echo "$1" >&2
echo
exit 1
}
minimap2 --version || die "Could not find minimap2"
samtools --version || die "Could not find samtools"
test -d ${OUT_DIR} && die "Output directory ${OUT_DIR} already exists. Please delete it first or give an alternate location. Exiting."
test -e ${FASTQ} || die "${FASTQ} not found. Exiting."
test -e ${REF} || die "${REF} not found. Exiting."
mkdir ${OUT_DIR} || die "Creating directory ${OUT_DIR} failed. Exiting."
cd ${OUT_DIR} || die "${OUT_DIR} not found. Exiting."
/usr/bin/time -v minimap2 -ax map-ont ${REF} ${FASTQ} -t 16 --secondary=no | samtools sort - -T . -o reads.bam || die "alignment failed"
/usr/bin/time -v samtools index reads.bam || die "index failed"
echo "alignment success"