19 lines
495 B
Bash
Executable File
19 lines
495 B
Bash
Executable File
#! /bin/bash
|
|
set -e
|
|
THREADS=${THREADS:-6}
|
|
if [ "$#" -ne 4 ]; then
|
|
echo "Usage: $0 <reference_genome> <fastq_1> <fastq_2> <output_prefix>"
|
|
exit 1
|
|
fi
|
|
|
|
ref=$1
|
|
fq1=$2
|
|
fq2=$3
|
|
out=$4
|
|
outdir=$(dirname "$out")
|
|
mkdir -p "$outdir"
|
|
hisat2 -p "$THREADS" --dta -x "$ref" -1 "$fq1" -2 "$fq2" -S "${out}.sam"
|
|
samtools view -b -@ "$THREADS" "${out}.sam" | samtools sort -@ "$THREADS" -o "${out}.sorted.bam" --write-index
|
|
rm "${out}.sam"
|
|
echo "Mapping completed. Sorted BAM file is at ${out}.sorted.bam"
|