0
|
1 gbcount=0
|
|
2
|
|
3 ##
|
|
4 ## Create Cover Page
|
|
5 ##
|
4
|
6 #<a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/>
|
0
|
7 function makeIntroPage ( ){
|
|
8 echo "Creating Intro Page"
|
|
9 title="$1"
|
|
10 coverimage=$2
|
|
11 link=$3
|
|
12 htmlout=$4
|
|
13 zipireport=$5
|
|
14
|
|
15 echo -e "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
|
|
16 <html>
|
|
17 <head>
|
|
18 </head>
|
|
19 <body>
|
|
20 <br/>
|
|
21 <br/>
|
|
22 <center>
|
|
23 <b><font size=\"15\"> iReport: ${title} </font></b><br/>
|
|
24 <br/>
|
|
25 <br/>
|
1
|
26 <a href=\"$link\"> Click image to view report </a> <br/><br/>
|
0
|
27 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/>
|
|
28 </center>
|
|
29 </body>
|
|
30 </html>" > $htmlout
|
|
31
|
|
32 }
|
|
33
|
|
34 ##
|
|
35 ## Decompress archive fiels
|
|
36 ## -> will detect archive formats: zip, tar, gzip, tar.gz, bzip2
|
|
37 ## -> input: path to archive
|
|
38 ## -> files will be located in ${galaxypath}/archive_${fname}/
|
|
39 ##
|
|
40 function decompressArchive (){
|
|
41 archive=$1
|
|
42
|
|
43 fname=`basename ${archive}`
|
|
44 fname=${fname%.dat}
|
|
45 ftype=`file $archive`
|
|
46
|
|
47 if [[ ! -d ${galaxypath}/archive_${fname}/ ]]
|
|
48 then
|
|
49 mkdir ${galaxypath}/archive_${fname}/
|
|
50
|
|
51 #echo "archive type: `file $archive`"
|
|
52 # decompress archive
|
|
53 if [[ $ftype == *Zip* ]]
|
|
54 then
|
|
55 #echo "detected zip file"
|
|
56 cp $archive ${galaxypath}/archive_${fname}/${fname}.zip
|
|
57 wd=`pwd`
|
|
58 cd ${galaxypath}/archive_${fname}/
|
|
59 unzip -q ${fname}.zip
|
|
60 rm ${fname}.zip
|
|
61 cd $wd
|
|
62 fi
|
|
63 if [[ $ftype == *tar* ]]
|
|
64 then
|
|
65 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar
|
|
66 wd=`pwd`
|
|
67 cd ${galaxypath}/archive_${fname}/
|
|
68 tar xf ${fname}.tar
|
|
69 rm ${fname}.tar
|
|
70 cd $wd
|
|
71 fi
|
|
72 if [[ $ftype == *gzip* ]]
|
|
73 then
|
|
74 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz
|
|
75 gunzip ${galaxypath}/archive_${fname}/${fname}.gz
|
|
76 #ls ${galaxypath}/archive_${fname}/
|
|
77
|
|
78 # check for tar.gz
|
|
79 ftype=`file ${galaxypath}/archive_${fname}/${fname}`
|
|
80 if [[ $ftype == *tar* ]]
|
|
81 then
|
|
82 # turns out it was tar.gz
|
|
83 rm -Rf ${galaxypath}/archive_${fname}/*
|
|
84 ls ${galaxypath}/archive_${fname}/
|
|
85 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar.gz
|
|
86
|
|
87 wd=`pwd`
|
|
88 cd ${galaxypath}/archive_${fname}/
|
|
89 tar xzf ${fname}.tar.gz
|
|
90 cd $wd
|
|
91 fi
|
|
92 wait
|
|
93 rm -f ${galaxypath}/archive_${fname}/*.tar
|
|
94 rm -f ${galaxypath}/archive_${fname}/*.tar.gz
|
|
95 fi
|
|
96 if [[ $ftype == *bzip2* ]]
|
|
97 then
|
|
98 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz
|
|
99 gunzip2 ${galaxypath}/archive_${fname}/${fname}.gz
|
|
100 fi
|
|
101 fi
|
|
102 }
|
|
103
|
|
104 ##
|
|
105 ## Create HTML content for the tabs specified by user
|
|
106 ##
|
|
107 function makeTabContent ( ){
|
|
108 tab=$1 # name of current tab
|
|
109 itemslist=$2 # list of all items
|
|
110 tracklist=$3 # genome browser tracks info
|
|
111 contentline="" # HTML code for tab
|
|
112 imgcount=0 # keep track of the number of images on the current tab
|
4
|
113 iframename=`head -n 1 < /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1`
|
|
114 #iframename="test"
|
0
|
115 for item in $itemslist
|
|
116 do
|
|
117 ## Parse items lists
|
|
118 item=${item/::/:emptycol:}
|
|
119 declare -a myarr=(`echo $item |sed 's/:/ /g'`)
|
|
120
|
|
121 ## Create the tab contents HTML code
|
|
122 if [ ${myarr[0]} == $tab ]
|
|
123 then
|
|
124
|
|
125 ##
|
|
126 ## Text Field
|
|
127 ##
|
|
128 if [ ${myarr[1]} == "text" ]
|
|
129 then
|
|
130 text=${myarr[2]}
|
|
131 md=${myarr[4]}
|
|
132
|
|
133 # if markdown, convert to html
|
|
134 if [ $md == "Y" ]
|
|
135 then
|
|
136 ## resubstitute sanitized charachters
|
|
137 text=${text//==space==/ }
|
|
138 text=${text//==colon==/:}
|
|
139 text=${text//==comma==/,}
|
1
|
140
|
|
141 text=${text//==braceopen==/(}
|
|
142 text=${text//==braceclose==/)}
|
|
143 text=${text//==cbraceopen==/{}
|
|
144 text=${text//==cbraceclose==/}}
|
|
145
|
0
|
146 text=${text//==slash==/\/}
|
|
147 text=${text//==lt==/<}
|
|
148 text=${text//==gt==/>}
|
|
149 text=${text//==apos==/\'}
|
|
150 text=${text//==quote==/\"}
|
|
151 text=${text//==backtick==/\`}
|
|
152 text=${text//==dollar==/$}
|
|
153 text=${text//==bar==/|}
|
|
154 text=${text//&&/&}
|
|
155 text=${text//\\n/\\n}
|
|
156 text=${text//\\t/\\t}
|
|
157 text=${text//\&r\&n/\\n}
|
|
158 text=${text//\&r/\\n}
|
|
159 text=${text//\&n/\\n}
|
|
160 text=${text//\&c/:}
|
1
|
161
|
|
162
|
0
|
163 ## convert markdown in textfield to html
|
|
164 echo -e "$text" > mytext.md
|
|
165
|
|
166 if [ -z `type -p pandoc` ]
|
|
167 then
|
|
168 # pandoc missing
|
|
169 ${repositorypath}/Markdown/markdown2.py mytext.md > mytext.html
|
|
170
|
|
171 else
|
|
172 # pandoc exists
|
|
173 pandoc -f markdown -o mytext.html mytext.md
|
|
174 pandoc -f markdown -o standalone.html -s mytext.md
|
|
175
|
|
176 #get css generated by pandoc and add as scoped attribute (HTML5)
|
|
177 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html`
|
|
178 fi
|
|
179
|
|
180 markdowntext=$(cat mytext.html)
|
|
181 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n"
|
|
182
|
|
183 else # If not markdown, print verbatim (with exception of few html tags)
|
|
184
|
|
185 ## allow some html formatting tags
|
|
186 text=${text//==lt==strong==gt==/<strong>} # search for strong tags
|
|
187 text=${text//==lt====slash==strong==gt==/<\/strong>} # search for strong tags
|
|
188 text=${text//==lt==em==gt==/<em>} # search for strong tags
|
|
189 text=${text//==lt====slash==em==gt==/<\/em>} # search for strong tags
|
|
190
|
|
191 text=${text//==lt==b==gt==/<strong>} # search for strong tags
|
|
192 text=${text//==lt====slash==b==gt==/<\/strong>} # search for strong tags
|
|
193 text=${text//==lt==i==gt==/<em>} # search for strong tags
|
|
194 text=${text//==lt====slash==i==gt==/<\/em>} # search for strong tags
|
|
195
|
|
196 text=${text//==lt==br==gt==/<br\/>} # search for strong tags
|
|
197 text=${text//==lt====br==slash==gt==/<br\/>} # search for strong tags
|
|
198 text=${text//==lt==h1==gt==/<h1>} # search for h1-h6 tags
|
|
199 text=${text//==lt==h2==gt==/<h2>} # search for h1-h6 tags
|
|
200 text=${text//==lt==h3==gt==/<h3>} # search for h1-h6 tags
|
|
201 text=${text//==lt==h4==gt==/<h4>} # search for h1-h6 tags
|
|
202 text=${text//==lt==h5==gt==/<h5>} # search for h1-h6 tags
|
|
203 text=${text//==lt==h6==gt==/<h6>} # search for h1-h6 tags
|
|
204 text=${text//==lt====slash==h1==gt==/<\/h1>} # search for h1-h6 closing tags
|
|
205 text=${text//==lt====slash==h2==gt==/<\/h2>} # search for h1-h6 closing tags
|
|
206 text=${text//==lt====slash==h3==gt==/<\/h3>} # search for h1-h6 closing tags
|
|
207 text=${text//==lt====slash==h4==gt==/<\/h4>} # search for h1-h6 closing tags
|
|
208 text=${text//==lt====slash==h5==gt==/<\/h5>} # search for h1-h6 closing tags
|
|
209 text=${text//==lt====slaxh==h6==gt==/<\/h6>} # search for h1-h6 closing tags
|
|
210
|
|
211 ## display everything else verbatim
|
|
212 text=${text//==space==/ }
|
|
213 text=${text//==colon==/:}
|
|
214 text=${text//==comma==/,}
|
|
215 text=${text//==slash==/\/}
|
|
216 text=${text//==lt==/<}
|
|
217 text=${text//==gt==/>}
|
|
218 text=${text//==apos==/'}
|
|
219 text=${text//==quote==/"}
|
|
220 text=${text//&&/&}
|
|
221 text=${text//\\n/<br/>}
|
|
222 text=${text//\\t/ }
|
|
223 text=${text//\&r\&n/<br/>}
|
|
224 text=${text//\&r/<br/>}
|
|
225 text=${text//\&n/<br/>}
|
|
226 text=${text//\&c/:}
|
|
227 text=${text//==backtick==/`}
|
|
228 text=${text//==dollar==/$}
|
|
229 text=${text//==bar==/|}
|
1
|
230 text=${text//==braceopen==/(}
|
|
231 text=${text//==braceclose==/)}
|
|
232 text=${text//==cbraceopen==/{}
|
|
233 text=${text//==cbraceclose==/}}
|
0
|
234 contentline="${contentline}\n${text}\n"
|
|
235 fi
|
|
236
|
|
237
|
|
238 fi
|
|
239
|
|
240 ##
|
|
241 ## Text File
|
|
242 ##
|
|
243 if [ ${myarr[1]} == "textfile" ]
|
|
244 then
|
|
245 tfile=${myarr[2]}
|
|
246 md=${myarr[4]}
|
|
247 fname=`basename ${tfile}`
|
|
248 fname=${fname%.*}
|
|
249 fname="${fname}.txt"
|
|
250 cp ${tfile} "${galaxypath}/${fname}"
|
|
251
|
|
252 #estimate height for iframe based on number oflines in the file
|
|
253 numlines=`wc -l ${tfile} | cut -d" " -f1`
|
|
254 minheight=$[$numlines*17]
|
|
255
|
|
256 # if markdown, convert to html
|
|
257 if [ $md == "Y" ]
|
|
258 then
|
|
259
|
|
260 if [ -z `type -p pandoc` ]
|
|
261 then
|
|
262 # pandoc missing
|
|
263 ${repositorypath}/Markdown/markdown2.py ${tfile} > mytext.html
|
|
264
|
|
265 else
|
|
266 # pandoc exists
|
|
267 pandoc -o mytext.html ${tfile}
|
|
268 pandoc -o standalone.html -s ${tfile}
|
|
269
|
|
270 # get css generated by pandoc and add as scoped attribute (HTML5)
|
|
271 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html`
|
|
272
|
|
273 fi
|
|
274
|
|
275 markdowntext=$(cat mytext.html)
|
|
276 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n"
|
|
277 else
|
|
278 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${fname}\" width=\"100%\" height=\"$minheight\"> </iframe>\n"
|
|
279 fi
|
|
280 fi
|
|
281
|
|
282 ##
|
|
283 ## Image
|
|
284 ##
|
|
285 if [ ${myarr[1]} == "image" ]
|
|
286
|
|
287 then
|
|
288 imgcount=$[$imgcount+1]
|
|
289 #restore file suffix for html
|
|
290 ftype=`file ${myarr[2]}`
|
|
291 zoomlevel=${myarr[4]}
|
|
292 zoomenable=${myarr[5]}
|
|
293 align=${myarr[6]}
|
1
|
294 typestring=""
|
0
|
295 #####echo "zoomenable:${zoomenable}, align:${align}"
|
|
296 if [[ $ftype == *JPEG* ]]
|
|
297 then
|
|
298 suffix=".jpg"
|
|
299 fi
|
|
300 if [[ $ftype == *SVG* ]]
|
|
301 then
|
|
302 suffix=".svg"
|
|
303 fi
|
|
304 if [[ $ftype == *PNG* ]]
|
|
305 then
|
|
306 suffix=".png"
|
|
307 fi
|
1
|
308 if [[ $ftype == *TIFF* ]]
|
|
309 then
|
|
310 suffix=".tiff"
|
|
311 typestring="type=\"image/tiff\""
|
|
312 fi
|
0
|
313
|
|
314 image=`basename ${myarr[2]}`
|
|
315 image=${image%.dat}
|
|
316 image="${image}${suffix}"
|
|
317 cp ${myarr[2]} ${galaxypath}/${image}
|
|
318
|
|
319 if [[ ${align} == "none" ]]
|
|
320 then
|
|
321 alignstring=""
|
|
322 alignstring2=""
|
|
323 else
|
|
324 alignstring="<div float=\"${align}\">"
|
|
325 alignstring2="</div>"
|
|
326
|
|
327 alignstring="align=\"${align}\""
|
|
328 alignstring2=""
|
|
329 fi
|
|
330
|
|
331
|
|
332 if [[ ${zoomlevel} -eq 0 ]]
|
|
333 then
|
|
334 widthstring=""
|
|
335 else
|
|
336 widthstring="width=\"${zoomlevel}\""
|
|
337 fi
|
|
338
|
|
339 if [[ ${zoomlevel} -eq 0 || ${zoomenable} == "N" ]]
|
4
|
340 then
|
|
341 contentline="${contentline}<span id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>"
|
0
|
342 else
|
|
343 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>"
|
|
344 fi
|
|
345
|
|
346 fi
|
|
347
|
|
348 ##
|
|
349 ## Table
|
|
350 ##
|
|
351 if [ ${myarr[1]} == "table" ]
|
|
352 then
|
|
353
|
|
354 maxlines=50000
|
|
355 tsvfile_orig=${myarr[2]}
|
|
356 tsvfile="tablehead.tsv"
|
|
357 fname=`basename ${tsvfile_orig}`
|
|
358 fname=${fname%.*}
|
|
359 fancy=${myarr[4]}
|
|
360 makelinks=${myarr[5]}
|
4
|
361 #iframeid="iframe$giframecount"
|
|
362 iframeid="iframe-$iframename"
|
|
363
|
0
|
364 #echo "\nmakelinks: $makelinks fancy: $fancy <br>"
|
|
365
|
|
366 #TODO client side database for large files. For now only display first section of file and add download link
|
|
367 numlines=`wc -l ${tsvfile_orig} |cut -d" " -f1`
|
|
368
|
|
369 head -${maxlines} ${tsvfile_orig} > tsvtmpfile
|
|
370
|
|
371 #remove any empty or header lines (lines starting with #, unless vcf file, then keep #CHROM line)
|
|
372 awk 'BEGIN{
|
|
373 FS="\t"
|
|
374 OFS="\t"
|
|
375 }{
|
|
376 if((index($0,"#")==1 && index($0,"#CHROM")!=1) || $0==""){
|
|
377 headerlines++
|
|
378 }
|
|
379 else print $0
|
|
380
|
|
381 }END{}' tsvtmpfile > ${tsvfile}
|
|
382
|
|
383 if [[ $makelinks == "Y" ]]
|
|
384 then
|
|
385 col=${myarr[6]}
|
|
386 prefix=${myarr[7]}
|
|
387 suffix=${myarr[8]}
|
|
388 urlitems=${myarr[9]}
|
|
389 minw=${myarr[10]}
|
1
|
390 minh=${myarr[11]}
|
0
|
391 suffix=${suffix/emptycol/}
|
|
392 suffix=${suffix/==quote==/&}
|
|
393 prefix=${prefix/emptycol/}
|
|
394 prefix=${prefix/==quote==/&}
|
|
395 prefix=${prefix/==colon==/:}
|
|
396
|
|
397 # unpack archive of files to link to if present
|
|
398 if [[ ${urlitems} != None ]]
|
|
399 then
|
|
400 oldfname=$fname
|
|
401 decompressArchive ${urlitems}
|
|
402 prefix=archive_${fname}/${prefix}
|
|
403 fname=$oldfname
|
|
404 fi
|
|
405
|
|
406
|
|
407 #edit the table to include links
|
|
408 awk 'BEGIN{
|
|
409 FS="\t"
|
|
410 OFS="\t"
|
|
411 url="'"$prefix"'"
|
|
412 url2="'"$suffix"'"
|
|
413 iframeid="'"$iframeid"'"
|
|
414 prefix="<a href=\42"
|
|
415 suffix="\42 onclick=\42resizeIframe("iframeid")\42>"
|
|
416 col="'"$col"'"
|
|
417 end="</a>"
|
|
418 }{
|
|
419 if(FNR==1)
|
|
420 print $0
|
|
421 else{
|
|
422 $col=prefix""url""$col""url2""suffix""$col""end
|
|
423 print $0
|
|
424 }
|
|
425 }END{}' ${tsvfile} > ${tsvfile}2
|
|
426
|
|
427 else
|
|
428 minw=${myarr[6]}
|
1
|
429 minh=${myarr[7]}
|
0
|
430 cp ${tsvfile} ${tsvfile}2
|
|
431 fi
|
|
432
|
4
|
433 #iframecount=$[$iframecount+1]
|
|
434
|
0
|
435 if [ $fancy == "Y" ]
|
|
436 then
|
|
437 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
|
4
|
438 contentline="${contentline}\n<iframe class=\"invisibleframe fancyiframe\" id=\"$iframeid\" src=\"htmltable_${fname}.html\" width=\"100%\" style=\"height: 350px; min-height: ${minh}px !important; overflow-y: hidden; overflow-x: scroll\" onClick=resizeIframe(\"$iframeid\")></iframe>"
|
|
439
|
0
|
440 else
|
|
441 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
|
4
|
442 contentline="${contentline}\n<iframe class=\"unfancyiframe invisibleframe\" id=\"$iframeid\" src=\"htmltable_${fname}.html\" scrolling=\"no\" style=\"min-width: ${minw}px; min-height: ${minh}px !important; max-width: 100%; vertical-align: top;\" onClick=resizeIframe(\"$iframeid\") ></iframe>"
|
|
443
|
0
|
444 fi
|
|
445
|
|
446 if [[ $numlines -gt ${maxlines} ]]
|
|
447 then
|
|
448 tablename=`basename ${tsvfile_orig}`
|
|
449 cp ${tsvfile_orig} ${galaxypath}/$tablename
|
|
450 contentline="${contentline}<br/>\nLarge tables will be supported soon. The first ${maxlines} lines are shown here, and you can download the full file <a href=\"${tablename}\">here</a>."
|
|
451 fi
|
|
452 fi
|
|
453
|
|
454 ##
|
|
455 ## PDF
|
|
456 ##
|
|
457 if [[ ${myarr[1]} == "pdf" ]]
|
|
458 then
|
|
459 pdffile=${myarr[2]}
|
|
460 fname=`basename ${pdffile}`
|
|
461 fname=${fname%.dat}
|
|
462 pdfname="${fname}.pdf"
|
|
463 cp ${pdffile} "${galaxypath}/${pdfname}"
|
|
464
|
|
465 width=1000
|
|
466 height=800
|
|
467 echo -e "<html><body><object data=\"${pdfname}\" type=\"application/pdf\" width=\"$width\" height=\"$height\"><embed src=\"${pdfname}\" type=\"application/pdf\" /><p>It appears you have no PDF plugin for your browser. No biggie... you can <a href=\"${pdfname}\">click here to download the PDF file.</a></p></object></body></html>" > "${galaxypath}/${fname}.html"
|
|
468 width=$[$width+10]
|
|
469 height=$[$height+10]
|
|
470 contentline="${contentline}\n<iframe src=\"${fname}.html\" width=\"${width}\" height=\"${height}\"></iframe>\n"
|
|
471
|
|
472 fi
|
|
473
|
|
474 ##
|
|
475 ## HTML
|
|
476 ##
|
|
477 if [[ ${myarr[1]} == "htmlfile" ]]
|
|
478 then
|
|
479 htmlfile=${myarr[2]}
|
|
480 height=${myarr[4]}
|
|
481 fname=`basename ${htmlfile}`
|
|
482 fname=${fname%.dat}
|
|
483 htmlname="${fname}.html"
|
|
484 cp ${htmlfile} "${galaxypath}/${htmlname}"
|
|
485
|
1
|
486 apiid=${myarr[5]}
|
|
487 isireport=${myarr[6]}
|
|
488 localhost=${myarr[7]}
|
|
489 proxy=${myarr[8]}
|
|
490 localhost=${localhost//==colon==/:}
|
|
491 localhost=${localhost//==fslash==/\/}
|
|
492 if [[ ${isireport} == "Y" ]]
|
|
493 then
|
|
494 #cp ${localhost}/datasets/${apiid}/* "${galaxypath}/tst"
|
|
495 htmlname="/${proxy}/datasets/${apiid}/display/"
|
|
496 fi
|
|
497
|
|
498 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n"
|
0
|
499 fi
|
|
500
|
|
501
|
|
502 if [[ ${myarr[1]} == "htmlpage" ]]
|
|
503 then
|
|
504 url=${myarr[2]}
|
|
505 url=${url//==colon==/:}
|
|
506 url=${url//==fslash==//}
|
1
|
507 height=${myarr[4]}
|
0
|
508 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${url}\" width=\"100%\" height=\"${height}px\"></iframe>\n"
|
|
509 fi
|
|
510
|
|
511 ##
|
|
512 ## Web Link
|
|
513 ##
|
|
514 if [ ${myarr[1]} == "weblink" ]
|
|
515 then
|
|
516 url=${myarr[2]}
|
|
517 linktext=${myarr[4]}
|
1
|
518
|
|
519 echo -n "$url" > tmpfileb64
|
|
520 url=`base64 -d tmpfileb64`
|
0
|
521
|
1
|
522 echo -n "$linktext" > tmpfileb64
|
|
523 linktext=`base64 -d tmpfileb64`
|
|
524
|
|
525 if [[ -z $linktext ]]
|
|
526 then
|
|
527 linktext=$url
|
|
528 fi
|
0
|
529 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>"
|
|
530 fi
|
|
531
|
|
532
|
|
533 ##
|
|
534 ## Genome Browser
|
|
535 ##
|
|
536 if [ ${myarr[1]} == "genomebrowser" ]
|
|
537 then
|
1
|
538
|
0
|
539 # parse inputs
|
|
540
|
|
541 apiid=${myarr[4]}
|
|
542 servername=${myarr[5]}
|
|
543 buildver=${myarr[2]}
|
|
544
|
1
|
545
|
|
546 region=${myarr[6]}
|
|
547
|
|
548
|
|
549 echo -n "$region" > tmpfileb64
|
|
550 region=`base64 -d tmpfileb64`
|
|
551
|
|
552
|
|
553 initialchrom=${region%:*}
|
|
554 initialrange=${region#*:}
|
|
555
|
|
556 initialstart=${initialrange%-*}
|
|
557 initialend=${initialrange#*-}
|
|
558
|
|
559
|
0
|
560 #TODO
|
|
561 ftype="vcf"
|
|
562
|
|
563 servername=${servername/==colon==/:}
|
|
564
|
|
565 ## parse and prepare all tracks
|
|
566 gbcount=$[$gbcount+1]
|
|
567 gbfilelist=${tracklist}
|
|
568 userTracks=""
|
|
569 #IFS=',' read -a gbfilearray <<< ${gbfilelist}
|
|
570 gbfilearray=(${gbfilelist//,/ })
|
|
571 for gbfile in "${gbfilearray[@]}"
|
|
572 do
|
|
573 # gbfile is in format "browsernum:file"
|
|
574 #IFS=':' read -a gbfileinfo <<< ${gbfile}
|
|
575 gbfileinfo=(${gbfile//:/ })
|
|
576 if [[ ${gbfileinfo[0]} == $gbcount ]]
|
|
577 then
|
|
578
|
|
579 ftype=${gbfileinfo[3]}
|
1
|
580
|
|
581 gbfilename=${gbfileinfo[1]}
|
|
582 gbfilelabel=${gbfileinfo[2]}
|
|
583 gbfilelabel=${gbfilelabel//==space==/ }
|
|
584 gbfilelabel=${gbfilelabel//==bopen==/(}
|
|
585 gbfilelabel=${gbfilelabel//==bclose==/)}
|
|
586 fname=`basename ${gbfilename}`
|
|
587 fname=${fname%.dat}
|
|
588
|
|
589 if [[ $ftype == "vcftabix" ]]
|
0
|
590 then
|
|
591 newgbfilename="${fname}.vcf"
|
|
592
|
|
593
|
|
594 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
595 bgzip "${galaxypath}/${newgbfilename}"
|
1
|
596 tabix -f -p vcf "${galaxypath}/${newgbfilename}.gz"
|
0
|
597
|
|
598 userTracks="${userTracks},
|
|
599 {name: '${gbfilelabel}',
|
|
600 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}.gz',
|
|
601 tier_type: 'tabix',
|
|
602 payload: 'vcf'}
|
|
603 "
|
|
604 fi
|
|
605
|
1
|
606 if [[ $ftype == "vcfmemstore" ]]
|
0
|
607 then
|
1
|
608 newgbfilename="${fname}.vcf"
|
|
609
|
|
610
|
|
611 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
612 #bgzip "${galaxypath}/${newgbfilename}"
|
|
613 #tabix -p vcf "${galaxypath}/${newgbfilename}.gz"
|
|
614
|
|
615 userTracks="${userTracks},
|
|
616 {name: '${gbfilelabel}',
|
|
617 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}',
|
|
618 tier_type: 'memstore',
|
|
619 payload: 'vcf'}
|
|
620 "
|
|
621 fi
|
|
622
|
|
623 if [[ $ftype == "bam" ]]
|
|
624 then
|
0
|
625 newgbfilename="${fname}.bam"
|
|
626
|
|
627 # link to bam instead of copying
|
|
628 ln -s ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
629 samtools index "${galaxypath}/${newgbfilename}"
|
|
630
|
|
631 userTracks="${userTracks},
|
|
632 {name: '${gbfilelabel}',
|
|
633 bamURI: '${servername}/datasets/${apiid}/display/${newgbfilename}'}
|
|
634 "
|
|
635
|
|
636 fi
|
1
|
637
|
4
|
638 if [[ $ftype == "bigbed" ]]
|
|
639 then
|
|
640 newgbfilename="${fname}.bigbed"
|
|
641
|
|
642 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
643 #bgzip "${galaxypath}/${newgbfilename}"
|
|
644 #tabix -f -p bed "${galaxypath}/${newgbfilename}.gz"
|
|
645
|
|
646 userTracks="${userTracks},
|
|
647 {name: '${gbfilelabel}',
|
|
648 bwgURI: '${servername}/datasets/${apiid}/display/${newgbfilename}'}
|
|
649 "
|
|
650
|
|
651 fi
|
|
652
|
1
|
653 if [[ $ftype == "bedtabix" ]]
|
|
654 then
|
|
655 newgbfilename="${fname}.bed"
|
|
656
|
|
657 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
658 bgzip "${galaxypath}/${newgbfilename}"
|
|
659 tabix -f -p bed "${galaxypath}/${newgbfilename}.gz"
|
|
660
|
|
661 userTracks="${userTracks},
|
|
662 {name: '${gbfilelabel}',
|
|
663 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}.gz',
|
|
664 tier_type: 'tabix',
|
|
665 payload: 'bed'}
|
|
666 "
|
|
667
|
|
668 fi
|
|
669
|
|
670 if [[ $ftype == "bedmemstore" ]]
|
|
671 then
|
|
672 newgbfilename="${fname}.bed"
|
|
673
|
|
674 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
|
|
675 #bgzip "${galaxypath}/${newgbfilename}"
|
|
676 #tabix -p bed "${galaxypath}/${newgbfilename}.gz"
|
|
677
|
|
678 userTracks="${userTracks},
|
|
679 {name: '${gbfilelabel}',
|
|
680 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}',
|
|
681 tier_type: 'memstore',
|
|
682 payload: 'bed'}
|
|
683 "
|
|
684
|
|
685 fi
|
0
|
686 fi
|
|
687 done
|
|
688
|
|
689
|
|
690
|
|
691 if [ ${buildver} == "hg18" ]
|
|
692 then
|
|
693 coordSystem="coordSystem: {
|
|
694 speciesName: 'Human',
|
|
695 taxon: 9606,
|
|
696 auth: 'NCBI',
|
|
697 version: '36',
|
|
698 ucscName: 'hg18'
|
|
699 },"
|
|
700
|
|
701 chains="chains: {
|
|
702 hg19ToHg18: new Chainset('https://www.biodalliance.org/das/hg19ToHg18/', 'GRCh37', 'NCBI36',
|
|
703 {
|
|
704 speciesName: 'Human',
|
|
705 taxon: 9606,
|
|
706 auth: 'GRCh',
|
|
707 version: 37
|
|
708 })
|
|
709 },"
|
|
710
|
|
711 genesTrack="{name: 'Genes',
|
|
712 desc: 'Gene structures from Ensembl 54',
|
|
713 uri: 'https://www.biodalliance.org/das/hsa_54_36p/',
|
|
714 collapseSuperGroups: true,
|
|
715 provides_karyotype: true,
|
|
716 provides_search: true,
|
|
717 provides_entrypoints: true,
|
|
718 maxbins: false}, "
|
|
719
|
|
720 repeatsTrack="{name: 'Repeats',
|
|
721 desc: 'Repeat annotation from Ensembl 59',
|
|
722 bwgURI: 'https://www.biodalliance.org/datasets/repeats.bb',
|
|
723 stylesheet_uri: 'https://www.biodalliance.org/stylesheets/bb-repeats.xml'}"
|
|
724
|
|
725
|
|
726 # default is hg19
|
|
727 else
|
|
728 coordSystem="coordSystem: {
|
|
729 speciesName: 'Human',
|
|
730 taxon: 9606,
|
|
731 auth: 'NCBI',
|
|
732 version: '37',
|
|
733 ucscName: 'hg19'
|
|
734 },"
|
|
735
|
|
736 chains=""
|
|
737
|
|
738 genesTrack="{name: 'Genes',
|
|
739 desc: 'Gene structures from GENCODE 19',
|
|
740 bwgURI: 'https://www.biodalliance.org/datasets/gencode.bb',
|
|
741 stylesheet_uri: 'https://www.biodalliance.org/stylesheets/gencode.xml',
|
|
742 collapseSuperGroups: true,
|
|
743 trixURI: 'https://www.biodalliance.org/datasets/geneIndex.ix'},"
|
|
744
|
|
745 repeatsTrack="{name: 'Repeats',
|
|
746 desc: 'Repeat annotation from Ensembl 59',
|
|
747 bwgURI: 'https://www.biodalliance.org/datasets/repeats.bb',
|
|
748 stylesheet_uri: 'https://www.biodalliance.org/stylesheets/bb-repeats.xml'},"
|
|
749
|
|
750 fi
|
|
751
|
|
752 contentline="${contentline}
|
|
753 <script language=\"javascript\" src=\"https://www.biodalliance.org/release-0.13/dalliance-compiled.js\"></script>
|
|
754 <script language=\"javascript\">
|
|
755 new Browser({
|
1
|
756 chr: '$initialchrom',
|
|
757 viewStart: $initialstart,
|
|
758 viewEnd: $initialend,
|
0
|
759 cookieKey: 'human',
|
1
|
760 pageName: 'svgHolder${gbcount}',
|
0
|
761 ${coordSystem}
|
|
762
|
|
763 ${chains}
|
|
764 sources: [{name: 'Genome',
|
|
765 twoBitURI: 'https://www.biodalliance.org/datasets/${buildver}.2bit',
|
|
766 tier_type: 'sequence'},
|
|
767 ${genesTrack},
|
|
768 ${repeatsTrack},
|
|
769 {name: 'Conservation',
|
|
770 desc: 'Conservation',
|
|
771 bwgURI: 'https://www.biodalliance.org/datasets/phastCons46way.bw',
|
|
772 noDownsample: true}
|
|
773 ${userTracks}
|
|
774 ],
|
|
775
|
|
776
|
|
777
|
|
778
|
|
779 browserLinks: {
|
|
780 Ensembl: 'http://www.ensembl.org/Homo_sapiens/Location/View?r=${chr}:${start}-${end}',
|
|
781 UCSC: 'http://genome.ucsc.edu/cgi-bin/hgTracks?db=${buildver}&position=chr${chr}:${start}-${end}',
|
|
782 Sequence: 'http://www.derkholm.net:8080/das/${buildver}comp/sequence?segment=${chr}:${start},${end}'
|
|
783 }
|
|
784
|
|
785 });
|
|
786 </script>
|
|
787
|
1
|
788 <div id=\"svgHolder${gbcount}\"></div>
|
0
|
789 "
|
|
790 fi
|
|
791
|
|
792 ##
|
|
793 ## Link to Dataset
|
|
794 ##
|
|
795 if [ ${myarr[1]} == "link" ]
|
|
796 then
|
|
797 linkfile=${myarr[2]}
|
|
798 apiid=${myarr[4]}
|
|
799 isireport=${myarr[5]}
|
|
800 linkfilename=`basename ${linkfile}`
|
|
801 linktext=${myarr[6]}
|
|
802
|
1
|
803 localhost=${myarr[7]}
|
|
804 proxy=${myarr[8]}
|
|
805 localhost=${localhost//==colon==/:}
|
|
806 localhost=${localhost//==fslash==/\/}
|
0
|
807
|
|
808 #check for some basic filetypes
|
|
809 ftype=`file $linkfile`
|
|
810 if [[ $ftype == *HTML* ]]
|
|
811 then
|
|
812 linkfilename=${linkfilename%.dat}
|
|
813 linkfilename=${linkfilename}.html
|
|
814 fi
|
|
815 if [[ $ftype == *PNG* ]]
|
|
816 then
|
|
817 linkfilename=${linkfilename%.dat}
|
|
818 linkfilename=${linkfilename}.png
|
|
819 fi
|
|
820 if [[ $ftype == *SVG* ]]
|
|
821 then
|
|
822 linkfilename=${linkfilename%.dat}
|
|
823 linkfilename=${linkfilename}.svg
|
|
824 fi
|
|
825 if [[ $ftype == *JPEG* ]]
|
|
826 then
|
|
827 linkfilename=${linkfilename%.dat}
|
|
828 linkfilename=${linkfilename}.jpg
|
|
829 fi
|
|
830
|
|
831
|
|
832 if [[ ${isireport} == "Y" ]]
|
|
833 then
|
1
|
834 linkfilename="/${proxy}/datasets/${apiid}/display/"
|
0
|
835 else
|
|
836 cp ${linkfile} "${galaxypath}/${linkfilename}"
|
|
837 fi
|
|
838
|
|
839 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>"
|
|
840 fi
|
|
841
|
|
842 ##
|
|
843 ## Links to Archive Contents
|
|
844 ##
|
|
845 if [[ ${myarr[1]} == "links" ]]
|
|
846 then
|
|
847 archive=${myarr[2]}
|
|
848 decompressArchive $archive
|
|
849
|
|
850 # add links to webpage
|
|
851 # separate line for each folder, files within folder on same line
|
|
852 for linkfile in `ls ${galaxypath}/archive_${fname}/ |sort -V`
|
|
853 do
|
|
854 #echo "<br/> ->making link to file: $linkfile "
|
|
855 if [ -d ${galaxypath}/archive_${fname}/$linkfile ] # if directory, add break, and list all contained files, max level 1 deep
|
|
856 then
|
|
857 #echo "<br/> ->is directory, entering: $linkfile "
|
|
858 #ls ${galaxypath}/archive_${fname}/$linkfile
|
|
859 contentline="${contentline}"
|
|
860 for linkfile2 in `ls ${galaxypath}/archive_${fname}/$linkfile | sort -V`
|
|
861 do
|
|
862 #echo "<br/> ->making link to file: ${galaxypath}/archive_${fname}/$linkfile2"
|
|
863 if [ -f ${galaxypath}/archive_${fname}/$linkfile/$linkfile2 ] # if directory, add break, and list all contained files, max level 1 deep
|
|
864 then
|
|
865 #echo "<br/> ->is file, making link: $linkfile "
|
|
866 label=`basename $linkfile2`
|
|
867 label=${label%.*}
|
|
868 contentline="${contentline}<a class=\"mylinks\" href=\"archive_${fname}/${linkfile}/${linkfile2}\">${label}</a> \n "
|
|
869 fi
|
|
870 done
|
|
871 elif [ -f ${galaxypath}/archive_${fname}/$linkfile ]
|
|
872 then
|
|
873 label=`basename ${galaxypath}/archive_${fname}/$linkfile`
|
|
874 label=${label%.*}
|
|
875 contentline="${contentline}<a class=\"mylinks\" href=\"archive_${fname}/${linkfile}\">$label</a> \n"
|
|
876 fi
|
|
877 done
|
|
878
|
|
879
|
|
880 fi
|
|
881
|
|
882 if [[ ${myarr[3]} == "Y" ]]
|
|
883 then
|
|
884 contentline="${contentline}<br/>\n"
|
|
885 fi
|
|
886 fi
|
|
887 done
|
|
888
|
|
889 echo "${contentline}"
|
4
|
890
|
|
891
|
0
|
892 }
|
|
893
|
|
894 ##
|
|
895 ## Create HTML content for iReport
|
|
896 ##
|
|
897 createMainPage (){
|
4
|
898 #export IFRAMECNT=1
|
0
|
899 page=$1
|
|
900 tabtitles=$2 # comma-separated list of tab titles
|
|
901 tabitems=$3 # colon-sparated list of tabs specifications
|
4
|
902 #giframecount=1 # keep track of number of iFrames so that they can be referenced by ID
|
0
|
903 minwidth=$4 # width of page
|
|
904 gbtracks=$5 # genome browser track information
|
|
905
|
|
906 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles. gbtracks: $gbtracks"
|
|
907 # create correct number of tabs
|
|
908 count=0
|
|
909
|
1
|
910 tabtitles=${tabtitles/,/}
|
0
|
911 tabtitles=${tabtitles//,/ }
|
1
|
912 echo $tabtitles
|
|
913
|
|
914 tabcount=0
|
|
915 for tabt in $tabtitles
|
|
916 do
|
|
917 echo -n $tabt > tmpfileb64
|
|
918 thistabtitle=`base64 -d tmpfileb64`
|
|
919 newtabtitles+=" $thistabtitle"
|
|
920 tabcount=$[tabcount+1]
|
|
921 done
|
|
922
|
|
923 echo $newtabtitles
|
|
924
|
0
|
925 tabslist="<ul>\n"
|
|
926 mytabs=""
|
|
927
|
1
|
928 for title in $newtabtitles
|
0
|
929 do
|
|
930 # Create list of tabs
|
|
931 count=$[count+1]
|
1
|
932 title2=${title//==space==/ }
|
|
933 title2=${title2//==dollar==/$}
|
|
934 title2=${title2//==colon==/}
|
0
|
935 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n"
|
|
936
|
|
937 # Create tabs with content
|
|
938 tabcontent=$(makeTabContent $title "$tabitems" "$gbtracks")
|
|
939 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n"
|
|
940 mytabs="${mytabs}${tabcontent}"
|
|
941 mytabs="${mytabs}\n</div>\n"
|
|
942 done
|
|
943 tabslist="${tabslist}</ul>"
|
|
944
|
|
945 ## Output the webpage
|
|
946 echo -e "<!doctype html>
|
|
947 <head>
|
|
948 <meta charset=\"utf-8\">
|
|
949 <title>iReport</title>
|
|
950 <link rel=\"stylesheet\" href=\"jquery-ui.css\">
|
|
951 <link rel=\"stylesheet\" href=\"ireport_css.css\">
|
|
952 <link rel=\"stylesheet\" href=\"md.css\">
|
|
953 <script type=\"text/javascript\" src=\"jquery-1.10.2.js\"></script>
|
|
954 <script type=\"text/javascript\" src=\"jquery-ui.js\"></script>
|
|
955 <script type=\"text/javascript\" src=\"iframe-resizer/src/iframeResizer.js\"></script>
|
|
956 <script type=\"text/javascript\" src=\"jquery.zoom.js\"></script>
|
|
957 <script type=\"text/javascript\" src=\"ireport_jquery.js\"></script>
|
|
958 <script type=\"text/javascript\" src=\"ireport_javascript.js\"></script>
|
|
959 </head>
|
|
960 <body>
|
|
961 <div id=\"tabs\" style=\"display:inline-block; min-height:100%; min-width:${minwidth}px\">
|
|
962 $tabslist
|
|
963
|
|
964 $mytabs
|
|
965 </div>
|
|
966 </body>
|
|
967 </html>" > $page
|
|
968 }
|