Mercurial > repos > kyost > atac_primer_tool
diff filter_bam.bash @ 0:fd3ea97a96bc draft
planemo upload commit 103cb51ec368438642504c3f98b76c363db478bb
author | kyost |
---|---|
date | Sat, 28 Apr 2018 15:07:26 -0400 |
parents | |
children | 3cd53127a838 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filter_bam.bash Sat Apr 28 15:07:26 2018 -0400 @@ -0,0 +1,35 @@ +#Requires bam files and bed file containing coordinates of peaks of interest +#Generates filtered bams and library size file to upload into Galaxy + +#required arguements: +#($1): bam file +#($2): bed file containing regions of interest + +#Usage: filter_bam /pathtofolder/ qPCR_peaks.bed + +#outputs: +#Filtered bam files containing reads in regions of interest +#read_counts: txt file containing number of mapped reads in each bam file, used for normalization + +bam_file=$1 +peak_file=$2 +chrom_sizes=$3 +ext_peak_file=$4 +filtered_bam_file=$5 +read_counts=$6 +name=$7 + +bedtools slop -i $peak_file -g $chrom_sizes -b 2000 | sort -k1,1 -k2,2n - > $ext_peak_file + +samtools index $bam_file + +samtools view -c -F 1284 $bam_file > count +echo $name > name +paste name count > $read_counts + +#create bed file of fragments for each bam file + +samtools view -b -L $ext_peak_file $bam_file > $filtered_bam_file + +rm name +rm count