1##
2#
3# script to add links to postscript file that was produced using the plot.awk script from ROIs.
4# usage :    gawk -v roiFile=infile.roi \
5#                 -f ps2pswLinks.gawk \
6#                 infile.roi.ps > outfile.ps
7# infile.roi.ps was created using plot.awk
8# infile.roi is the same file that was used to generate the infile.roi.ps
9#
10# the link to the localhost, i.e. the genome browser to be used can be changed at the end of the script.
11# current version is using the default for IGV on localhost.
12#
13
14
15BEGIN{
16longstring="\
17[ /Rect [124 87 240 257]\n\
18/Border [0 0 0]\n\
19/Color [0 0 1]\n\
20/Action << /Subtype /URI /URI (__URI1__) >>\n\
21/Subtype /Link\n\
22/ANN pdfmark\n\
23[ /Rect [275 87 391 257]\n\
24/Border [0 0 0]\n\
25/Color [0 0 1]\n\
26/Action << /Subtype /URI /URI (__URI4__) >>\n\
27/Subtype /Link\n\
28/ANN pdfmark\n\
29[ /Rect [426 87 542 257]\n\
30/Border [0 0 0]\n\
31/Color [0 0 1]\n\
32/Action << /Subtype /URI /URI (__URI7__) >>\n\
33/Subtype /Link\n\
34/ANN pdfmark\n\
35[ /Rect [124 297 240 473]\n\
36/Border [0 0 0]\n\
37/Color [0 0 1]\n\
38/Action << /Subtype /URI /URI (__URI2__) >>\n\
39/Subtype /Link\n\
40/ANN pdfmark\n\
41[ /Rect [275 297 391 473]\n\
42/Border [0 0 0]\n\
43/Color [0 0 1]\n\
44/Action << /Subtype /URI /URI (__URI5__) >>\n\
45/Subtype /Link\n\
46/ANN pdfmark\n\
47[ /Rect [426 297 542 473]\n\
48/Border [0 0 0]\n\
49/Color [0 0 1]\n\
50/Action << /Subtype /URI /URI (__URI8__) >>\n\
51/Subtype /Link\n\
52/ANN pdfmark\n\
53[ /Rect [124 507 240 689]\n\
54/Border [0 0 0]\n\
55/Color [0 0 1]\n\
56/Action << /Subtype /URI /URI (__URI3__) >>\n\
57/Subtype /Link\n\
58/ANN pdfmark\n\
59[ /Rect [275 507 391 689]\n\
60/Border [0 0 0]\n\
61/Color [0 0 1]\n\
62/Action << /Subtype /URI /URI (__URI6__) >>\n\
63/Subtype /Link\n\
64/ANN pdfmark\n\
65[ /Rect [426 507 542 689]\n\
66/Border [0 0 0]\n\
67/Color [0 0 1]\n\
68/Action << /Subtype /URI /URI (__URI9__) >>\n\
69/Subtype /Link\n\
70/ANN pdfmark\n\
71showpage\n\
72"
73if(roiFile==""){
74   print "Error: I need the variable roiFile to be set (-v roiFile=filename)" > "/dev/stderr"
75   exit -1
76}
77}
78/showpage/{
79   outstring = longstring
80   for(i=1;i<=9;i++){
81      roiLine=""
82      while(roiLine==""){
83         if( (getline roiLine < roiFile) <= 0){
84	    break
85	 }
86	 if(substr(roiLine,1,1)=="#"){
87	    roiLine=""
88	 }
89      }
90      split(roiLine,roiArr, "\t")
91      gsub("__URI"i"__","http://localhost:60151/goto?locus="roiArr[1]":"roiArr[2]"-"roiArr[3],outstring)
92   }
93   print outstring
94   next
95}
96{print}
97