Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (34 sloc) 1.23 KB
#!/bin/bash
# bam_to_fastq2 0.0.1
# Generated by dx-app-wizard.
main() {
echo "Value of bam: '$bam'"
echo "Value of params: '$params'"
# boilerplate stuff needed to get dnanexus samtools running in the ubuntu
# 12.04 execution environment
rm /etc/apt/apt.conf.d/99dnanexus
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install -y gcc-4.8 g++-4.8
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
bzip2 -d /samtools.bz2
chmod +x /samtools
# sort reads by name
dx cat $(dx-jobutil-parse-link "$bam") | /samtools rocksort -n -@ 4 -m 2560M -l 1 - input
# show read groups
/samtools view -H input.bam | grep '^@RG'
# run picard SamToFastq
mkdir fastq
java -Xmx12g -jar /opt/jar/SamToFastq.jar \
INPUT=input.bam RE_REVERSE=true INCLUDE_NON_PF_READS=true \
OUTPUT_PER_RG=true OUTPUT_DIR=fastq $params
# compress, upload, & output fastq files
cd fastq
ls -lh
for fq in *.fastq; do
echo $fq
fid=$(pigz -c "$fq" | dx upload --brief --path "${fq}.gz" -)
dx-jobutil-add-output fastq "$fid" --class=array:file
done
}