Mercurial > repos > saskia-hiltemann > ireport
comparison createHTML.sh @ 6:42076db43d42 draft
Fixed auto resizing plus various other minor bugs
author | saskia-hiltemann |
---|---|
date | Mon, 16 Nov 2015 08:56:22 -0500 |
parents | a4813532bbc6 |
children |
comparison
equal
deleted
inserted
replaced
5:4e21ce709269 | 6:42076db43d42 |
---|---|
1 gbcount=0 | |
2 | |
1 ## | 3 ## |
2 ## Create Cover Page | 4 ## Create Cover Page |
3 ## | 5 ## |
6 #<a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/> | |
4 function makeIntroPage ( ){ | 7 function makeIntroPage ( ){ |
5 echo "Creating Intro Page" | 8 echo "Creating Intro Page" |
6 title="$1" | 9 title="$1" |
7 coverimage=$2 | 10 coverimage=$2 |
8 link=$3 | 11 link=$3 |
18 <br/> | 21 <br/> |
19 <center> | 22 <center> |
20 <b><font size=\"15\"> iReport: ${title} </font></b><br/> | 23 <b><font size=\"15\"> iReport: ${title} </font></b><br/> |
21 <br/> | 24 <br/> |
22 <br/> | 25 <br/> |
23 <a href=\"$link\"> Click here to view report </a> <br/><br/> | 26 <a href=\"$link\"> Click image to view report </a> <br/><br/> |
24 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/> | 27 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/> |
25 <a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/> | |
26 </center> | 28 </center> |
27 </body> | 29 </body> |
28 </html>" > $htmlout | 30 </html>" > $htmlout |
29 | 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 | |
30 } | 102 } |
31 | 103 |
32 ## | 104 ## |
33 ## Create HTML content for the tabs specified by user | 105 ## Create HTML content for the tabs specified by user |
34 ## | 106 ## |
35 function makeTabContent ( ){ | 107 function makeTabContent ( ){ |
36 tab=$1 # name of current tab | 108 tab=$1 # name of current tab |
37 itemslist=$2 # list of all items | 109 itemslist=$2 # list of all items |
110 tracklist=$3 # genome browser tracks info | |
38 contentline="" # HTML code for tab | 111 contentline="" # HTML code for tab |
39 imgcount=0 # keep track of the number of images on the current tab | 112 imgcount=0 # keep track of the number of images on the current tab |
40 | 113 iframename=`head -n 1 < /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1` |
114 #iframename="test" | |
41 for item in $itemslist | 115 for item in $itemslist |
42 do | 116 do |
43 ## Parse items lists | 117 ## Parse items lists |
44 item=${item/::/:emptycol:} | 118 item=${item/::/:emptycol:} |
45 declare -a myarr=(`echo $item |sed 's/:/ /g'`) | 119 declare -a myarr=(`echo $item |sed 's/:/ /g'`) |
61 then | 135 then |
62 ## resubstitute sanitized charachters | 136 ## resubstitute sanitized charachters |
63 text=${text//==space==/ } | 137 text=${text//==space==/ } |
64 text=${text//==colon==/:} | 138 text=${text//==colon==/:} |
65 text=${text//==comma==/,} | 139 text=${text//==comma==/,} |
140 | |
141 text=${text//==braceopen==/(} | |
142 text=${text//==braceclose==/)} | |
143 text=${text//==cbraceopen==/{} | |
144 text=${text//==cbraceclose==/}} | |
145 | |
66 text=${text//==slash==/\/} | 146 text=${text//==slash==/\/} |
67 text=${text//==lt==/<} | 147 text=${text//==lt==/<} |
68 text=${text//==gt==/>} | 148 text=${text//==gt==/>} |
69 text=${text//==apos==/\'} | 149 text=${text//==apos==/\'} |
70 text=${text//==quote==/\"} | 150 text=${text//==quote==/\"} |
76 text=${text//\\t/\\t} | 156 text=${text//\\t/\\t} |
77 text=${text//\&r\&n/\\n} | 157 text=${text//\&r\&n/\\n} |
78 text=${text//\&r/\\n} | 158 text=${text//\&r/\\n} |
79 text=${text//\&n/\\n} | 159 text=${text//\&n/\\n} |
80 text=${text//\&c/:} | 160 text=${text//\&c/:} |
81 | 161 |
82 | 162 |
83 ## convert markdown in textfield to html | 163 ## convert markdown in textfield to html |
84 echo -e "$text" > mytext.md | 164 echo -e "$text" > mytext.md |
85 | 165 |
86 if [ -z `type -p pandoc` ] | 166 if [ -z `type -p pandoc` ] |
87 then | 167 then |
88 # pandoc missing | 168 # pandoc missing |
89 ${repositorypath}/Markdown/markdown2.py mytext.md > mytext.html | 169 ${repositorypath}/Markdown/markdown2.py mytext.md > mytext.html |
90 | 170 |
91 else | 171 else |
92 # pandoc exists | 172 # pandoc exists |
93 echo "pandoc exists" | 173 pandoc -f markdown -o mytext.html mytext.md |
94 pandoc -o mytext.html mytext.md | 174 pandoc -f markdown -o standalone.html -s mytext.md |
95 pandoc -o standalone.html -s mytext.md | |
96 | 175 |
97 #get css generated by pandoc and add as scoped attribute (HTML5) | 176 #get css generated by pandoc and add as scoped attribute (HTML5) |
98 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html` | 177 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html` |
99 fi | 178 fi |
100 | 179 |
146 text=${text//\&n/<br/>} | 225 text=${text//\&n/<br/>} |
147 text=${text//\&c/:} | 226 text=${text//\&c/:} |
148 text=${text//==backtick==/`} | 227 text=${text//==backtick==/`} |
149 text=${text//==dollar==/$} | 228 text=${text//==dollar==/$} |
150 text=${text//==bar==/|} | 229 text=${text//==bar==/|} |
230 text=${text//==braceopen==/(} | |
231 text=${text//==braceclose==/)} | |
232 text=${text//==cbraceopen==/{} | |
233 text=${text//==cbraceclose==/}} | |
151 contentline="${contentline}\n${text}\n" | 234 contentline="${contentline}\n${text}\n" |
152 fi | 235 fi |
153 | 236 |
154 | 237 |
155 fi | 238 fi |
206 #restore file suffix for html | 289 #restore file suffix for html |
207 ftype=`file ${myarr[2]}` | 290 ftype=`file ${myarr[2]}` |
208 zoomlevel=${myarr[4]} | 291 zoomlevel=${myarr[4]} |
209 zoomenable=${myarr[5]} | 292 zoomenable=${myarr[5]} |
210 align=${myarr[6]} | 293 align=${myarr[6]} |
294 typestring="" | |
211 #####echo "zoomenable:${zoomenable}, align:${align}" | 295 #####echo "zoomenable:${zoomenable}, align:${align}" |
212 if [[ $ftype == *JPEG* ]] | 296 if [[ $ftype == *JPEG* ]] |
213 then | 297 then |
214 suffix=".jpg" | 298 suffix=".jpg" |
215 fi | 299 fi |
218 suffix=".svg" | 302 suffix=".svg" |
219 fi | 303 fi |
220 if [[ $ftype == *PNG* ]] | 304 if [[ $ftype == *PNG* ]] |
221 then | 305 then |
222 suffix=".png" | 306 suffix=".png" |
307 fi | |
308 if [[ $ftype == *TIFF* ]] | |
309 then | |
310 suffix=".tiff" | |
311 typestring="type=\"image/tiff\"" | |
223 fi | 312 fi |
224 | 313 |
225 image=`basename ${myarr[2]}` | 314 image=`basename ${myarr[2]}` |
226 image=${image%.dat} | 315 image=${image%.dat} |
227 image="${image}${suffix}" | 316 image="${image}${suffix}" |
246 else | 335 else |
247 widthstring="width=\"${zoomlevel}\"" | 336 widthstring="width=\"${zoomlevel}\"" |
248 fi | 337 fi |
249 | 338 |
250 if [[ ${zoomlevel} -eq 0 || ${zoomenable} == "N" ]] | 339 if [[ ${zoomlevel} -eq 0 || ${zoomenable} == "N" ]] |
251 then | 340 then |
252 contentline="${contentline}<span id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" | 341 contentline="${contentline}<span id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" |
253 else | 342 else |
254 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" | 343 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" |
255 fi | 344 fi |
256 | 345 |
257 fi | 346 fi |
259 ## | 348 ## |
260 ## Table | 349 ## Table |
261 ## | 350 ## |
262 if [ ${myarr[1]} == "table" ] | 351 if [ ${myarr[1]} == "table" ] |
263 then | 352 then |
353 | |
264 maxlines=50000 | 354 maxlines=50000 |
265 tsvfile_orig=${myarr[2]} | 355 tsvfile_orig=${myarr[2]} |
266 tsvfile="tablehead.tsv" | 356 tsvfile="tablehead.tsv" |
267 fname=`basename ${tsvfile_orig}` | 357 fname=`basename ${tsvfile_orig}` |
268 fname=${fname%.*} | 358 fname=${fname%.*} |
269 fancy=${myarr[4]} | 359 fancy=${myarr[4]} |
270 makelinks=${myarr[5]} | 360 makelinks=${myarr[5]} |
361 #iframeid="iframe$giframecount" | |
362 iframeid="iframe-$iframename" | |
363 | |
271 #echo "\nmakelinks: $makelinks fancy: $fancy <br>" | 364 #echo "\nmakelinks: $makelinks fancy: $fancy <br>" |
272 | 365 |
273 #TODO client side database for large files. For now only display first section of file and add download link | 366 #TODO client side database for large files. For now only display first section of file and add download link |
274 numlines=`wc -l ${tsvfile_orig} |cut -d" " -f1` | 367 numlines=`wc -l ${tsvfile_orig} |cut -d" " -f1` |
275 | 368 |
289 | 382 |
290 if [[ $makelinks == "Y" ]] | 383 if [[ $makelinks == "Y" ]] |
291 then | 384 then |
292 col=${myarr[6]} | 385 col=${myarr[6]} |
293 prefix=${myarr[7]} | 386 prefix=${myarr[7]} |
294 suffix=${myarr[8]} | 387 suffix=${myarr[8]} |
388 urlitems=${myarr[9]} | |
389 minw=${myarr[10]} | |
390 minh=${myarr[11]} | |
295 suffix=${suffix/emptycol/} | 391 suffix=${suffix/emptycol/} |
296 suffix=${suffix/==quote==/&} | 392 suffix=${suffix/==quote==/&} |
297 prefix=${prefix/emptycol/} | 393 prefix=${prefix/emptycol/} |
298 prefix=${prefix/==quote==/&} | 394 prefix=${prefix/==quote==/&} |
299 prefix=${prefix/==colon==/:} | 395 prefix=${prefix/==colon==/:} |
300 #echo "prefix: $prefix" | 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 | |
301 | 406 |
302 #edit the table to include links | 407 #edit the table to include links |
303 awk 'BEGIN{ | 408 awk 'BEGIN{ |
304 FS="\t" | 409 FS="\t" |
305 OFS="\t" | 410 OFS="\t" |
306 url="'"$prefix"'" | 411 url="'"$prefix"'" |
307 url2="'"$suffix"'" | 412 url2="'"$suffix"'" |
413 iframeid="'"$iframeid"'" | |
308 prefix="<a href=\42" | 414 prefix="<a href=\42" |
309 suffix="\42>" | 415 suffix="\42 onclick=\42resizeIframe("iframeid")\42>" |
310 col="'"$col"'" | 416 col="'"$col"'" |
311 end="</a>" | 417 end="</a>" |
312 }{ | 418 }{ |
313 if(FNR==1) | 419 if(FNR==1) |
314 print $0 | 420 print $0 |
315 else{ | 421 else{ |
316 $col=prefix""url""$col""url2""suffix""$col""end | 422 $col=prefix""url""$col""url2""suffix""$col""end |
317 print $0 | 423 print $0 |
318 } | 424 } |
319 }END{}' ${tsvfile} > ${tsvfile}2 | 425 }END{}' ${tsvfile} > ${tsvfile}2 |
320 | 426 |
321 else | 427 else |
428 minw=${myarr[6]} | |
429 minh=${myarr[7]} | |
322 cp ${tsvfile} ${tsvfile}2 | 430 cp ${tsvfile} ${tsvfile}2 |
323 fi | 431 fi |
324 | 432 |
433 #iframecount=$[$iframecount+1] | |
434 | |
325 if [ $fancy == "Y" ] | 435 if [ $fancy == "Y" ] |
326 then | 436 then |
327 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html | 437 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html |
328 contentline="${contentline}\n<iframe class=\"invisibleframe fancyiframe\" src=\"htmltable_${fname}.html\" width=\"100%\" style=\"min-height: 525px; overflow-y: hidden; overflow-x: scroll\" ></iframe>" | 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>" |
329 iframecount=$[$iframecount+1] | 439 |
330 else | 440 else |
331 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html | 441 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html |
332 contentline="${contentline}\n<iframe class=\"unfancyiframe invisibleframe\" src=\"htmltable_${fname}.html\" scrolling=\"no\" style=\"max-width: 100%; vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe>" | 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>" |
333 iframecount=$[$iframecount+1] | 443 |
334 fi | 444 fi |
335 | 445 |
336 if [[ $numlines -gt ${maxlines} ]] | 446 if [[ $numlines -gt ${maxlines} ]] |
337 then | 447 then |
338 tablename=`basename ${tsvfile_orig}` | 448 tablename=`basename ${tsvfile_orig}` |
371 fname=`basename ${htmlfile}` | 481 fname=`basename ${htmlfile}` |
372 fname=${fname%.dat} | 482 fname=${fname%.dat} |
373 htmlname="${fname}.html" | 483 htmlname="${fname}.html" |
374 cp ${htmlfile} "${galaxypath}/${htmlname}" | 484 cp ${htmlfile} "${galaxypath}/${htmlname}" |
375 | 485 |
376 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n" | 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" | |
499 fi | |
500 | |
501 | |
502 if [[ ${myarr[1]} == "htmlpage" ]] | |
503 then | |
504 url=${myarr[2]} | |
505 url=${url//==colon==/:} | |
506 url=${url//==fslash==//} | |
507 height=${myarr[4]} | |
508 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${url}\" width=\"100%\" height=\"${height}px\"></iframe>\n" | |
377 fi | 509 fi |
378 | 510 |
379 ## | 511 ## |
380 ## Web Link | 512 ## Web Link |
381 ## | 513 ## |
382 if [ ${myarr[1]} == "weblink" ] | 514 if [ ${myarr[1]} == "weblink" ] |
383 then | 515 then |
384 url=${myarr[2]} | 516 url=${myarr[2]} |
385 linktext=${myarr[4]} | 517 linktext=${myarr[4]} |
386 url=${url/==colon==/:} | 518 |
387 url=${url/==quote==/&} | 519 echo -n "$url" > tmpfileb64 |
388 | 520 url=`base64 -d tmpfileb64` |
521 | |
522 echo -n "$linktext" > tmpfileb64 | |
523 linktext=`base64 -d tmpfileb64` | |
524 | |
525 if [[ -z $linktext ]] | |
526 then | |
527 linktext=$url | |
528 fi | |
389 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>" | 529 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>" |
390 fi | 530 fi |
391 | 531 |
532 | |
533 ## | |
534 ## Genome Browser | |
535 ## | |
536 if [ ${myarr[1]} == "genomebrowser" ] | |
537 then | |
538 | |
539 # parse inputs | |
540 | |
541 apiid=${myarr[4]} | |
542 servername=${myarr[5]} | |
543 buildver=${myarr[2]} | |
544 | |
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 | |
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]} | |
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" ]] | |
590 then | |
591 newgbfilename="${fname}.vcf" | |
592 | |
593 | |
594 cp ${gbfilename} "${galaxypath}/${newgbfilename}" | |
595 bgzip "${galaxypath}/${newgbfilename}" | |
596 tabix -f -p vcf "${galaxypath}/${newgbfilename}.gz" | |
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 | |
606 if [[ $ftype == "vcfmemstore" ]] | |
607 then | |
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 | |
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 | |
637 | |
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 | |
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 | |
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({ | |
756 chr: '$initialchrom', | |
757 viewStart: $initialstart, | |
758 viewEnd: $initialend, | |
759 cookieKey: 'human', | |
760 pageName: 'svgHolder${gbcount}', | |
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 | |
788 <div id=\"svgHolder${gbcount}\"></div> | |
789 " | |
790 fi | |
791 | |
392 ## | 792 ## |
393 ## Link to Dataset | 793 ## Link to Dataset |
394 ## | 794 ## |
395 if [ ${myarr[1]} == "link" ] | 795 if [ ${myarr[1]} == "link" ] |
396 then | 796 then |
398 apiid=${myarr[4]} | 798 apiid=${myarr[4]} |
399 isireport=${myarr[5]} | 799 isireport=${myarr[5]} |
400 linkfilename=`basename ${linkfile}` | 800 linkfilename=`basename ${linkfile}` |
401 linktext=${myarr[6]} | 801 linktext=${myarr[6]} |
402 | 802 |
803 localhost=${myarr[7]} | |
804 proxy=${myarr[8]} | |
805 localhost=${localhost//==colon==/:} | |
806 localhost=${localhost//==fslash==/\/} | |
403 | 807 |
404 #check for some basic filetypes | 808 #check for some basic filetypes |
405 ftype=`file $linkfile` | 809 ftype=`file $linkfile` |
406 if [[ $ftype == *HTML* ]] | 810 if [[ $ftype == *HTML* ]] |
407 then | 811 then |
425 fi | 829 fi |
426 | 830 |
427 | 831 |
428 if [[ ${isireport} == "Y" ]] | 832 if [[ ${isireport} == "Y" ]] |
429 then | 833 then |
430 linkfilename="/datasets/${apiid}/display/" | 834 linkfilename="/${proxy}/datasets/${apiid}/display/" |
431 else | 835 else |
432 cp ${linkfile} "${galaxypath}/${linkfilename}" | 836 cp ${linkfile} "${galaxypath}/${linkfilename}" |
433 fi | 837 fi |
434 | 838 |
435 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>" | 839 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>" |
437 | 841 |
438 ## | 842 ## |
439 ## Links to Archive Contents | 843 ## Links to Archive Contents |
440 ## | 844 ## |
441 if [[ ${myarr[1]} == "links" ]] | 845 if [[ ${myarr[1]} == "links" ]] |
442 then | 846 then |
443 #echo "making links:" | |
444 archive=${myarr[2]} | 847 archive=${myarr[2]} |
445 fname=`basename ${archive}` | 848 decompressArchive $archive |
446 fname=${fname%.dat} | 849 |
447 ftype=`file $archive` | |
448 mkdir ${galaxypath}/archive_${fname}/ | |
449 | |
450 #echo "archive type: `file $archive`" | |
451 # decompress archive | |
452 if [[ $ftype == *Zip* ]] | |
453 then | |
454 #echo "detected zip file" | |
455 cp $archive ${galaxypath}/archive_${fname}/${fname}.zip | |
456 wd=`pwd` | |
457 cd ${galaxypath}/archive_${fname}/ | |
458 unzip -q ${fname}.zip | |
459 rm ${fname}.zip | |
460 cd $wd | |
461 fi | |
462 if [[ $ftype == *tar* ]] | |
463 then | |
464 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar | |
465 wd=`pwd` | |
466 cd ${galaxypath}/archive_${fname}/ | |
467 tar xf ${fname}.tar | |
468 rm ${fname}.tar | |
469 cd $wd | |
470 fi | |
471 if [[ $ftype == *gzip* ]] | |
472 then | |
473 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz | |
474 gunzip ${galaxypath}/archive_${fname}/${fname}.gz | |
475 #ls ${galaxypath}/archive_${fname}/ | |
476 | |
477 # check for tar.gz | |
478 ftype=`file ${galaxypath}/archive_${fname}/${fname}` | |
479 if [[ $ftype == *tar* ]] | |
480 then | |
481 # turns out it was tar.gz | |
482 rm -Rf ${galaxypath}/archive_${fname}/* | |
483 ls ${galaxypath}/archive_${fname}/ | |
484 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar.gz | |
485 | |
486 wd=`pwd` | |
487 cd ${galaxypath}/archive_${fname}/ | |
488 tar xzf ${fname}.tar.gz | |
489 cd $wd | |
490 fi | |
491 wait | |
492 rm -f ${galaxypath}/archive_${fname}/*.tar | |
493 rm -f ${galaxypath}/archive_${fname}/*.tar.gz | |
494 fi | |
495 if [[ $ftype == *bzip2* ]] | |
496 then | |
497 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz | |
498 gunzip2 ${galaxypath}/archive_${fname}/${fname}.gz | |
499 fi | |
500 | |
501 | |
502 | |
503 # add links to webpage | 850 # add links to webpage |
504 # separate line for each folder, files within folder on same line | 851 # separate line for each folder, files within folder on same line |
505 for linkfile in `ls ${galaxypath}/archive_${fname}/ |sort -V` | 852 for linkfile in `ls ${galaxypath}/archive_${fname}/ |sort -V` |
506 do | 853 do |
507 #echo "<br/> ->making link to file: $linkfile " | 854 #echo "<br/> ->making link to file: $linkfile " |
538 fi | 885 fi |
539 fi | 886 fi |
540 done | 887 done |
541 | 888 |
542 echo "${contentline}" | 889 echo "${contentline}" |
890 | |
891 | |
543 } | 892 } |
544 | 893 |
545 ## | 894 ## |
546 ## Create HTML content for iReport | 895 ## Create HTML content for iReport |
547 ## | 896 ## |
548 createMainPage (){ | 897 createMainPage (){ |
898 #export IFRAMECNT=1 | |
549 page=$1 | 899 page=$1 |
550 tabtitles=$2 # comma-separated list of tab titles | 900 tabtitles=$2 # comma-separated list of tab titles |
551 tabitems=$3 # colon-sparated list of tabs specifications | 901 tabitems=$3 # colon-sparated list of tabs specifications |
552 iframecount=1 # keep track of number of iFrames so that they can be referenced by ID | 902 #giframecount=1 # keep track of number of iFrames so that they can be referenced by ID |
553 minwidth=$4 # width of page | 903 minwidth=$4 # width of page |
554 | 904 gbtracks=$5 # genome browser track information |
555 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles" | 905 |
906 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles. gbtracks: $gbtracks" | |
556 # create correct number of tabs | 907 # create correct number of tabs |
557 count=0 | 908 count=0 |
558 | 909 |
910 tabtitles=${tabtitles/,/} | |
559 tabtitles=${tabtitles//,/ } | 911 tabtitles=${tabtitles//,/ } |
560 tabtitles=${tabtitles//==colon==/:} | 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 | |
561 tabslist="<ul>\n" | 925 tabslist="<ul>\n" |
562 mytabs="" | 926 mytabs="" |
563 | 927 |
564 for title in $tabtitles | 928 for title in $newtabtitles |
565 do | 929 do |
566 # Create list of tabs | 930 # Create list of tabs |
567 count=$[count+1] | 931 count=$[count+1] |
568 title2=${title//_s_/ } | 932 title2=${title//==space==/ } |
933 title2=${title2//==dollar==/$} | |
934 title2=${title2//==colon==/} | |
569 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n" | 935 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n" |
570 | 936 |
571 # Create tabs with content | 937 # Create tabs with content |
572 tabcontent=$(makeTabContent $title "$tabitems") | 938 tabcontent=$(makeTabContent $title "$tabitems" "$gbtracks") |
573 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n" | 939 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n" |
574 mytabs="${mytabs}${tabcontent}" | 940 mytabs="${mytabs}${tabcontent}" |
575 mytabs="${mytabs}\n</div>\n" | 941 mytabs="${mytabs}\n</div>\n" |
576 done | 942 done |
577 tabslist="${tabslist}</ul>" | 943 tabslist="${tabslist}</ul>" |