Created
September 28, 2017 22:23
-
-
Save armintoepfer/5a62ee07da15269782cf0439433f9823 to your computer and use it in GitHub Desktop.
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
#!/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