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

Get selection programatically #85

Open
duerrsimon opened this issue Apr 19, 2023 · 3 comments
Open

Get selection programatically #85

duerrsimon opened this issue Apr 19, 2023 · 3 comments

Comments

@duerrsimon
Copy link

I'm looking for a way to programmatically access the currently selected residues. I checked the methods in viewerInstance.visual but there was no obvious way of getting a data object.

@orangeSi
Copy link

orangeSi commented Nov 7, 2023

I also had the silimar question: get which one residues is hovered now? I am looking at https://rcsb.org/3d-view/ to get some clue.

@midlik
Copy link
Collaborator

midlik commented Aug 28, 2024

PDBe Molstar does not provide helper functions for this. But it is achievable via core Molstar functionality.

You can add listeners for highlight (when the user hovers a residue) and select (when the user clicks a residue while in Selection Mode):

viewerInstance.plugin.managers.interactivity.lociHighlights.addProvider((loci, action) => console.log('mark', loci, action));
viewerInstance.plugin.managers.interactivity.lociSelects.addProvider((loci, action) => console.log('select', loci, action));

Getting useful info from loci and action won't be straightforward. I can just point you to the source code where these are declared:
loci: https://github.com/molstar/molstar/blob/523dfe7928d3f8cad9b62b1c95667816f1ca9d2a/src/mol-model/structure/structure/element/loci.ts#L31
action: https://github.com/molstar/molstar/blob/523dfe7928d3f8cad9b62b1c95667816f1ca9d2a/src/mol-util/marker-action.ts#L11

@midlik
Copy link
Collaborator

midlik commented Aug 28, 2024

If you meant getting residues that you have previously selected via viewerInstance.visual.select, just save the object that you passed to the function.

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

No branches or pull requests

3 participants