GMOD / jbrowse

JBrowse 1, a full-featured genome browser built with JavaScript and HTML5. For JBrowse 2, see https://github.com/GMOD/jbrowse-components.
http://jbrowse.org
Other
460 stars 199 forks source link

Dynamically add tracks to track selector #677

Closed timeu closed 8 years ago

timeu commented 8 years ago

What is the best way to dynamically add tracks to the track selector? I checked the configuration page but I couldn't find any information and also couldn't find an existing issue.

I have following use case: I would like to embed a jBrowse instance in a web-application. users can log into the web-application and when they do I want to display the user's custom tracks in the track selector.

I see three possible solutions:

  1. Allow to define a REST endpoint which retrieves a list of custom tracks
  2. Provide an JS API to interact with the track selector
  3. Write a custom JS plugin to interact with the track selector

As far as I can tell option 1 and 2 are not yet supported (maybe 2 is but I couldn't find any documentation) and option 3 I could do myself but I guess it's also the most involved one.

Personally I would favor option 1, because from a user point of view, it would be the simplest one to use.

enuggetry commented 8 years ago

Hi Umit, The plugin RegexSequenceSearch is a good example of dynamically creating a track on the JS side. However, if you're looking to drive it from an external application or from the server end, there's no way to do it yet.

Eric

On Thu, Jan 7, 2016 at 7:12 AM, Ümit Seren notifications@github.com wrote:

What is the best way to dynamically add tracks to the track selector? I checked the configuration page but I couldn't find any information and also couldn't find an existing issue

I have following use case: I would like to embed a jBrowse instance in a web-application users can log into the web-application and when they do I want to display the user's custom tracks in the track selector

I see three possible solutions: 1 Allow to define a REST endpoint which retrieves a list of custom tracks 2 Provide an JS API to interact with the track selector 3 Write a custom JS plugin to interact with the track selector

As far as I can tell option 1 and 2 are not yet supported (maybe 2 is but I couldn't find any documentation) and option 3 I could do myself but I guess it's also the most involved one

Personally I would favor option 1, because from a user point of view, it would be the simplest one to use

— Reply to this email directly or view it on GitHub https://github.com/GMOD/jbrowse/issues/677.

ihh commented 8 years ago

There will be soon!

ihh commented 8 years ago

@timeu: On re-reading this I am not sure if you were asking what I thought you were asking. If what you want is to be able to publish new tracks on the server and have them show up in the client, then this is now (partly) functional on the faye branch: https://github.com/gmod/jbrowse/tree/faye

I say "partly" because there is not yet any way to remove or replace tracks via this mechanism (there should be soon).

I think, however, that what you really want is a way to filter visible tracks on the client side (possibly with a RESTful store that maintains the set of visible tracks for each user). There is no such mechanism in the JBrowse server yet, but there IS a JS API to interact with the track selector (your solution number 2). Well, sort of, anyway: you can use the internal event framework to delete tracks from the track selector, as per here: http://gmod.org/wiki/JBrowse_Configuration_Guide#Publishing_and_Subscribing_to_JBrowse_Events

Maybe not exactly what you're looking for, but possibly helpful nonetheless.

timeu commented 8 years ago

@ihh Thanks for the info. Yeah I actually don't want to modify anything on the JBrowser backend side but let my backend control the data that is displayed in the track selector. This would make it easy to support multitenancy in JBrowse. The Jbrowse backend does not have to know anything about the users and so on. I will have a look at the JS API but would you be willing to accept a pull request if I implement a REST endpoint feature for the track selector ?

nathandunn commented 8 years ago

@timeu We do the same thing Apollo by driving the JBrowse URL in an iframe. You should be able to show the appropriate tracks that way. Additionally, you can write a plugin to explicitly set / unset them:

      if (command == "show") {
                                browser.publish('/jbrowse/v1/v/tracks/show', [browser.trackConfigsByName[trackInfo.label]]);
                            }
                            else if (command == "hide") {
                                browser.publish('/jbrowse/v1/v/tracks/hide', [browser.trackConfigsByName[trackInfo.label]]);
                            }
nathandunn commented 8 years ago

We are also looking forward to the JS API! The faye branch looks nice.

cmdcolin commented 8 years ago

This is sort of a random note, but I think if you are trying to dynamically add a new track to an already running browser, you first have to add some extra code to initialize it first (that is, if the track you are adding did not exist in the config at all)

The createCombinationTrack is an example of that, where first it calls "addStoreConfig", and then it calls "getStore", and then it calls browser.publish with the config

cmdcolin commented 8 years ago

There might be other ways to do it though. The FileDialog for example for initializing new tracks doesn't use those functions !