Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Subsample S. aureus FASTQ to a given coverage using SeqTK
#! /bin/bash
# Subsample reads from a given S. aureus FASTQ file.
#
# Program: seqtk (https://github.com/lh3/seqtk)
# Version: commit 43ff625a3211b51f301cb356a34fb8d1e593d50a
#
# Example: subsample-fq.sh 0.25 saureus.fastq.gz
#
set -x # Echo all commands
# Use N315 genome size
GENOME_SIZE=2814816
READ_LENGTH=100
COVERAGE=$1
FASTQ=$2
# Reduce coverage by randomly subsampling the reads useing seqtk
TOTAL_READS=`echo "${GENOME_SIZE} * ${COVERAGE} / ${READ_LENGTH}" | bc`
echo seqtk sample -s${READ_LENGTH} ${FASTQ} ${TOTAL_READS} | gzip - > ${COVERAGE}-${FASTQ}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.