-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_table.sh
41 lines (30 loc) · 895 Bytes
/
make_table.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
#!/bin/bash
# Systems Immunology Lab, WUSTL
NAME=$1 ## common prefix in BED files to be processed, e.g. [proB]_H3K27ac, [proB]_H3K4me1, etc
WFILE=$2 ## genomic windows
CHROMSIZES=$3
echo "This script is intended to run on multiple CPUs"
KK=`awk '{print $1}' $CHROMSIZES`
for i in $NAME*.bed
do
bedtools intersect -c -f 0.5 -b $i -a hg19.200bp_windows.bed > ${i%%.bed}_binary.bed &
done
wait
for i in $NAME*_binary.bed
do
for j in $KK
do
grep -P "$j\t" $i | awk '{print $4}' > ${i%%_binary.bed}_${j}.x &
done
wait
echo "done processing $i"
done
ls $NAME*_chr1.x | sed "s/_chr1\.x//g" | sed "s/${NAME}_//g"> $NAME.$$.marks
PP=`cat $NAME.$$.marks`
for j in $KK
do
echo "$NAME $j" | sed "s/ /\t/g" > ${NAME}_${j}_binary.txt
echo $PP | sed "s/ /\t/g" >> ${NAME}_${j}_binary.txt
paste $NAME*_${j}.x >> ${NAME}_${j}_binary.txt
done
rm *.x *binary.bed $NAME.$$.marks