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

Avoid performing a text index search if input looks like a locstring #2960

Merged
merged 4 commits into from
May 19, 2022

Conversation

cmdcolin
Copy link
Collaborator

Possible shortcut for refnameautocomplete

If the user input looks like a locstring then we can shortcircuit and not perform a text search

This shortcut already exists for a locstring that matches exactly a chromosome name in the assembly's refname list (or alias)

So, this just expands the shortcut to detect if it matches the a locstring with a colon, splitting on the colon and assuming the start of that is a locstring

That wouldn't perfectly apply for assembly based locstrings but the majority use case would be non-assembly-including locstrings probably

@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label May 19, 2022
@cmdcolin cmdcolin changed the title Avoid performing a text index search if if input looks like a locstring Avoid performing a text index search if input looks like a locstring May 19, 2022
@codecov
Copy link

codecov bot commented May 19, 2022

Codecov Report

Merging #2960 (946f695) into main (8b9d869) will increase coverage by 0.01%.
The diff coverage is 80.00%.

❗ Current head 946f695 differs from pull request most recent head 141dd6a. Consider uploading reports for the commit 141dd6a to get more accurate results

@@            Coverage Diff             @@
##             main    #2960      +/-   ##
==========================================
+ Coverage   60.67%   60.68%   +0.01%     
==========================================
  Files         601      601              
  Lines       27342    27353      +11     
  Branches     6654     6665      +11     
==========================================
+ Hits        16589    16600      +11     
  Misses      10442    10442              
  Partials      311      311              
Impacted Files Coverage Δ
...iew/src/LinearGenomeView/components/ImportForm.tsx 78.04% <77.77%> (-0.62%) ⬇️
...view/src/LinearGenomeView/components/SearchBox.tsx 87.23% <81.81%> (-3.01%) ⬇️
...inearGenomeView/components/RefNameAutocomplete.tsx 84.84% <0.00%> (-0.31%) ⬇️
.../linear-genome-view/src/LinearGenomeView/index.tsx 85.10% <0.00%> (-0.18%) ⬇️
packages/core/ui/SnackbarModel.ts 90.47% <0.00%> (+23.80%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fbed2d...141dd6a. Read the comment docs.

@cmdcolin cmdcolin added enhancement New feature or request and removed needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) labels May 19, 2022
@cmdcolin
Copy link
Collaborator Author

issue that this fixes was noted in gitter by @Shellfishgene

@cmdcolin
Copy link
Collaborator Author

Now it tries to detect essentially strings that are like

ctgA:100
ctgA:200..300

But won't do it for something like

ctgA:FEATID

It does so by detecting whether the string after the colon is a valid number, e.g. !Number.isNaN(parseInt(strAfterColon,10)), and if so, it thinks it is a locstring.

@cmdcolin cmdcolin force-pushed the refname_nav_shortcut branch from 946f695 to 141dd6a Compare May 19, 2022 23:40
@cmdcolin cmdcolin merged commit c3b9b3e into main May 19, 2022
@cmdcolin cmdcolin deleted the refname_nav_shortcut branch May 19, 2022 23:55
@jantusan
Copy link

Hello, I'm not sure if this is the right place to comment or I should open a new issue, but related to this it could be useful to interpret three words strings in the search bars as genome coordinates, without the need to include : and ../- in a similar manner as IGV does. Then Chr2 4480831 4736747 would be interpreted as Chr2:4,480,831..4,736,747

I think this may be helpful to users as I often browse the genome by copying coordinates from BED files or GRanges objects in R that have formats of chr\tstart\tend or chr\sstart-end respectively, and adding the required : and ../- slows the process a bit. I am wondering if this could be done by checking if the first word is a RefName and the others numeric.

@cmdcolin
Copy link
Collaborator Author

@jantusan that sounds like a great idea, i'll reference this in a new issue. i think it should be possible to do

@cmdcolin
Copy link
Collaborator Author

@jantusan this feature was released in v1.7.10! at least the white space generated (chr start end), the chr\tstart-end wasn't done. let me know if the chr\tstart-end is valuable too

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.

2 participants