Created
August 21, 2017 03:16
-
-
Save hliang/bd6db195e21cf9ae567ce2dffea587ba to your computer and use it in GitHub Desktop.
exome target coverage: http://www.gettinggeneticsdone.com/2014/03/visualize-coverage-exome-targeted-ngs-bedtools.html
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 | |
#SBATCH -p bcbio | |
#SBATCH -a 1-60 | |
set -e | |
source /WORK/app/toolshs/cnmodule.sh | |
module load bedtools/2.26.0 | |
which bedtools | |
bedtools --version | |
## create output dir | |
[ -d "bedcov" ] || mkdir bedcov | |
## monitor | |
collectl -i 5 -c 3600 -scmdn -f ./bedcov & | |
## Set up to run in GNU parallel. | |
# find ../out_bcbio/final/ -name "*-ready.bam" | sort | sed -n "$SLURM_ARRAY_TASK_ID, $((SLURM_ARRAY_TASK_ID + 1)) p" | parallel -j 2 'bedtools coverage -hist -sorted -a ../ex_region.sort.bed -b {} | grep ^all > ./bedcov/{/}.hist.all.txt ' | |
# What this actually runs: | |
# bedtools coverage -hist -a target_regions.bed -b samp.01.bam | grep ^all > samp.01.bam.hist.all.txt | |
# bedtools coverage -hist -a target_regions.bed -b samp.02.bam | grep ^all > samp.02.bam.hist.all.txt | |
inbam=`find ../out_bcbio/final/ -name "*-ready.bam" | sort | sed -n "$SLURM_ARRAY_TASK_ID p"` | |
bedfile="../ex_region.sort.bed" | |
outtxt="./bedcov/"`basename $inbam`".hist.all.txt" | |
if [ -f $outtxt.ok ]; then | |
echo skip because file exists | |
else | |
echo "bedtools coverage -hist -sorted -g hg19.genomeFile.txt -a ../ex_region.sort.bed -b $inbam | grep '^all' > $outtxt" | |
bedtools coverage -hist -sorted -g hg19.genomeFile.txt -a ../ex_region.sort.bed -b $inbam | grep '^all' > $outtxt && touch $outtxt.ok | |
fi | |
## stop collectl | |
kill %1 | |
echo "DONE in $SECONDS seconds" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment