jbrowse_config.js~ 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. window.onerror=function(msg){
  2. if( document.body )
  3. document.body.setAttribute("JSError",msg);
  4. }
  5. // puts the main Browser object in this for convenience. feel
  6. // free to move it into function scope if you want to keep it
  7. // out of the global namespace
  8. var JBrowse;
  9. require(['JBrowse/Browser', 'dojo/io-query', 'dojo/json' ],
  10. function (Browser,ioQuery,JSON) {
  11. // the initial configuration of this JBrowse
  12. // instance
  13. // NOTE: this initial config is the same as any
  14. // other JBrowse config in any other file. this
  15. // one just sets defaults from URL query params.
  16. // If you are embedding JBrowse in some other app,
  17. // you might as well just set this initial config
  18. // to something like { include: '../my/dynamic/conf.json' },
  19. // or you could put the entire
  20. // dynamically-generated JBrowse config here.
  21. // parse the query vars in the page URL
  22. var queryParams = ioQuery.queryToObject( window.location.search.slice(1) );
  23. var config = {
  24. containerID: "GenomeBrowser",
  25. dataRoot: '/jbrowse/Medicago/data',
  26. browserRoot: '/jbrowse/Medicago',
  27. queryParams: queryParams,
  28. location: queryParams.loc,
  29. forceTracks: queryParams.tracks,
  30. initialHighlight: queryParams.highlight,
  31. show_nav: queryParams.nav,
  32. show_tracklist: queryParams.tracklist,
  33. show_overview: queryParams.overview,
  34. stores: { url: { type: "JBrowse/Store/SeqFeature/FromConfig", features: [] } },
  35. makeFullViewURL: function( browser ) {
  36. // the URL for the 'Full view' link
  37. // in embedded mode should be the current
  38. // view URL, except with 'nav', 'tracklist',
  39. // and 'overview' parameters forced to 1.
  40. return browser.makeCurrentViewURL({ nav: 1, tracklist: 1, overview: 1 });
  41. },
  42. updateBrowserURL: true
  43. };
  44. //if there is ?addFeatures in the query params,
  45. //define a store for data from the URL
  46. if( queryParams.addFeatures ) {
  47. config.stores.url.features = JSON.parse( queryParams.addFeatures );
  48. }
  49. // if there is ?addTracks in the query params, add
  50. // those track configurations to our initial
  51. // configuration
  52. if( queryParams.addTracks ) {
  53. config.tracks = JSON.parse( queryParams.addTracks );
  54. }
  55. // if there is ?addStores in the query params, add
  56. // those store configurations to our initial
  57. // configuration
  58. if( queryParams.addStores ) {
  59. config.stores = JSON.parse( queryParams.addStores );
  60. }
  61. // create a JBrowse global variable holding the JBrowse instance
  62. JBrowse = new Browser( config );
  63. });