Skip to content

Instantly share code, notes, and snippets.

@scottcain
Last active October 4, 2022 02:28
Show Gist options
  • Save scottcain/1950d7582ddd30a51b42af37c65cfe0d to your computer and use it in GitHub Desktop.
Save scottcain/1950d7582ddd30a51b42af37c65cfe0d to your computer and use it in GitHub Desktop.
working LGV in drupal test site but not staging.wormbase.org
//this exact JS works just fine at http://scottca.in/node/3
// but at https://staging.wormbase.org/species/c_elegans/gene/WBGene00001340#09f6--10
// the exact same JS (with an extra fetch to get the releaseVersion) nearly entirely
// works but does NOT offset the track labels--that is the only difference.
//
// Weird
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script><script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script><script src="https://unpkg.com/@jbrowse/react-linear-genome-view/dist/react-linear-genome-view.umd.development.js" crossorigin></script>
function create_jbrowse2() {
var releaseVersion = 285;
var genomic_location = 'II:161136..172695';
var jbrowse_dataset = 'c_elegans_PRJNA13758';
const { createViewState, JBrowseLinearGenomeView } =
JBrowseReactLinearGenomeView
const { createElement } = React
const { render } = ReactDOM
fetch('https://s3.amazonaws.com/agrjbrowse/MOD-jbrowses/WormBase/WS'+ releaseVersion + '/embed/'+ jbrowse_dataset + '_embed.json').then(function(response) {
return response.json();
}).then(function(results) {
var assembl = results["assemblies"][0]
var tra = results["tracks"]
const state = new createViewState({
assembly: assembl,
tracks: tra,
location: genomic_location,
session: {
"id": "5nxOhj9gA",
"view": [
{
"id": "ZiH76KASh",
"type": "LinearGenomeView",
"trackLabels": "offset"
}
]
},
configuration: {
theme: {
palette: {
secondary : {
main: '#29405F'
},
tertiary: {
main: '#C5D1DE'
}
}
}
}
})
function showTrackSilencer(id) { try { state.session.view.showTrack(id) } catch(e) { console.warn(e) } }
showTrackSilencer(jbrowse_dataset+"_curated_genes")
showTrackSilencer(jbrowse_dataset+"_classical_alleles")
showTrackSilencer(jbrowse_dataset+"_change-of-function_alleles")
render(
createElement(JBrowseLinearGenomeView, { viewState: state }),
document.getElementById('jbrowse2_linear_genome_view'),
);
});
}
create_jbrowse2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment