Closed maxime-bc closed 4 years ago
By the time this renderFeatures is called, you can see you are already getting fRects, which is the exact rectangle in screen coordinates that the feature was given by the layout. It will not matter how that list of rectangles is sorted. I can't necessarily point you to the best place to do it properly but here is a couple notes
An important part of the "Sort by" function that I only learned recently is that it sorts the features that cross a so-called "center line" e.g. the center of the view. This means for example the "Sort by base" function means it is the base in the middle of the view. "Sort by start" is sorting the reads that cross the middle of the view by their start coordinate.
That has some amount of impact on how this feature is implemented.
Now, if you are applying the sort, you may look at modifying the storeClass BAM.js and/or CRAM.js and make it so that you call the featureCallback for each feature in sorted order, and it will need to be connected to the coordinate of the so called "center line" which you can maybe compute from JBrowse.view.visibleRegion()
For adding menu items that could be fine, I normally do it like this though https://github.com/elsiklab/gccontent/blob/master/js/View/Track/GCContent.js#L42
Also, instead of deeply poking into the "feature.record.alignmentStart" etc. I'd recommend calling things like feature.get('start') https://jbrowse.org/docs/faq.html#how-do-i-access-data-about-my-features-in-my-callback-or-plugin
Closed by accident
Thanks !
Sure thing, let us know if you have any more questions or get any results, this would be a great feature to have
We have added this feature in JBrowse 2 which is in alpha state just FYI
It is likely that we will not backport this ourselves but PR are still welcome
Hello everybody,
I would like to develop a plugin to answer this issue.
I tried to inherit the
renderFeatures
function from Alignment2.js in order to sort the features (fRects) according to their alignment start by clicking on an extra feature menu item.In the development console of my browser, I can see that the features are sorted as wanted but in the end the features are still displayed in the same order as before sorting.
With what I want to achieve, I also need to find a way to trigger the sort of the features using the
action
key from the extra menu item.This is my current piece of code :
Am I modifying the right function ?
Would it be possible to have more information regarding the display of features within JBrowse? What classes do you think I should inherit and which functions should I modify?
Thanks in advance for your help, Best regards.