def solid_volume(vm): from VolumeViewer import volume_list for v in volume_list(): if vm in v.models(): return v return None
def make_molecule_map(atoms, resolution, step, pad, cutoff_range, sigma_factor, display_threshold, model_id, replace, show_dialog): atoms = tuple(atoms) grid, molecules = molecule_grid_data(atoms, resolution, step, pad, cutoff_range, sigma_factor) from chimera import openModels as om if replace: from VolumeViewer import volume_list vlist = [v for v in volume_list() if getattr(v, 'molmap_atoms', None) == atoms] om.close(vlist) from VolumeViewer import volume_from_grid_data v = volume_from_grid_data(grid, open_model = False, show_dialog = show_dialog) v.initialize_thresholds(mfrac = (display_threshold, 1), replace = True) v.show() v.molmap_atoms = tuple(atoms) # Remember atoms used to calculate volume v.molmap_parameters = (resolution, step, pad, cutoff_range, sigma_factor) if len(molecules) == 1 and model_id is None: om.add([v], sameAs = tuple(molecules)[0]) else: if model_id is None: model_id = (om.Default, om.Default) om.add([v], baseId = model_id[0], subid = model_id[1]) v.openState.xform = atoms[0].molecule.openState.xform return v
def make_molecule_map(atoms, resolution, step, pad, cutoff_range, sigma_factor, display_threshold, model_id, replace, show_dialog): atoms = tuple(atoms) grid, molecules = molecule_grid_data(atoms, resolution, step, pad, cutoff_range, sigma_factor) from chimera import openModels as om if replace: from VolumeViewer import volume_list vlist = [ v for v in volume_list() if getattr(v, 'molmap_atoms', None) == atoms ] om.close(vlist) from VolumeViewer import volume_from_grid_data v = volume_from_grid_data(grid, open_model=False, show_dialog=show_dialog) v.initialize_thresholds(mfrac=(display_threshold, 1), replace=True) v.show() v.molmap_atoms = tuple(atoms) # Remember atoms used to calculate volume v.molmap_parameters = (resolution, step, pad, cutoff_range, sigma_factor) if len(molecules) == 1 and model_id is None: om.add([v], sameAs=tuple(molecules)[0]) else: if model_id is None: model_id = (om.Default, om.Default) om.add([v], baseId=model_id[0], subid=model_id[1]) v.openState.xform = atoms[0].molecule.openState.xform return v
def find_simulated_map(self, atoms, res, mwm): a = tuple(atoms) from VolumeViewer import volume_list for v in volume_list(): if hasattr(v, 'fitsim_params') and v.fitsim_params == (a, res, mwm): return v return None
def interpolated_map(self, create=True): v1 = self.map_menu_1.volume() v2 = self.map_menu_2.volume() if v1 is None or v2 is None: self.message('Need to select two volume data sets.') return None im = None mm = self.morph_maps if (v1, v2) in mm: im = mm[(v1, v2)] # Check that volume is still opened in volume viewer. from VolumeViewer import volume_list if not im.result in volume_list(): im = None else: # Check that map size matches current v1 subregion ijk_min, ijk_max = v1.region[:2] v1_size = tuple(map(lambda a, b: b - a + 1, ijk_min, ijk_max)) if im.result.data.size != v1_size: im = None if not create and im is None: return None sf = (1.0, self.second_map_multiplier()) adj = self.adjust_thresholds.get() am = self.add_maps.get() if im is None: if v1 == v2: self.message('Two maps are the same.') return None if v1.data.size != v2.data.size: self.message('Map sizes differ.') return None import morph im = morph.Interpolated_Map((v1, v2), scale_factors=sf, adjust_thresholds=adj, add_mode=am, subregion=v1.region[:2]) mm[(v1, v2)] = mm[(v2, v1)] = im else: im.adjust_thresholds = adj im.add_mode = am im.scale_factors = sf if self.undisplay_maps.get(): v1.unshow() v2.unshow() self.message('') return im
def interpolated_map(self, create = True): v1 = self.map_menu_1.volume() v2 = self.map_menu_2.volume() if v1 is None or v2 is None: self.message('Need to select two volume data sets.') return None im = None mm = self.morph_maps if (v1,v2) in mm: im = mm[(v1,v2)] # Check that volume is still opened in volume viewer. from VolumeViewer import volume_list if not im.result in volume_list(): im = None else: # Check that map size matches current v1 subregion ijk_min, ijk_max = v1.region[:2] v1_size = tuple(map(lambda a,b: b-a+1, ijk_min, ijk_max)) if im.result.data.size != v1_size: im = None if not create and im is None: return None sf = (1.0, self.second_map_multiplier()) adj = self.adjust_thresholds.get() am = self.add_maps.get() if im is None: if v1 == v2: self.message('Two maps are the same.') return None if v1.data.size != v2.data.size: self.message('Map sizes differ.') return None import morph im = morph.Interpolated_Map((v1,v2), scale_factors = sf, adjust_thresholds = adj, add_mode = am, subregion = v1.region[:2]) mm[(v1,v2)] = mm[(v2,v1)] = im else: im.adjust_thresholds = adj im.add_mode = am im.scale_factors = sf if self.undisplay_maps.get(): v1.unshow() v2.unshow() self.message('') return im
def data_regions_volume_viewer_list(): """data_regions_volume_viewer_list() Output: data_regions list of Volume Viewer data regions Return a list of data regions in Volume Viewer dialog, if it is open, else return None. """ from VolumeViewer import volume_list return volume_list()
def outline_box(): 'Toggle outline boxes for selected volumes' from VolumeViewer import volume_list, Volume from chimera import selection if selection.currentEmpty(): vlist = volume_list() else: vlist = [v for v in selection.currentGraphs() if isinstance(v, Volume)] for v in vlist: if v.display: shown = v.rendering_options.show_outline_box v.set_parameters(show_outline_box=not shown) v.show()
def outline_box(): 'Toggle outline boxes for selected volumes' from VolumeViewer import volume_list, Volume from chimera import selection if selection.currentEmpty(): vlist = volume_list() else: vlist = [v for v in selection.currentGraphs() if isinstance(v, Volume)] for v in vlist: if v.display: shown = v.rendering_options.show_outline_box v.set_parameters(show_outline_box = not shown) v.show()
def fillInUI(self, parent): self.morph_maps = {} # Writable maps for pairs of end-point maps. self.default_f_range = (0.0, 1.0, 0.1) self.play_stop_button = self.buttonWidgets['Play'] import Tkinter from CGLtk import Hybrid frame = parent frame.columnconfigure(0, weight=1) row = 0 h = Tkinter.Label(parent, text='Interpolate between two maps') h.grid(row=row, column=0, sticky='w') row += 1 from VolumeViewer import volume_list, Volume_Menu vlist = volume_list() vm1 = Volume_Menu(parent, 'First map', open_button=True, show_on_open=True) vm1.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 1: vm1.set_volume(vlist[0]) row += 1 self.map_menu_1 = vm1 vm2 = Volume_Menu(parent, 'Second map', open_button=True, show_on_open=True) vm2.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 2: vm2.set_volume(vlist[1]) row += 1 self.map_menu_2 = vm2 self.scale = Hybrid.Scale(parent, 'Fraction ', 0.0, 1.0, 0.01, 0) self.scale.frame.grid(row=row, column=0, sticky='ew') self.scale.callback(self.scale_changed_cb) self.scale.entry.bind('<KeyPress-Return>', self.scale_changed_cb) row += 1 op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row=row, column=0, sticky='news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row=orow, column=1, sticky='e') fr = Tkinter.Frame(opf) fr.grid(row=orow, column=0, sticky='w') orow += 1 fmin, fmax, fstep = self.default_f_range fn = Hybrid.Entry(fr, 'Movie start ', 5, fmin) fn.frame.grid(row=0, column=0, sticky='w') fx = Hybrid.Entry(fr, ' end ', 5, fmax) fx.frame.grid(row=0, column=1, sticky='w') fs = Hybrid.Entry(fr, ' step ', 5, fstep) fs.frame.grid(row=0, column=2, sticky='w') self.f_range_variables = (fn.variable, fx.variable, fs.variable) um = Hybrid.Checkbutton(opf, 'Undisplay original maps', True) um.button.grid(row=orow, column=0, sticky='w') orow += 1 self.undisplay_maps = um.variable mu = Hybrid.Checkbutton_Entries(opf, False, 'Multiplier for second map', (4, '1.0')) mu.frame.grid(row=orow, column=0, sticky='w') orow += 1 self.use_multiplier, self.map_2_multiplier = mu.variables ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', False) ta.button.grid(row=orow, column=0, sticky='w') orow += 1 self.adjust_thresholds = ta.variable am = Hybrid.Checkbutton(opf, 'Add to first map instead of interpolating', False) am.button.grid(row=orow, column=0, sticky='w') orow += 1 self.add_maps = am.variable am.callback(self.add_mode_cb) rt = Hybrid.Checkbutton(opf, 'Round trip when recording movie', True) rt.button.grid(row=orow, column=0, sticky='w') orow += 1 self.roundtrip = rt.variable # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg
def getMapInfo(model): from VolumeViewer import volume_list for v in volume_list(): if v.data.name == volume_name.strip(): return (v.data.size, v.data.origin) return (None, None)
def volume_data_set(model): from VolumeViewer import volume_list for v in volume_list(): if model in v.models(): return v return None
def fillInUI(self, parent ): self.morph_maps = {} # Writable maps for pairs of end-point maps. self.default_f_range = (0.0, 1.0, 0.1) self.play_stop_button = self.buttonWidgets['Play'] import Tkinter from CGLtk import Hybrid frame = parent frame.columnconfigure(0, weight = 1) row = 0 h = Tkinter.Label(parent, text = 'Interpolate between two maps') h.grid(row = row, column = 0, sticky = 'w') row += 1 from VolumeViewer import volume_list, Volume_Menu vlist = volume_list() vm1 = Volume_Menu(parent, 'First map', open_button = True, show_on_open = True) vm1.frame.grid(row = row, column = 0, sticky = 'w') if len(vlist) >= 1: vm1.set_volume(vlist[0]) row += 1 self.map_menu_1 = vm1 vm2 = Volume_Menu(parent, 'Second map', open_button = True, show_on_open = True) vm2.frame.grid(row = row, column = 0, sticky = 'w') if len(vlist) >= 2: vm2.set_volume(vlist[1]) row += 1 self.map_menu_2 = vm2 self.scale = Hybrid.Scale(parent, 'Fraction ', 0.0, 1.0, 0.01, 0) self.scale.frame.grid(row = row, column = 0, sticky = 'ew') self.scale.callback(self.scale_changed_cb) self.scale.entry.bind('<KeyPress-Return>', self.scale_changed_cb) row += 1 op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row = row, column = 0, sticky = 'news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row = orow, column = 1, sticky = 'e') fr = Tkinter.Frame(opf) fr.grid(row=orow, column=0, sticky='w') orow += 1 fmin, fmax, fstep = self.default_f_range fn = Hybrid.Entry(fr, 'Movie start ', 5, fmin) fn.frame.grid(row=0, column=0, sticky='w') fx = Hybrid.Entry(fr, ' end ', 5, fmax) fx.frame.grid(row=0, column=1, sticky='w') fs = Hybrid.Entry(fr, ' step ', 5, fstep) fs.frame.grid(row=0, column=2, sticky='w') self.f_range_variables = (fn.variable, fx.variable, fs.variable) um = Hybrid.Checkbutton(opf, 'Undisplay original maps', True) um.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.undisplay_maps = um.variable mu = Hybrid.Checkbutton_Entries(opf, False, 'Multiplier for second map', (4, '1.0')) mu.frame.grid(row=orow, column=0, sticky='w') orow += 1 self.use_multiplier, self.map_2_multiplier = mu.variables ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', False) ta.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.adjust_thresholds = ta.variable am = Hybrid.Checkbutton(opf, 'Add to first map instead of interpolating', False) am.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.add_maps = am.variable am.callback(self.add_mode_cb) rt = Hybrid.Checkbutton(opf, 'Round trip when recording movie', True) rt.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.roundtrip = rt.variable # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width = 40, anchor = 'w', justify = 'left') msg.grid(row = row, column = 0, sticky = 'ew') row = row + 1 self.message_label = msg