0
|
1 #!/bin/bash
|
|
2
|
|
3 # convert junctions file to input for circos to display links
|
|
4 # usage: junctions2circos.sh <input file> <output file>
|
|
5
|
|
6 # output format: hs1 start end hs2 start end
|
|
7
|
|
8 infile=$1
|
|
9 outfile=$2
|
|
10 bedfile=$3
|
|
11
|
|
12 if [ $# -ne 3 ]
|
|
13 then
|
|
14 echo "error, unexpected number of arguments in $0"
|
|
15 exit
|
|
16 fi
|
|
17
|
|
18 ### convert junctions file
|
|
19 echo "converting junctions files"
|
|
20
|
|
21 fname=`basename $infile`
|
|
22
|
|
23 echo "infile: $infile, outfile: $outfile, fname: $fname"
|
|
24
|
|
25 # remove header and 'chr'
|
|
26 sed '1,13d' $infile > $fname
|
|
27 sed -i 's/chr//g' $fname
|
|
28
|
|
29 # make output for links in circos
|
|
30 awk 'BEGIN{
|
|
31 FS="\t";
|
|
32 OFS=" "
|
|
33 }{
|
|
34 if($2 != "M" && $6 != "M")
|
|
35 print "hs"$2,$3,$3,"hs"$6,$7,$7;
|
|
36 }END{}' $fname > $outfile
|
|
37
|
|
38
|
|
39 #make bedfile to find impacted genes
|
|
40 awk 'BEGIN{
|
|
41 FS="\t";
|
|
42 OFS="\t"
|
|
43 }{
|
|
44 if($2 != "M" && $6 != "M"){
|
|
45 print "chr"$2,$3,$3; #left side
|
|
46 print "chr"$6,$7,$7; #right side
|
|
47 }
|
|
48
|
|
49 }END{}' $fname > $bedfile
|