| 1 |
#! /bin/bash |
| 2 |
|
| 3 |
test $# = 2 || { |
| 4 |
cat <<EOF |
| 5 |
Usage: $0 x.fastq y.fastq |
| 6 |
or: $0 x.fastq.gz y.fastq.gz |
| 7 |
|
| 8 |
Read 2 fastq files, and write them interleaved. Keep just the first |
| 9 |
word of header lines, and append "/1" and "/2" if they are otherwise |
| 10 |
identical. Assumes 1 fastq per 4 lines, i.e. no line wrapping. |
| 11 |
EOF |
| 12 |
exit |
| 13 |
} |
| 14 |
|
| 15 |
fastqTab () { |
| 16 |
gzip -cdf "$@" | |
| 17 |
sed -e 's/^@ */@/' -e 's/ .*//' | |
| 18 |
paste - - - - |
| 19 |
} |
| 20 |
|
| 21 |
paste <(fastqTab "$1") <(fastqTab "$2") | |
| 22 |
awk '$1 == $5 {$1 = $1 "/1"; $5 = $5 "/2"} $1 = $1' OFS="\n" |