Skip to content

Instantly share code, notes, and snippets.

@nathanhaigh
Last active March 28, 2022 09:11
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save nathanhaigh/4544979 to your computer and use it in GitHub Desktop.
Save nathanhaigh/4544979 to your computer and use it in GitHub Desktop.
Interleave reads from 2 FASTQ files and output to STDOUT.
#!/bin/bash
# Usage: interleave_fastq.sh f.fastq r.fastq > interleaved.fastq
#
# Interleaves the reads of two FASTQ files specified on the
# command line and outputs a single FASTQ file of STDOUT.
#
# Can interleave 100 million paired reads (200 million total
# reads; a 2 x 22Gbyte files), in memory (/dev/shm), in 6m54s (414s)
#
# Latest code: https://gist.github.com/4544979
# Also see my deinterleaving script: https://gist.github.com/3521724
paste $1 $2 | paste - - - - | awk -v OFS="\n" -v FS="\t" '{print($1,$3,$5,$7,$2,$4,$6,$8)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment