Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds URL query param for highlight on LGV #4234

Merged
merged 11 commits into from
Feb 27, 2024
Merged

Adds URL query param for highlight on LGV #4234

merged 11 commits into from
Feb 27, 2024

Conversation

carolinebridge
Copy link
Contributor

Responds to comments on #2316 and #599 requesting a highlight feature similar to what existed in JB1.

Allows a user to specify a highlight region in the URL with the pattern &highlight=REF:START..END

@carolinebridge carolinebridge added the enhancement New feature or request label Feb 22, 2024
@carolinebridge carolinebridge self-assigned this Feb 22, 2024
@carolinebridge
Copy link
Contributor Author

First draft divorced from existing bookmarking functionality -- adds a highlight element to the LGV if provided in the URL params.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 28.37838% with 53 lines in your changes are missing coverage. Please review.

Project coverage is 62.62%. Comparing base (ff057f5) to head (3da45d3).
Report is 9 commits behind head on main.

Files Patch % Lines
...view/src/LinearGenomeView/components/Highlight.tsx 35.89% 25 Missing ⚠️
.../LinearGenomeView/components/OverviewHighlight.tsx 9.52% 19 Missing ⚠️
...ar-genome-view/src/LaunchLinearGenomeView/index.ts 28.57% 5 Missing ⚠️
...c/LinearGenomeView/components/OverviewScalebar.tsx 33.33% 1 Missing and 1 partial ⚠️
...s/linear-genome-view/src/LinearGenomeView/model.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4234      +/-   ##
==========================================
- Coverage   62.71%   62.62%   -0.09%     
==========================================
  Files        1084     1086       +2     
  Lines       31316    31390      +74     
  Branches     7474     7502      +28     
==========================================
+ Hits        19639    19658      +19     
- Misses      11503    11557      +54     
- Partials      174      175       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmdcolin
Copy link
Collaborator

there may want to be a system to clear the highlights. in jbrowse 1. in jbrowse 1 there was sort of a 3-state button that helped with this. not sure the best UI for it for jbrowse 2, it is possible it doesn't need to be so "present" on the header bar and could instead be that clicking on the highlight itself could clear it or something like that. just an idea

additionally, it may be useful to show the highlight in the overviewscalebar

can see example for jbrowse 1 here

image

https://jbrowse.org/code/JBrowse-1.16.11/?loc=ctgA%3A9897..32106&tracks=DNA&data=sample_data%2Fjson%2Fvolvox&tracklist=1&highlight=ctgA%3A18821..28852&nav=1&overview=1

@cmdcolin
Copy link
Collaborator

I added a commit that avoids the highlight not rendering if the coordinate was numeric 0 (explicit checks for undefined) here 9c93a5a

would actually be nice if there was a lint rule for this as it can be so easy to miss this type of bug (you can reproduce numeric 0 by highlighting something starting at coord 1 e.g. ctgA:1-100 since it gets changed to 0 on import due to 1 base to 0 base conversion)

@cmdcolin
Copy link
Collaborator

found the lint rule :) #4238

@carolinebridge carolinebridge marked this pull request as ready for review February 26, 2024 21:47
: undefined
}

const h = mapCoords(model.highlight as ParsedLocStringA)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe this cast is "not valid", as model.highlight.start and model.highlight.end are potentially undefined by definition of ParsedLocString(?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most recent commit: is making use of Required https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype satisfactory?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is an interesting new feature of typescript, but I might opt for creating a new type (just the simple {assemblyName:string,refName:string,start:number,end:number} instead perhaps, and try to avoid using "as" cast entirely (casts are generally best if avoided as it cancels out any check that typescript would do for you)

*/
highlight: types.optional(
types.frozen<ParsedLocString>(),
{} as ParsedLocString,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this cast may not be valid, as refName is required on ParsedLocString. potentially, making it something like {assemblyName:string,refName:string,start:number,end:number}|undefined might be better than parsedlocstring, because then you know you have all required fields, or else it is just undefined

/**
* #action
*/
setHighlight(highlight: ParsedLocString) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with above comment, can make it "|undefined" so that undefined clears it

@cmdcolin cmdcolin merged commit 8f8da20 into main Feb 27, 2024
9 of 10 checks passed
@cmdcolin
Copy link
Collaborator

should be good for now, can see how it goes:)

@cmdcolin cmdcolin deleted the query-param-region branch February 27, 2024 18:37
@cmdcolin
Copy link
Collaborator

can you add a note to urlparams.md mentioning it? also might mention that it must be combined with &loc and &assembly because otherwise the app does not realize it is doing the "simple lgv launcher mode"

@grexor
Copy link

grexor commented Mar 21, 2024

This works great and thank you all, Jbrowse is amazing. I am now usign the highlight feature extensively and a need to highlight several regions somehow appeared. Do you think it would be possible to implement something like it? (or should I also have a look and perhaps can help?)

I was thinking something in this direction:

&highlight=1:100..200,1:250..300

This would highlight two regions on ref. 1 and 2, coordinates 100-200 and 250-300.

Any help appreciated, Thanks, Gregor

@cmdcolin cmdcolin mentioned this pull request Mar 21, 2024
@cmdcolin
Copy link
Collaborator

@grexor I just created a new issue for this here !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants