Open sehilyi opened 1 year ago
@manzt Can you suggeset a way to enable the Python package to visualize individual views of Chromoscope? My thought was that (1) we can publish a JS library that exposes several Gosling spec template functions (e.g., createOverviewSpec()
, createSvSpec()
, etc) and (2) use them in Python somehow (e.g., gosling.embed(ele, createOverviewSpec({ config }))
using AnyWidget?).
You shouldn't need to publish a second package. You could easily create an HTML template and inline the JavaScript like in Gos and write the spec directly:
_HTML_TEMPLATE = jinja2.Template("""
<div id="{{ output_id }"></div>
<script type="application/javascript">// load gosling</script>
<script>
const templateType = "{{ template_type }}";
let templateFn;
if (templateType === "sv") {
templateFn = ...
} else if (templateType == "overview") {
templateFn = ...
}
const spec = templateFn(JSON.parse(({{ config_json }}));
gosling.embed(document.getElementById("#{{ output_id }}", spec);
</script>
""")
html = _HTML_TEMPLATE.render(
output_id=uuid.uuid4().hex, # unique id for the page
template_type="sv",
config_json=json.dumps(config),
)
@manzt But, we want to reuse template codes already implemented in JS (e.g., here) so that visualizations generated by the JS library and the Python package can be consistent. In this case, should we still not need to publish the second package?
esbuild --bundle src/track/coverage.ts --outfile coverage.js
_TEMPLATE = jinja2.Template("""
<script>
""" + pathlib.Path("./coverage.js").read_text() + """
</script>
<script>
console.log(coverage) // imported as global above
</script>
""")
Required
If Possible
chromoscope.overview()
)