Created
August 10, 2016 15:38
-
-
Save rpetit3/9c623454758c9885bf81d269e3453b76 to your computer and use it in GitHub Desktop.
Subsample S. aureus FASTQ to a given coverage using SeqTK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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