-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessing_peaks.sh
More file actions
49 lines (47 loc) · 1.11 KB
/
Copy pathpreprocessing_peaks.sh
File metadata and controls
49 lines (47 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/bash
help_str="
-h, --help: print helo info
-g, --genome string: reference chromsizes
-o, --outdir string: output directory
"
getopt_cmd=$(getopt -o hg:b:o: --long help,genome:,bedfiles:,outdir: -n $(basename $0) -- "$@")
[ $? -ne 0 ] && exit 1
eval set -- "$getopt_cmd"
while [ -n "$1" ]
do
case "$1" in
-h|--help)
echo -e "$help_str"
exit ;;
-g|--genome)
genome="$2"
shift ;;
-o|--outdir)
outdir="$2"
shift ;;
--) shift
break ;;
*) echo "$1 is not an invalid option"
exit 1 ;;
esac
shift
done
dir=`pwd`
cd ${outdir}
arr=($*)
bedtools makewindows -g $genome -w 200 -s 200 > hg19.txt
mkdir -p tmp/
for i in ${arr[@]}
do
cp ${dir}/${i} tmp/
done
bedtools multiinter -i tmp/* | bedtools window -w 900 -u -a hg19.txt -b - > overlap
cp overlap coverage
for((i=0;i<${#arr[*]};i++))
do
echo 'Processing' ${arr[i]}
bedtools coverage -a overlap -b ${dir}/${arr[i]} | cut -f 5 -| paste coverage - > tmp_cov;
mv tmp_cov coverage;
done
rm -r tmp/
rm overlap