annotate deinterleave_fastq.sh @ 1:f8e2c8bc540d tip

Uploaded
author estrain
date Wed, 02 Oct 2019 16:59:09 -0400
parents 18c8b4d6ab1e
children
rev   line source
estrain@0 1 #!/bin/bash
estrain@0 2 # Usage: deinterleave_fastq.sh < interleaved.fastq f.fastq r.fastq [compress]
estrain@0 3 #
estrain@0 4 # Deinterleaves a FASTQ file of paired reads into two FASTQ
estrain@0 5 # files specified on the command line. Optionally GZip compresses the output
estrain@0 6 # FASTQ files using pigz if the 3rd command line argument is the word "compress"
estrain@0 7 #
estrain@0 8 # Can deinterleave 100 million paired reads (200 million total
estrain@0 9 # reads; a 43Gbyte file), in memory (/dev/shm), in 4m15s (255s)
estrain@0 10 #
estrain@0 11 # Latest code: https://gist.github.com/3521724
estrain@0 12 # Also see my interleaving script: https://gist.github.com/4544979
estrain@0 13 #
estrain@0 14 # Inspired by Torsten Seemann's blog post:
estrain@0 15 # http://thegenomefactory.blogspot.com.au/2012/05/cool-use-of-unix-paste-with-ngs.html
estrain@0 16
estrain@0 17 # Set up some defaults
estrain@0 18 GZIP_OUTPUT=0
estrain@0 19 PIGZ_COMPRESSION_THREADS=10
estrain@0 20
estrain@0 21 # If the third argument is the word "compress" then we'll compress the output using pigz
estrain@0 22 if [[ $3 == "compress" ]]; then
estrain@0 23 GZIP_OUTPUT=1
estrain@0 24 fi
estrain@0 25
estrain@0 26 if [[ ${GZIP_OUTPUT} == 0 ]]; then
estrain@0 27 paste - - - - - - - - | tee >(cut -f 1-4 | tr "\t" "\n" > $1) | cut -f 5-8 | tr "\t" "\n" > $2
estrain@0 28 else
estrain@0 29 paste - - - - - - - - | tee >(cut -f 1-4 | tr "\t" "\n" | pigz --best --processes ${PIGZ_COMPRESSION_THREADS} > $1) | cut -f 5-8 | tr "\t" "\n" | pigz --best --processes ${PIGZ_COMPRESSION_THREADS} > $2
estrain@0 30 fi