Skip to content

Commit

Permalink
Made similar structures cluster plot menu entries that show traces cr…
Browse files Browse the repository at this point in the history
…eate the traces if they don't already exist.
  • Loading branch information
tomgoddard committed Nov 1, 2024
1 parent b032791 commit 404a6fb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/bundles/similarstructures/src/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ def fill_context_menu(self, menu, item):
self.add_menu_entry(menu, 'Select reference atoms', self._select_reference_atoms)

def _show_cluster_traces(self, node):
self._show_traces(self._cluster_names(node))
if self._create_traces():
self._show_only_cluster_traces(node)
else:
self._show_traces(self._cluster_names(node))

def _show_only_cluster_traces(self, node):
cnames = self._cluster_names(node)
Expand All @@ -156,9 +159,18 @@ def _hide_cluster_traces(self, node):
self._show_traces(self._cluster_names(node), show = False)

def _show_traces(self, names, show = True, other = False):
self._create_traces()
for tmodel in _backbone_trace_models(self.session, self._similar_structures_id):
tmodel.show_traces(names, show=show, other=other)

def _create_traces(self):
if len(_backbone_trace_models(self.session, self._similar_structures_id)) == 0:
from . import traces
traces.similar_structures_traces(self.session, from_set = self._similar_structures_id)
self._color_traces()
return True
return False

def _show_all_traces(self):
cnames = []
self._show_traces(cnames, show = True, other = True)
Expand Down Expand Up @@ -188,6 +200,7 @@ def _hide_unplotted_traces(self):
self._show_traces([n.name for n in self.nodes], show = False, other = True)

def _color_traces(self):
self._create_traces()
tmodels = _backbone_trace_models(self.session, self._similar_structures_id)
if tmodels:
from chimerax.core.colors import rgba_to_rgba8
Expand Down

0 comments on commit 404a6fb

Please sign in to comment.