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

Support cryoET data portal API v2 #30

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]

[project]
name = "ChimeraX-copick"
version = "0.3.6"
version = "0.5.0"
dynamic = ["classifiers", "requires-python"]
dependencies = [
"ChimeraX-Core>=1.7",
"ChimeraX-ArtiaX>=0.4.9",
"ChimeraX-ArtiaX>=0.5.0",
"ChimeraX-OME-Zarr>=0.5.4",
"pydantic",
"hatchling",
"s3fs>=2024.3.1",
"copick[all]>=0.5.2",
"copick[all]>=0.6.0",
]
authors = [
{name = "Utz H. Ermel", email = "utz@ermel.me"},
Expand Down
30 changes: 29 additions & 1 deletion src/cmd/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,28 @@ def copick_start(session, config_file: str):
copick.from_config_file(config_file)


def cks(session, shortcut=None):
"""
Enable copick keyboard shortcuts. Keys typed in the graphics window will be interpreted as shortcuts.

Parameters
----------
shortcut : string
Keyboard shortcut to execute. If no shortcut is specified switch to shortcut input mode.
"""

from ..shortcuts.shortcuts import copick_keyboard_shortcuts

ks = copick_keyboard_shortcuts(session)
if shortcut is None:
ks.enable_shortcuts()
else:
ks.try_shortcut(shortcut)


def register_copick(logger):
"""Register all commands with ChimeraX, and specify expected arguments."""
from chimerax.core.commands import CmdDesc, FileNameArg, register
from chimerax.core.commands import CmdDesc, FileNameArg, StringArg, register

def register_copick_start():
desc = CmdDesc(
Expand All @@ -40,4 +59,13 @@ def register_copick_start():
)
register("copick start", desc, copick_start)

def register_copick_keyboard_shortcuts():
desc = CmdDesc(
optional=[("shortcut", StringArg)],
synopsis="Start using Copick keyboard shortcuts.",
# url='help:user/commands/copick_start.html'
)
register("cks", desc, cks)

register_copick_start()
register_copick_keyboard_shortcuts()
22 changes: 19 additions & 3 deletions src/shortcuts/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
from chimerax.artiax.particle.ParticleList import delete_selected_particles
from chimerax.core.session import Session
from chimerax.log.tool import Log
from chimerax.shortcuts.shortcuts import Shortcut, keyboard_shortcuts, list_keyboard_shortcuts
from chimerax.shortcuts.shortcuts import (
Keyboard_Shortcuts,
Shortcut,
shortcut_descriptions,
)

from ..misc.volops import switch_to_ortho, switch_to_slab

Expand Down Expand Up @@ -75,8 +79,15 @@ def copick_shortcuts() -> Tuple[List[Tuple[Any, ...]], Tuple[Any, ...]]:
return csc, catcols


def copick_keyboard_shortcuts(session: Session) -> Keyboard_Shortcuts:
ks = getattr(session, "copick_shortcuts", None)
if ks is None:
session.copick_shortcuts = ks = Keyboard_Shortcuts(session)
return ks


def register_shortcuts(session: Session):
ksc = keyboard_shortcuts(session)
ksc = copick_keyboard_shortcuts(session)
ksc.shortcuts.clear()

scs, catcols = copick_shortcuts()
Expand Down Expand Up @@ -145,6 +156,11 @@ def toggle_info_label(session: Session):
session.copick.show_info = not session.copick.show_info


def list_copick_shortcuts(session: Session):
t = shortcut_descriptions(session.copick_shortcuts, html=True)
session.logger.info(t, is_html=True)


def show_help(session: Session):
list_keyboard_shortcuts(session)
list_copick_shortcuts(session)
session.tools.find_by_class(Log)[0].tool_window.shown = True
4 changes: 2 additions & 2 deletions src/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CopickTool(ToolInstance):
# Does this instance persist when session closes
SESSION_ENDURING = False
# We do save/restore in sessions
SESSION_SAVE = True
SESSION_SAVE = False

# Let ChimeraX know about our help page
def __init__(self, session, tool_name):
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(self, session, tool_name):
from .shortcuts.shortcuts import register_shortcuts

register_shortcuts(self.session)
run(session, "ks")
run(session, "cks")

# Stepper
self.stepper_list = []
Expand Down
9 changes: 0 additions & 9 deletions src/ui/QCoPickTreeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,3 @@ def flags(self, index: QModelIndex) -> Union[Qt.ItemFlag, None]:

index.internalPointer()
return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable

# if item.is_dir:
# return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
#
# if item.is_file:
# if item.extension in self._openable_types:
# return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
# else:
# return Qt.ItemFlag.ItemIsSelectable