forked from Jia-Yu-Chen/RChIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.sh
56 lines (51 loc) · 1.9 KB
/
profile.sh
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
50
51
52
53
54
55
56
#!/bin/bash
fwd=${1?bigwig file in fwd strand}
rev=${2?bigwig file in rev strand}
bed6=${3:-../../data/R-ChIP/HEK293/peaks/narrow/all.peaks.bed6}
ref=${4:-~jchen/public/hg19.chrom.sizes}
left=${5:-2000}
right=${6:-2000}
# upstream
bedtools flank -i $bed6 -l $left -r 0 -g $ref -s | while read region;
do
chr=`echo $region|cut -d " " -f 1`;
sta=`echo $region|cut -d " " -f 2`;
end=`echo $region|cut -d " " -f 3`;
str=`echo $region|cut -d " " -f 6`;
if [ "$str" = "+" ]; then
status=`bigWigSummary $fwd $chr $sta $end 200`
else
status=`bigWigSummary $rev $chr $sta $end 200 | perl -ne '@t=split;print join("\t",reverse(@t)),"\n";'`
fi
if [ "$status" = "" ];then perl -e 'print join(" ",split("",0 x 200)),"\n"';else echo $status; fi
done > upstream
# central
cat $bed6 | while read region;
do
chr=`echo $region|cut -d " " -f 1`;
sta=`echo $region|cut -d " " -f 2`;
end=`echo $region|cut -d " " -f 3`;
str=`echo $region|cut -d " " -f 6`;
if [ "$str" = "+" ]; then
status=`bigWigSummary $fwd $chr $sta $end 100`
else
status=`bigWigSummary $rev $chr $sta $end 100 | perl -ne '@t=split;print join("\t",reverse(@t)),"\n";'`
fi
if [ "$status" = "" ];then perl -e 'print join(" ",split("",0 x 100)),"\n"';else echo $status; fi
done > central
# downstream
bedtools flank -i $bed6 -r $right -l 0 -g $ref -s | while read region;
do
chr=`echo $region|cut -d " " -f 1`;
sta=`echo $region|cut -d " " -f 2`;
end=`echo $region|cut -d " " -f 3`;
str=`echo $region|cut -d " " -f 6`;
if [ "$str" = "+" ]; then
status=`bigWigSummary $fwd $chr $sta $end 200`
else
status=`bigWigSummary $rev $chr $sta $end 200 | perl -ne '@t=split;print join("\t",reverse(@t)),"\n";'`
fi
if [ "$status" = "" ];then perl -e 'print join(" ",split("",0 x 200)),"\n"';else echo $status; fi
done > downstream
paste upstream central downstream | sed 's/\t/ /g' | sed 's/n\/a/0/g'
rm upstream central downstream