Skip to content

Instantly share code, notes, and snippets.

@armintoepfer
Created September 28, 2017 22:23
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 armintoepfer/5a62ee07da15269782cf0439433f9823 to your computer and use it in GitHub Desktop.
Save armintoepfer/5a62ee07da15269782cf0439433f9823 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
coverage=${COVERAGE:-3000}
percentage=${PERCENTAGE:-1}
outputprefix=${OUTPUT_PREFIX:-mix}
numdatasets=$#
coverageMajority=$((coverage * (100 - (numdatasets - 1) * percentage) / 100))
coverageMinority=$((coverage * percentage / 100))
samtools view -H $1 > ${outputprefix}.sam
for i in ${@:2}
do
samtools view -H $i | grep '^@RG' >> ${outputprefix}.sam
done
samtools view $1 | shuf | head -n $coverageMajority >> ${outputprefix}.sam
shift
while test $# -gt 0
do
samtools view $1 | shuf | head -n $coverageMinority >> ${outputprefix}.sam
shift
done
samtools view -@10 -bS ${outputprefix}.sam > ${outputprefix}.bam
rm ${outputprefix}.sam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment