#!/bin/bash -euo pipefail
STAR \
--genomeDir ref_genome.fa.star.idx \
--readFilesIn input1/dna_s716_1.fastp.fastq.gz input2/dna_s716_2.fastp.fastq.gz \
--runThreadN 24 \
--outFileNamePrefix dna_s716. \
\
--sjdbGTFfile ref_annot.gtf \
--outSAMattrRGline 'ID:dna_s716' 'SM:dna_s716' \
--twopassMode None --chimSegmentMin 12 --chimJunctionOverhangMin 5 --chimMultimapNmax 50 --chimScoreJunctionNonGTAG -4 --chimScoreSeparation 1 --alignIntronMax 140000 --outReadsUnmapped None --readFilesCommand zcat --outSAMtype BAM SortedByCoordinate --outSAMstrandField intronMotif --outSAMunmapped Within --chimOutJunctionFormat 1 --alignSJDBoverhangMin 10 --alignMatesGapMax 100000 --alignSJstitchMismatchNmax 5 -1 5 5 --chimMultimapScoreRange 3 --chimNonchimScoreDropMin 10 --peOverlapNbasesMin 12 --peOverlapMMp 0.1 --alignInsertionFlush Right --alignSplicedMateMapLmin 30 --alignSplicedMateMapLminOverLmate 0.5 --quantMode GeneCounts --runRNGseed 1 --chimOutType Junctions WithinBAM --limitBAMsortRAM 38654705664
# Sort Chimeric.out.junction file for consistent output between runs
# Preserve header (first line) and comments (lines starting with #) at the end
if [ -f dna_s716.Chimeric.out.junction ]; then
head -n 1 dna_s716.Chimeric.out.junction > dna_s716.Chimeric.out.junction.tmp
tail -n +2 dna_s716.Chimeric.out.junction | grep -v '^#' | LC_ALL=C sort -k1,1 -k2,2n -k3,3 -k4,4 -k5,5n -k6,6 >> dna_s716.Chimeric.out.junction.tmp || true
tail -n +2 dna_s716.Chimeric.out.junction | grep '^#' >> dna_s716.Chimeric.out.junction.tmp || true
mv dna_s716.Chimeric.out.junction.tmp dna_s716.Chimeric.out.junction
fi
if [ -f dna_s716.Unmapped.out.mate1 ]; then
mv dna_s716.Unmapped.out.mate1 dna_s716.unmapped_1.fastq
gzip dna_s716.unmapped_1.fastq
fi
if [ -f dna_s716.Unmapped.out.mate2 ]; then
mv dna_s716.Unmapped.out.mate2 dna_s716.unmapped_2.fastq
gzip dna_s716.unmapped_2.fastq
fi
cat <<-END_VERSIONS > versions.yml
"NFCORE_RNAFUSION:RNAFUSION:FASTQ_ALIGN_STAR:STAR_ALIGNMENT":
star: $(STAR --version | sed -e "s/STAR_//g")
samtools: $(echo $(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*$//')
gawk: $(echo $(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*$//')
END_VERSIONS