Skip to content

Instantly share code, notes, and snippets.

@michaelsilverstein
Last active June 18, 2021 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelsilverstein/04c880b8e7728982ee57399599cfb56d to your computer and use it in GitHub Desktop.
Save michaelsilverstein/04c880b8e7728982ee57399599cfb56d to your computer and use it in GitHub Desktop.
Deinterleave entire directory of compressed .fastq.gz files and re-compress mates
#!/bin/bash
# Uses this incredible script, deinterleave_fastq.sh, and associated comments: https://gist.github.com/nathanhaigh/3521724
# Usage: deinterleave_dir.sh indir outdir
# Deinterleave entire directory of compressed .fastq.gz files from `indir` and re-compresses mates with
# _R1.fastq.gz and _R2.fastq.gz suffixes to `ourdir`
# Download deinterleave_fastq.sh
wget https://gist.githubusercontent.com/nathanhaigh/3521724/raw/5d4cc310d65ce798c2b030756a2b855cf55ecbcd/deinterleave_fastq.sh
# Make output directory
mkdir $2
# Deinterleave each compressed file and save to output directory
for file in $1/*
do
echo $file
out1=$2/$(basename ${file%.fastq.gz})_R1.fastq.gz
out2=$2/$(basename ${file%.fastq.gz})_R2.fastq.gz
pigz --best --processes 16 -dc $file | bash deinterleave_fastq.sh $out1 $out2 compress
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment