From: Giles V. <gv...@sa...> - 2009-09-23 09:58:21
Attachments:
Picture 1.png
|
Hello JBrowsers, I have encountered a situation where if the GFF file in question does not have features of a certain type, but JBrowse is configured to show these, then the track gets stuck with a "Loading..." (see screenshot). It looks like it's making a request to a json file that's not there in this case. e.g. : gv1@ubuntu:~/code/jbrowse_config$ ls /var/www/jbrowsers/jbrowse/data/ tracks/Lmjchr1 Exon Gene Polypeptide Repeats gv1@ubuntu:~/code/jbrowse_config$ ls /var/www/jbrowsers/jbrowse/data/ tracks/Lmjchr10 Exon Gene Polypeptide Pseudogenics Repeats In the chromosome 10, there are some tracks labelled as pseudogenics. In chromosome 1, there aren't. Because in this situation I am loading a lot of GFF files, there are bound to be ones that don't have some of the features specified in the config file. Should it be possible to make the Loading message time out? I guess it would then display a wholly blank track, which would be accurate in this case. The disadvantage of that approach is for users with poor connections, where timeouts happen more often, and where blank tracks would then appear even though the data is there on the server. Another option might be to create a blank files with empty data structures in them, but I guess that depends on how the js handles empties. All the Best, Giles -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. |
From: Mitch S. <mit...@be...> - 2009-09-23 18:21:31
|
On 09/23/2009 02:58 AM, Giles Velarde wrote: > Should it be possible to make the Loading message time out? I guess it > would then display a wholly blank track, which would be accurate in > this case. The disadvantage of that approach is for users with poor > connections, where timeouts happen more often, and where blank tracks > would then appear even though the data is there on the server. If there's no file, then the client should be getting a 404 HTTP error code. And it should be straightforward to add an error handler to the code that loads the individual tracks. That should handle the no-file case without requiring a timeout. I'll send a message to the list when I have something. Mitch |
From: Giles V. <gv...@sa...> - 2009-09-24 08:50:55
|
Thanks, Mitch! On 23 Sep 2009, at 19:21, Mitch Skinner wrote: > On 09/23/2009 02:58 AM, Giles Velarde wrote: >> Should it be possible to make the Loading message time out? I guess >> it would then display a wholly blank track, which would be accurate >> in this case. The disadvantage of that approach is for users with >> poor connections, where timeouts happen more often, and where blank >> tracks would then appear even though the data is there on the server. > > If there's no file, then the client should be getting a 404 HTTP > error code. And it should be straightforward to add an error > handler to the code that loads the individual tracks. That should > handle the no-file case without requiring a timeout. I'll send a > message to the list when I have something. > > Mitch -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. |
From: Giles V. <gv...@sa...> - 2009-09-27 22:15:41
|
On 23 Sep 2009, at 19:21, Mitch Skinner wrote: > On 09/23/2009 02:58 AM, Giles Velarde wrote: >> Should it be possible to make the Loading message time out? I guess >> it would then display a wholly blank track, which would be accurate >> in this case. The disadvantage of that approach is for users with >> poor connections, where timeouts happen more often, and where blank >> tracks would then appear even though the data is there on the server. > > If there's no file, then the client should be getting a 404 HTTP > error code. And it should be straightforward to add an error > handler to the code that loads the individual tracks. That should > handle the no-file case without requiring a timeout. I'll send a > message to the list when I have something. > > Mitch Thanks Mitch, I had a look over the weekend (see patch below). This turned out to be a little bit more complicated than I thought because if I tried to just do something simple in the error handler like this.setLoaded(); data structures weren't initialized properly and errors ensued. I got around this by faking an empty track inside the error handler and passing it onto loadSuccess(). Not being familiar with JBrowse, I don't know if this is the best way to do it, but it seems to work for me. All the Best, Giles From f2406d7e65c65fb98553b197eec0107db7c49c08 Mon Sep 17 00:00:00 2001 From: Giles Velarde <gv...@sa...> Date: Sun, 27 Sep 2009 12:24:39 +0100 Subject: [PATCH] added an error handler to FeatureTrack to handle tracks with no features --- js/FeatureTrack.js | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/js/FeatureTrack.js b/js/FeatureTrack.js index 40ea281..d05e587 100644 --- a/js/FeatureTrack.js +++ b/js/FeatureTrack.js @@ -27,12 +27,37 @@ function FeatureTrack(trackMeta, url, refSeq, browserParams) { var curTrack = this; dojo.xhrGet({url: curTrack.baseUrl + url, handleAs: "json", - load: function(o) { curTrack.loadSuccess(o); } + load: function(o) { curTrack.loadSuccess(o); }, + error: function(o) { curTrack.loadFail(o); } }); } FeatureTrack.prototype = new Track(""); +FeatureTrack.prototype.loadFail = function(error) { + if (error.status == "404") + { + console.log(this.trackMeta.label + " not loaded due to missing JSON file, creating an 'empty' track... "); + var trackInfo = { + "subfeatureClasses":null, + "headers": ["start","end","strand","id","name","phase","type","load_id"], + "featureCount":0, + "featureNCList":[], + "key": this.trackMeta.key, + "className":"", + "clientConfig":null, + "rangeMap":[], + "arrowheadClass":null, + "subfeatureHeaders":["start","end","strand","id","type"], + "label": this.trackMeta.label, + "type": this.trackMeta.type, + "sublistIndex":0 + }; + this.loadSuccess(trackInfo); + } +} + + FeatureTrack.prototype.loadSuccess = function(trackInfo) { var startTime = new Date().getTime(); this.count = trackInfo.featureCount; -- 1.5.6.3 -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. |
From: Mitch S. <mit...@be...> - 2009-09-29 12:46:54
|
On 09/27/2009 03:16 PM, Giles Velarde wrote: > I had a look over the weekend (see patch below). This turned out to be > a little bit more complicated than I thought because if I tried to > just do something simple in the error handler like > > this.setLoaded(); > > data structures weren't initialized properly and errors ensued. I got > around this by faking an empty track inside the error handler and > passing it onto loadSuccess(). Not being familiar with JBrowse, I > don't know if this is the best way to do it, but it seems to work for me. Cool! It's great to see people getting into the code. What you did was the first thing I thought of doing, but I wanted to solve the problem for ImageTrack as well. This is what I just committed to the master branch: http://github.com/jbrowse/jbrowse/commit/6e7f2e8940ccb3fa6bf2c79db499121289d67fe6 It adds yet another bit of state to the Track class, which I usually try to avoid; on the other hand, it saves us from having to maintain a proper fake empty track. Hopefully I don't sound like I'm dismissing what you did; I'm really happy when I get patches, but I thought about it and decided I wanted to go in a different direction. Regards, Mitch |
From: Giles V. <gv...@sa...> - 2009-09-29 12:42:07
|
On 29 Sep 2009, at 13:31, Mitch Skinner wrote: > On 09/27/2009 03:16 PM, Giles Velarde wrote: >> I had a look over the weekend (see patch below). This turned out to >> be a little bit more complicated than I thought because if I tried >> to just do something simple in the error handler like >> >> this.setLoaded(); >> >> data structures weren't initialized properly and errors ensued. I >> got around this by faking an empty track inside the error handler >> and passing it onto loadSuccess(). Not being familiar with JBrowse, >> I don't know if this is the best way to do it, but it seems to work >> for me. > > Cool! It's great to see people getting into the code. What you did > was the first thing I thought of doing, but I wanted to solve the > problem for ImageTrack as well. This is what I just committed to > the master branch: > > http://github.com/jbrowse/jbrowse/commit/6e7f2e8940ccb3fa6bf2c79db499121289d67fe6 > > It adds yet another bit of state to the Track class, which I usually > try to avoid; on the other hand, it saves us from having to maintain > a proper fake empty track. > > Hopefully I don't sound like I'm dismissing what you did; I'm really > happy when I get patches, but I thought about it and decided I > wanted to go in a different direction. > > Regards, > Mitch No worries, Mitch. I am just scratching its surface right now, and was well aware that was probably a better way. Glad it's fixed! Will try it out asap. Cheers, Giles -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. |