Skip to content

Commit

Permalink
allow custom javascript
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
brentp committed Apr 7, 2020
1 parent b5e01be commit 78ceac2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v0.0.8 (dev)
============
+ show help when run with no args (#7)
+ allow injection of custom javascript to affect `options` and `option.tracks` (#4)

v0.0.7
======
Expand Down
2 changes: 2 additions & 0 deletions jigv-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
} else {
location.hash = options.locus
}
// this is replaced and filled with any custom javascript from the user.
<JIGV_CUSTOM_JS>
igv.createBrowser(div, options).then(function (b) {
browser = b;
browser.on('locuschange', function (referenceFrame) {
Expand Down
9 changes: 5 additions & 4 deletions jigv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ const templ = staticRead("jigv-template.html")
proc main() =

let p = newParser("jigv"):
option("-r", "--region", help="optional region to start at")
option("-r", "--region", help="optional region to start viewing (will default to first variant in first vcf)")
flag("-o", "--open-browser", help="open browser")
option("-g", "--genome-build", default="hg38", help="genome build (e.g. hg19, mm10, dm6, etc, from https://s3.amazonaws.com/igv.org.genomes/genomes.json)")
option("-f", "--fasta", default="", help="optional fasta reference file if not in hosted and needed to decode CRAM")
option("-p", "--port", default="5001")
# TODO: regions files
option("--js", help="custom javascript to inject. will have access to `options` and `options.tracks`. if this ends in .js it is read as a file")
arg("files", help="bam/cram/vcf/bed file(s) (with indexes)", nargs= -1)

var argv = commandLineParams()
Expand Down Expand Up @@ -405,8 +405,9 @@ proc main() =
options["locus"] = % args.region

index_html = tmpl.replace("<OPTIONS>", pretty(options))
# index_html = tmpl.replace("</head>", insert_js.replace("<OPTIONS>", pretty(options)) & "</head>")
# index_html = index_html.replace("</body>", """</body><script type="text/javascript">jigv()</script>""")
var js:string = args.js
if js.endsWith(".js"): js = readFile(js)
index_html = index_html.replace("<JIGV_CUSTOM_JS>", js)

let settings = newSettings(port=parseInt(args.port).Port)
var jester = initJester(igvrouter, settings)
Expand Down

0 comments on commit 78ceac2

Please sign in to comment.