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

How to use function getSequence() from WebApollo plugin #659

Closed twsaari closed 7 years ago

twsaari commented 8 years ago

My goal is to get the sequence for a feature on a CanvasFeatures track. I know how to get the region sequence, but I'm only interested in the coding portions. I want to make this very easy for end-users.

I'm trying to make use of the functions in the WebApollo plugin getSequence and getSequenceForSelectedFeatures (AnnotTrack.js is attached which includes these functions), on a CanvasFeatures track, but I'm unsure about how to go about doing this. Would I have to define AnnotTrack.js within CanvasFeatures.js? I have made a crude attempt at trying this out, but only feel that I'm on the wrong path. When things break, I'm not sure how to debug. Unfortunately, my knowledge of javascript only dates back to when I started playing with JBrowse.

[AnnotTrack.txt](https://github.com/GMOD/jbrowse/files/39383/AnnotTrack.txt)
nathandunn commented 8 years ago

In Apollo 2.0.1 (still pre-release) you should be able to create an annotated feature from a canvas feature and then extract the sequence from that. If you are using an older version, you may be able to back-port this fix.

twsaari commented 8 years ago

Thank you for the reply. Is it at all possible to do this within JBrowse itself? The reason I ask is that I've got JBrowse approved (bureaucratic environment) and working on a server for testing within our team of researchers. Apollo, on the other hand, I've just begun playing with on my local machine. I imagine that it will take a while to get Apollo to that stage, as it has a backend to it.

nathandunn commented 8 years ago

I don’t know.

It might be better to post to the gmod-ajax or jbrowse-dev lists as someone may have already done this or may have more nuance:

http://gmod.org/wiki/JBrowse#Contacts_and_Mailing_Lists http://gmod.org/wiki/JBrowse#Contacts_and_Mailing_Lists

Nathan

On Nov 19, 2015, at 12:22 PM, tsaari88 notifications@github.com wrote:

Thank you for the reply. Is it at all possible to do this within JBrowse itself? The reason I ask is that I've got JBrowse approved (bureaucratic environment) and working on a server for testing within our team of researchers. Apollo, on the other hand, I've just begun playing with on my local machine. I imagine that it will take a while to get Apollo to that stage, as it has a backend to it.

— Reply to this email directly or view it on GitHub https://github.com/GMOD/jbrowse/issues/659#issuecomment-158186275.

ihh commented 8 years ago

Hi Travis, The JBrowse/Store/SeqFeature object has a getReferenceSequence method that returns the reference sequence for a given feature. This is used by JBrowse/View/Track/_FeatureDetailMixin to implement the "Region sequence" field in the feature default window that you get by right-clicking on a feature (in an HTMLFeatures or CanvasFeatures track) and selecting "View details". Since JBrowse does not currently have a way of selecting a feature per se (just highlighting a region of sequence), I'm not sure exactly how you want this feature to look in JBrowse, but it should be possible. I suspect someone in the community may even have done it but I'm not sure. Cheers, Ian

cmdcolin commented 8 years ago

here's sort of a similar github topic https://github.com/GMOD/jbrowse/issues/633

I guess this could be possible with just "grabbing" all your exons, and matching them together. Basically you could create a custom click action for a popup for example, and then just put all the subsequences together

For example

"onClick": {"action": "function() { var res_string; var feat=this.feature; var subfeatures=feat.get('subfeatures'); for(subfeat in subfeatures) { if(subfeat.get('type')=='exon') { res_string+=get the sequence for this feature here... } alert(res_string); }"}

The code for getting the sequence for the feature is a async operation, so you would want to wait on multiple promises from the getReferenceSequence operation, i.e. call getReferenceSequence({ ref: this.refSeq.name, start: f.get('start'), end: f.get('end')} a bunch of times, save the promises that it returns, and then use http://dojotoolkit.org/reference-guide/1.10/dojo/promise/all.html or similar to wait on all the promises, and then concatenate all the substrings together

Apollo of course is a little more sophisticated at building gene models on the server side, but this type of thing might be sufficient in some use cases

zhjilin commented 8 years ago

Hi, I may ask a stupid question here, I want to query sequence of each features for further visualization together with on my customized features. Let's take code from HTMLFeatures.js as an example.

I was trying to append sequence to object 'feature' or 'featDiv' by calling

this.browser.getStore('refseqs',dojo.hitch(this, function(refSeqStore){ refSeqStore.getReferenceSequence( { ref:feature.get('seq_id'), start: feature.get('start'), end: feature.get('end')}, function(seq){ feature.data['seq']=seq;}, function(mfeat){feature.data['mfeat']=mfeat;} function(){} )}));

either in addFeatureToBlock or fillFeatures function, however I couldn't really add sequence back. I guess it's because of scope issue? the 2nd function is my customized function(I modified SeqFeature to fit my needs, here it can be properly called by this method but not direct this.store.getReferenceSequence() ). Can anyone help to figure out how to put "mfeat" to feature?

Thanks !

cmdcolin commented 7 years ago

I imagine now that there is the successful featuresequence plugin that this can be closed! https://github.com/tsaari88/FeatureSequence