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