#!/bin/bash -Ceuo pipefail
INDEX=`find -L ./ -name "*.amb" | sed 's/\.amb$//'`
export bwt_max_mem=112G
sentieon bwa mem \
-K 100000000 -Y -R '@RG\tID:20260603_LH00166_0309_A23WCJNLT4.T21-D0003322.L007\tPU:L007\tSM:T21-D0003322\tLB:T21-D0003322\tDS:s3://natera-platform-sandbox/pipeline-resources/ngi-igenomes/igenomes/Homo_sapiens/GATK/GRCh38/Sequence/WholeGenomeFasta/Homo_sapiens_assembly38.fasta\tPL:ILLUMINA' \
-t 31 \
$INDEX \
T21-D0003322_R1.fastq.gz T21-D0003322_R2.fastq.gz \
| sentieon util sort \
-r Homo_sapiens_assembly38.fasta \
-t 31 \
-o T21-D0003322.bam \
--sam2bam \
-
# When outputting CRAM, sentieon util sort may create a spurious .bai index.
# Remove it since CRAM uses .crai indices.
if [ "bam" = "cram" ] && [ -f "T21-D0003322.cram.bai" ]; then
rm -f T21-D0003322.cram.bai
fi
cat <<-END_VERSIONS > versions.yml
"DAQ:SENTIEON_BWAMEM":
sentieon: $(echo $(sentieon driver --version 2>&1) | sed -e "s/sentieon-genomics-//g")
END_VERSIONS