comparison createHTML.sh @ 1:d582e2cd3e13 draft

Uploaded
author saskia-hiltemann
date Wed, 15 Jul 2015 08:52:21 -0400
parents 3c160414da2e
children 945e72d0e723
comparison
equal deleted inserted replaced
0:3c160414da2e 1:d582e2cd3e13
20 <br/> 20 <br/>
21 <center> 21 <center>
22 <b><font size=\"15\"> iReport: ${title} </font></b><br/> 22 <b><font size=\"15\"> iReport: ${title} </font></b><br/>
23 <br/> 23 <br/>
24 <br/> 24 <br/>
25 <a href=\"$link\"> Click here to view report </a> <br/><br/> 25 <a href=\"$link\"> Click image to view report </a> <br/><br/>
26 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/> 26 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/>
27 <a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/> 27 <a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/>
28 </center> 28 </center>
29 </body> 29 </body>
30 </html>" > $htmlout 30 </html>" > $htmlout
135 then 135 then
136 ## resubstitute sanitized charachters 136 ## resubstitute sanitized charachters
137 text=${text//==space==/ } 137 text=${text//==space==/ }
138 text=${text//==colon==/:} 138 text=${text//==colon==/:}
139 text=${text//==comma==/,} 139 text=${text//==comma==/,}
140
141 text=${text//==braceopen==/(}
142 text=${text//==braceclose==/)}
143 text=${text//==cbraceopen==/{}
144 text=${text//==cbraceclose==/&#125;}
145
140 text=${text//==slash==/\/} 146 text=${text//==slash==/\/}
141 text=${text//==lt==/<} 147 text=${text//==lt==/<}
142 text=${text//==gt==/>} 148 text=${text//==gt==/>}
143 text=${text//==apos==/\'} 149 text=${text//==apos==/\'}
144 text=${text//==quote==/\"} 150 text=${text//==quote==/\"}
150 text=${text//\\t/\\t} 156 text=${text//\\t/\\t}
151 text=${text//\&r\&n/\\n} 157 text=${text//\&r\&n/\\n}
152 text=${text//\&r/\\n} 158 text=${text//\&r/\\n}
153 text=${text//\&n/\\n} 159 text=${text//\&n/\\n}
154 text=${text//\&c/:} 160 text=${text//\&c/:}
155 161
156 162
157 ## convert markdown in textfield to html 163 ## convert markdown in textfield to html
158 echo -e "$text" > mytext.md 164 echo -e "$text" > mytext.md
159 165
160 if [ -z `type -p pandoc` ] 166 if [ -z `type -p pandoc` ]
161 then 167 then
219 text=${text//\&n/<br/>} 225 text=${text//\&n/<br/>}
220 text=${text//\&c/:} 226 text=${text//\&c/:}
221 text=${text//==backtick==/&#96;} 227 text=${text//==backtick==/&#96;}
222 text=${text//==dollar==/$} 228 text=${text//==dollar==/$}
223 text=${text//==bar==/|} 229 text=${text//==bar==/|}
230 text=${text//==braceopen==/(}
231 text=${text//==braceclose==/)}
232 text=${text//==cbraceopen==/{}
233 text=${text//==cbraceclose==/&#125;}
224 contentline="${contentline}\n${text}\n" 234 contentline="${contentline}\n${text}\n"
225 fi 235 fi
226 236
227 237
228 fi 238 fi
279 #restore file suffix for html 289 #restore file suffix for html
280 ftype=`file ${myarr[2]}` 290 ftype=`file ${myarr[2]}`
281 zoomlevel=${myarr[4]} 291 zoomlevel=${myarr[4]}
282 zoomenable=${myarr[5]} 292 zoomenable=${myarr[5]}
283 align=${myarr[6]} 293 align=${myarr[6]}
294 typestring=""
284 #####echo "zoomenable:${zoomenable}, align:${align}" 295 #####echo "zoomenable:${zoomenable}, align:${align}"
285 if [[ $ftype == *JPEG* ]] 296 if [[ $ftype == *JPEG* ]]
286 then 297 then
287 suffix=".jpg" 298 suffix=".jpg"
288 fi 299 fi
291 suffix=".svg" 302 suffix=".svg"
292 fi 303 fi
293 if [[ $ftype == *PNG* ]] 304 if [[ $ftype == *PNG* ]]
294 then 305 then
295 suffix=".png" 306 suffix=".png"
307 fi
308 if [[ $ftype == *TIFF* ]]
309 then
310 suffix=".tiff"
311 typestring="type=\"image/tiff\""
296 fi 312 fi
297 313
298 image=`basename ${myarr[2]}` 314 image=`basename ${myarr[2]}`
299 image=${image%.dat} 315 image=${image%.dat}
300 image="${image}${suffix}" 316 image="${image}${suffix}"
367 col=${myarr[6]} 383 col=${myarr[6]}
368 prefix=${myarr[7]} 384 prefix=${myarr[7]}
369 suffix=${myarr[8]} 385 suffix=${myarr[8]}
370 urlitems=${myarr[9]} 386 urlitems=${myarr[9]}
371 minw=${myarr[10]} 387 minw=${myarr[10]}
388 minh=${myarr[11]}
372 suffix=${suffix/emptycol/} 389 suffix=${suffix/emptycol/}
373 suffix=${suffix/==quote==/&} 390 suffix=${suffix/==quote==/&}
374 prefix=${prefix/emptycol/} 391 prefix=${prefix/emptycol/}
375 prefix=${prefix/==quote==/&} 392 prefix=${prefix/==quote==/&}
376 prefix=${prefix/==colon==/:} 393 prefix=${prefix/==colon==/:}
405 } 422 }
406 }END{}' ${tsvfile} > ${tsvfile}2 423 }END{}' ${tsvfile} > ${tsvfile}2
407 424
408 else 425 else
409 minw=${myarr[6]} 426 minw=${myarr[6]}
427 minh=${myarr[7]}
410 cp ${tsvfile} ${tsvfile}2 428 cp ${tsvfile} ${tsvfile}2
411 fi 429 fi
412 430
413 iframecount=$[$iframecount+1] 431 iframecount=$[$iframecount+1]
414 if [ $fancy == "Y" ] 432 if [ $fancy == "Y" ]
415 then 433 then
416 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html 434 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
417 contentline="${contentline}\n<iframe class=\"invisibleframe fancyiframe\" id=\"$iframeid\" src=\"htmltable_${fname}.html\" width=\"100%\" style=\"height: 760px; min-height: 525px; overflow-y: hidden; overflow-x: scroll\" ></iframe>" 435 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\" ></iframe>"
418 iframecount=$[$iframecount+1] 436 iframecount=$[$iframecount+1]
419 else 437 else
420 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html 438 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
421 contentline="${contentline}\n<iframe class=\"unfancyiframe invisibleframe\" id=\"$iframeid\" src=\"htmltable_${fname}.html\" scrolling=\"no\" style=\"min-width: ${minw}px; max-width: 100%; vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe>" 439 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;\" onload=\"resizeIframe(this)\"></iframe>"
422 iframecount=$[$iframecount+1] 440 iframecount=$[$iframecount+1]
423 fi 441 fi
424 442
425 if [[ $numlines -gt ${maxlines} ]] 443 if [[ $numlines -gt ${maxlines} ]]
426 then 444 then
460 fname=`basename ${htmlfile}` 478 fname=`basename ${htmlfile}`
461 fname=${fname%.dat} 479 fname=${fname%.dat}
462 htmlname="${fname}.html" 480 htmlname="${fname}.html"
463 cp ${htmlfile} "${galaxypath}/${htmlname}" 481 cp ${htmlfile} "${galaxypath}/${htmlname}"
464 482
465 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n" 483 apiid=${myarr[5]}
484 isireport=${myarr[6]}
485 localhost=${myarr[7]}
486 proxy=${myarr[8]}
487 localhost=${localhost//==colon==/:}
488 localhost=${localhost//==fslash==/\/}
489 if [[ ${isireport} == "Y" ]]
490 then
491 #cp ${localhost}/datasets/${apiid}/* "${galaxypath}/tst"
492 htmlname="/${proxy}/datasets/${apiid}/display/"
493 fi
494
495 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n"
466 fi 496 fi
467 497
468 498
469 if [[ ${myarr[1]} == "htmlpage" ]] 499 if [[ ${myarr[1]} == "htmlpage" ]]
470 then 500 then
471 url=${myarr[2]} 501 url=${myarr[2]}
472 url=${url//==colon==/:} 502 url=${url//==colon==/:}
473 url=${url//==fslash==//} 503 url=${url//==fslash==//}
474 height=${myarr[4]} 504 height=${myarr[4]}
475
476 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${url}\" width=\"100%\" height=\"${height}px\"></iframe>\n" 505 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${url}\" width=\"100%\" height=\"${height}px\"></iframe>\n"
477 fi 506 fi
478 507
479 ## 508 ##
480 ## Web Link 509 ## Web Link
481 ## 510 ##
482 if [ ${myarr[1]} == "weblink" ] 511 if [ ${myarr[1]} == "weblink" ]
483 then 512 then
484 url=${myarr[2]} 513 url=${myarr[2]}
485 linktext=${myarr[4]} 514 linktext=${myarr[4]}
486 url=${url/==colon==/:} 515
487 url=${url/==quote==/&} 516 echo -n "$url" > tmpfileb64
488 517 url=`base64 -d tmpfileb64`
518
519 echo -n "$linktext" > tmpfileb64
520 linktext=`base64 -d tmpfileb64`
521
522 if [[ -z $linktext ]]
523 then
524 linktext=$url
525 fi
489 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>" 526 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>"
490 fi 527 fi
491 528
492 529
493 ## 530 ##
494 ## Genome Browser 531 ## Genome Browser
495 ## 532 ##
496 if [ ${myarr[1]} == "genomebrowser" ] 533 if [ ${myarr[1]} == "genomebrowser" ]
497 then 534 then
535
498 # parse inputs 536 # parse inputs
499 537
500 apiid=${myarr[4]} 538 apiid=${myarr[4]}
501 servername=${myarr[5]} 539 servername=${myarr[5]}
502 buildver=${myarr[2]} 540 buildver=${myarr[2]}
541
542
543 region=${myarr[6]}
544
545
546 echo -n "$region" > tmpfileb64
547 region=`base64 -d tmpfileb64`
548
549
550 initialchrom=${region%:*}
551 initialrange=${region#*:}
552
553 initialstart=${initialrange%-*}
554 initialend=${initialrange#*-}
555
503 556
504 #TODO 557 #TODO
505 ftype="vcf" 558 ftype="vcf"
506 559
507 servername=${servername/==colon==/:} 560 servername=${servername/==colon==/:}
519 gbfileinfo=(${gbfile//:/ }) 572 gbfileinfo=(${gbfile//:/ })
520 if [[ ${gbfileinfo[0]} == $gbcount ]] 573 if [[ ${gbfileinfo[0]} == $gbcount ]]
521 then 574 then
522 575
523 ftype=${gbfileinfo[3]} 576 ftype=${gbfileinfo[3]}
524 if [ $ftype == "vcf" ] 577
578 gbfilename=${gbfileinfo[1]}
579 gbfilelabel=${gbfileinfo[2]}
580 gbfilelabel=${gbfilelabel//==space==/ }
581 gbfilelabel=${gbfilelabel//==bopen==/(}
582 gbfilelabel=${gbfilelabel//==bclose==/)}
583 fname=`basename ${gbfilename}`
584 fname=${fname%.dat}
585
586 if [[ $ftype == "vcftabix" ]]
525 then 587 then
526 gbfilename=${gbfileinfo[1]}
527 gbfilelabel=${gbfileinfo[2]}
528 gbfilelabel=${gbfilelabel//==space==/ }
529 fname=`basename ${gbfilename}`
530 fname=${fname%.dat}
531 newgbfilename="${fname}.vcf" 588 newgbfilename="${fname}.vcf"
532 589
533 590
534 cp ${gbfilename} "${galaxypath}/${newgbfilename}" 591 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
535 bgzip "${galaxypath}/${newgbfilename}" 592 bgzip "${galaxypath}/${newgbfilename}"
536 tabix -p vcf "${galaxypath}/${newgbfilename}.gz" 593 tabix -f -p vcf "${galaxypath}/${newgbfilename}.gz"
537 594
538 userTracks="${userTracks}, 595 userTracks="${userTracks},
539 {name: '${gbfilelabel}', 596 {name: '${gbfilelabel}',
540 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}.gz', 597 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}.gz',
541 tier_type: 'tabix', 598 tier_type: 'tabix',
542 payload: 'vcf'} 599 payload: 'vcf'}
543 " 600 "
544 fi 601 fi
545 602
546 if [ $ftype == "bam" ] 603 if [[ $ftype == "vcfmemstore" ]]
547 then 604 then
548 gbfilename=${gbfileinfo[1]} 605 newgbfilename="${fname}.vcf"
549 gbfilelabel=${gbfileinfo[2]} 606
550 gbfilelabel=${gbfilelabel//==space==/ } 607
551 fname=`basename ${gbfilename}` 608 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
552 fname=${fname%.dat} 609 #bgzip "${galaxypath}/${newgbfilename}"
610 #tabix -p vcf "${galaxypath}/${newgbfilename}.gz"
611
612 userTracks="${userTracks},
613 {name: '${gbfilelabel}',
614 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}',
615 tier_type: 'memstore',
616 payload: 'vcf'}
617 "
618 fi
619
620 if [[ $ftype == "bam" ]]
621 then
553 newgbfilename="${fname}.bam" 622 newgbfilename="${fname}.bam"
554 623
555 # link to bam instead of copying 624 # link to bam instead of copying
556 ln -s ${gbfilename} "${galaxypath}/${newgbfilename}" 625 ln -s ${gbfilename} "${galaxypath}/${newgbfilename}"
557 samtools index "${galaxypath}/${newgbfilename}" 626 samtools index "${galaxypath}/${newgbfilename}"
558 627
559 userTracks="${userTracks}, 628 userTracks="${userTracks},
560 {name: '${gbfilelabel}', 629 {name: '${gbfilelabel}',
561 bamURI: '${servername}/datasets/${apiid}/display/${newgbfilename}'} 630 bamURI: '${servername}/datasets/${apiid}/display/${newgbfilename}'}
631 "
632
633 fi
634
635 if [[ $ftype == "bigbed" ]]
636 then
637 newgbfilename="${fname}.bigbed"
638
639 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
640 #bgzip "${galaxypath}/${newgbfilename}"
641 #tabix -f -p bed "${galaxypath}/${newgbfilename}.gz"
642
643 userTracks="${userTracks},
644 {name: '${gbfilelabel}',
645 bwgURI: '${servername}/datasets/${apiid}/display/${newgbfilename}'}
646 "
647
648 fi
649
650 if [[ $ftype == "bedtabix" ]]
651 then
652 newgbfilename="${fname}.bed"
653
654 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
655 bgzip "${galaxypath}/${newgbfilename}"
656 tabix -f -p bed "${galaxypath}/${newgbfilename}.gz"
657
658 userTracks="${userTracks},
659 {name: '${gbfilelabel}',
660 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}.gz',
661 tier_type: 'tabix',
662 payload: 'bed'}
663 "
664
665 fi
666
667 if [[ $ftype == "bedmemstore" ]]
668 then
669 newgbfilename="${fname}.bed"
670
671 cp ${gbfilename} "${galaxypath}/${newgbfilename}"
672 #bgzip "${galaxypath}/${newgbfilename}"
673 #tabix -p bed "${galaxypath}/${newgbfilename}.gz"
674
675 userTracks="${userTracks},
676 {name: '${gbfilelabel}',
677 uri: '${servername}/datasets/${apiid}/display/${newgbfilename}',
678 tier_type: 'memstore',
679 payload: 'bed'}
562 " 680 "
563 681
564 fi 682 fi
565 fi 683 fi
566 done 684 done
630 748
631 contentline="${contentline} 749 contentline="${contentline}
632 <script language=\"javascript\" src=\"https://www.biodalliance.org/release-0.13/dalliance-compiled.js\"></script> 750 <script language=\"javascript\" src=\"https://www.biodalliance.org/release-0.13/dalliance-compiled.js\"></script>
633 <script language=\"javascript\"> 751 <script language=\"javascript\">
634 new Browser({ 752 new Browser({
635 chr: '1', 753 chr: '$initialchrom',
636 viewStart: 0, 754 viewStart: $initialstart,
637 viewEnd: 100000, 755 viewEnd: $initialend,
638 cookieKey: 'human', 756 cookieKey: 'human',
639 757 pageName: 'svgHolder${gbcount}',
640 ${coordSystem} 758 ${coordSystem}
641 759
642 ${chains} 760 ${chains}
643 sources: [{name: 'Genome', 761 sources: [{name: 'Genome',
644 twoBitURI: 'https://www.biodalliance.org/datasets/${buildver}.2bit', 762 twoBitURI: 'https://www.biodalliance.org/datasets/${buildver}.2bit',
662 } 780 }
663 781
664 }); 782 });
665 </script> 783 </script>
666 784
667 <div id=\"svgHolder\"></div> 785 <div id=\"svgHolder${gbcount}\"></div>
668 " 786 "
669 fi 787 fi
670 788
671 ## 789 ##
672 ## Link to Dataset 790 ## Link to Dataset
677 apiid=${myarr[4]} 795 apiid=${myarr[4]}
678 isireport=${myarr[5]} 796 isireport=${myarr[5]}
679 linkfilename=`basename ${linkfile}` 797 linkfilename=`basename ${linkfile}`
680 linktext=${myarr[6]} 798 linktext=${myarr[6]}
681 799
800 localhost=${myarr[7]}
801 proxy=${myarr[8]}
802 localhost=${localhost//==colon==/:}
803 localhost=${localhost//==fslash==/\/}
682 804
683 #check for some basic filetypes 805 #check for some basic filetypes
684 ftype=`file $linkfile` 806 ftype=`file $linkfile`
685 if [[ $ftype == *HTML* ]] 807 if [[ $ftype == *HTML* ]]
686 then 808 then
704 fi 826 fi
705 827
706 828
707 if [[ ${isireport} == "Y" ]] 829 if [[ ${isireport} == "Y" ]]
708 then 830 then
709 linkfilename="/datasets/${apiid}/display/" 831 linkfilename="/${proxy}/datasets/${apiid}/display/"
710 else 832 else
711 cp ${linkfile} "${galaxypath}/${linkfilename}" 833 cp ${linkfile} "${galaxypath}/${linkfilename}"
712 fi 834 fi
713 835
714 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>" 836 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>"
777 899
778 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles. gbtracks: $gbtracks" 900 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles. gbtracks: $gbtracks"
779 # create correct number of tabs 901 # create correct number of tabs
780 count=0 902 count=0
781 903
904 tabtitles=${tabtitles/,/}
782 tabtitles=${tabtitles//,/ } 905 tabtitles=${tabtitles//,/ }
783 tabtitles=${tabtitles//==colon==/:} 906 echo $tabtitles
907
908 tabcount=0
909 for tabt in $tabtitles
910 do
911 echo -n $tabt > tmpfileb64
912 thistabtitle=`base64 -d tmpfileb64`
913 newtabtitles+=" $thistabtitle"
914 tabcount=$[tabcount+1]
915 done
916
917 echo $newtabtitles
918
784 tabslist="<ul>\n" 919 tabslist="<ul>\n"
785 mytabs="" 920 mytabs=""
786 921
787 for title in $tabtitles 922 for title in $newtabtitles
788 do 923 do
789 # Create list of tabs 924 # Create list of tabs
790 count=$[count+1] 925 count=$[count+1]
791 title2=${title//_s_/ } 926 title2=${title//==space==/ }
927 title2=${title2//==dollar==/$}
928 title2=${title2//==colon==/}
792 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n" 929 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n"
793 930
794 # Create tabs with content 931 # Create tabs with content
795 tabcontent=$(makeTabContent $title "$tabitems" "$gbtracks") 932 tabcontent=$(makeTabContent $title "$tabitems" "$gbtracks")
796 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n" 933 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n"