Skip to content

Instantly share code, notes, and snippets.

@rpetit3
Created August 10, 2016 15:38
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 rpetit3/9c623454758c9885bf81d269e3453b76 to your computer and use it in GitHub Desktop.
Save rpetit3/9c623454758c9885bf81d269e3453b76 to your computer and use it in GitHub Desktop.
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