Skip to content

Instantly share code, notes, and snippets.

@slavailn
Last active November 21, 2024 23:39
Show Gist options
  • Save slavailn/258ed33a0bca67b8b5296b0dde58b7a6 to your computer and use it in GitHub Desktop.
Save slavailn/258ed33a0bca67b8b5296b0dde58b7a6 to your computer and use it in GitHub Desktop.
Merge fastq files that belong to the same sample, but were generated from different lanes
#! /bin/bash
# Taken from https://www.biostars.org/p/317385/
#! /bin/bash
for i in $(find ./ -type f -name "*.fastq.gz" | while read F; do basename $F | rev | cut -c 22- | rev; done | sort | uniq)
do echo "Merging R1"
echo "$i"_L00*_R1_001.fastq.gz
echo "$i"_ME_L001_R1_001.fastq
zcat "$i"_L00*_R1_001.fastq.gz > "$i"_ME_L001_R1_001.fastq
echo "Merging R2"
zcat "$i"_L00*_R2_001.fastq.gz > "$i"_ME_L001_R2_001.fastq
echo "$i"_L00*_R2_001.fastq.gz
echo "$i"_ME_L001_R2_001.fastq
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment