Mercurial > repos > kyost > atac_primer_tool
comparison filter_bam.bash @ 0:fd3ea97a96bc draft
planemo upload commit 103cb51ec368438642504c3f98b76c363db478bb
author | kyost |
---|---|
date | Sat, 28 Apr 2018 15:07:26 -0400 |
parents | |
children | 3cd53127a838 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fd3ea97a96bc |
---|---|
1 #Requires bam files and bed file containing coordinates of peaks of interest | |
2 #Generates filtered bams and library size file to upload into Galaxy | |
3 | |
4 #required arguements: | |
5 #($1): bam file | |
6 #($2): bed file containing regions of interest | |
7 | |
8 #Usage: filter_bam /pathtofolder/ qPCR_peaks.bed | |
9 | |
10 #outputs: | |
11 #Filtered bam files containing reads in regions of interest | |
12 #read_counts: txt file containing number of mapped reads in each bam file, used for normalization | |
13 | |
14 bam_file=$1 | |
15 peak_file=$2 | |
16 chrom_sizes=$3 | |
17 ext_peak_file=$4 | |
18 filtered_bam_file=$5 | |
19 read_counts=$6 | |
20 name=$7 | |
21 | |
22 bedtools slop -i $peak_file -g $chrom_sizes -b 2000 | sort -k1,1 -k2,2n - > $ext_peak_file | |
23 | |
24 samtools index $bam_file | |
25 | |
26 samtools view -c -F 1284 $bam_file > count | |
27 echo $name > name | |
28 paste name count > $read_counts | |
29 | |
30 #create bed file of fragments for each bam file | |
31 | |
32 samtools view -b -L $ext_peak_file $bam_file > $filtered_bam_file | |
33 | |
34 rm name | |
35 rm count |