| 1 | #
|
|---|
| 2 | # Keyboard shortcuts to mark compounds with View Dock in Chimera 1.14.
|
|---|
| 3 | # To use these use Chimera menu Tools / General / Keyboard Shortcuts and enter
|
|---|
| 4 | # the path to this file in the "Load shortcuts file" entry of the Keyboard Shortcuts
|
|---|
| 5 | # window.
|
|---|
| 6 | #
|
|---|
| 7 | # Typed two letter shortcuts cd, cx, cv, cn, cp only work when the main Chimera window
|
|---|
| 8 | # has the focus, not when the View Dock window has the focus.
|
|---|
| 9 | #
|
|---|
| 10 | def register_accelerators():
|
|---|
| 11 |
|
|---|
| 12 | from Accelerators import standard_accelerators
|
|---|
| 13 | standard_accelerators.register_accelerators()
|
|---|
| 14 |
|
|---|
| 15 | from Accelerators import add_accelerator
|
|---|
| 16 | add_accelerator('cd', 'Mark current View Dock compound deleted', vdock_delete)
|
|---|
| 17 | add_accelerator('cx', 'Mark current View Dock compound purged', vdock_purged)
|
|---|
| 18 | add_accelerator('cv', 'Mark current View Dock compound viable', vdock_viable)
|
|---|
| 19 | add_accelerator('cn', 'Move to next View Dock compound', vdock_next)
|
|---|
| 20 | add_accelerator('cp', 'Move to next View Dock compound', vdock_previous)
|
|---|
| 21 |
|
|---|
| 22 | def vdock_delete():
|
|---|
| 23 | from ViewDock.Compound import Compound
|
|---|
| 24 | vdock_set_state(Compound.Deleted)
|
|---|
| 25 |
|
|---|
| 26 | def vdock_purged():
|
|---|
| 27 | from ViewDock.Compound import Compound
|
|---|
| 28 | vdock_set_state(Compound.Purged)
|
|---|
| 29 |
|
|---|
| 30 | def vdock_viable():
|
|---|
| 31 | from ViewDock.Compound import Compound
|
|---|
| 32 |
|
|---|
| 33 | def vdock_set_state(state):
|
|---|
| 34 | vd = vdock_dialog()
|
|---|
| 35 | if vd:
|
|---|
| 36 | vd.compoundState.set(state)
|
|---|
| 37 | # To remove deleted and purged from list:
|
|---|
| 38 | # vd.results.setSelectedState(state)
|
|---|
| 39 | # vd._reloadCompounds()
|
|---|
| 40 | vdock_set_state(Compound.Viable)
|
|---|
| 41 |
|
|---|
| 42 | def vdock_next():
|
|---|
| 43 | vdock_step(1)
|
|---|
| 44 |
|
|---|
| 45 | def vdock_previous():
|
|---|
| 46 | vdock_step(-1)
|
|---|
| 47 |
|
|---|
| 48 | def vdock_step(step):
|
|---|
| 49 | vd = vdock_dialog()
|
|---|
| 50 | if vd:
|
|---|
| 51 | r = vd.results
|
|---|
| 52 | csel = r.selected
|
|---|
| 53 | if csel:
|
|---|
| 54 | c = csel[0]
|
|---|
| 55 | clist = r.compoundList
|
|---|
| 56 | i = clist.index(c)
|
|---|
| 57 | if i+step < len(clist) and i+step >= 0:
|
|---|
| 58 | nextc = clist[i+step]
|
|---|
| 59 | vd.results.setSelected([nextc])
|
|---|
| 60 |
|
|---|
| 61 | def vdock_dialog():
|
|---|
| 62 | from ViewDock import ViewDock
|
|---|
| 63 | from chimera import extension
|
|---|
| 64 | for vd in extension.manager.instances:
|
|---|
| 65 | if isinstance(vd, ViewDock):
|
|---|
| 66 | return vd
|
|---|
| 67 | return None
|
|---|