def ask_for_file_name(parent=None): import iotbx.file_reader file_name = wx.FileSelector( message="Select a reflections file", flags=wx.OPEN, wildcard=iotbx.file_reader.get_wildcard_strings(["hkl"])) if (file_name == "") or (file_name is None): raise Abort() return file_name
def get_phil_value_from_dialog(dlg): abort = False if (dlg.ShowModal() == wx.ID_OK): value = dlg.GetPhilValue() else: abort = True wx.CallAfter(dlg.Destroy) if (abort): raise Abort() return value
def do_work(item): tag, filename = item datablock = do_import(filename) imagesets = datablock.extract_imagesets() if len(imagesets) == 0 or len(imagesets[0]) == 0: logger.info("Zero length imageset in file: %s"%filename) return if len(imagesets) > 1: raise Abort("Found more than one imageset in file: %s"%filename) if len(imagesets[0]) > 1: raise Abort("Found a multi-image file. Run again with pre_import=True") if self.reference_detector is not None: from dxtbx.model import Detector imagesets[0].set_detector(Detector.from_dict(self.reference_detector.to_dict())) update_geometry(imagesets[0]) Processor(copy.deepcopy(params)).process_datablock(tag, datablock)
def load_reflections_file (self, file_name, set_array=True, data_only=False) : file_name = to_str(file_name) if (file_name != "") : from iotbx.reflection_file_reader import any_reflection_file from iotbx.gui_tools.reflections import get_array_description try : hkl_file = any_reflection_file(file_name) except Exception as e : raise Sorry(to_str(e)) arrays = hkl_file.as_miller_arrays(merge_equivalents=False, )#observation_type_callback=misc_dialogs.get_shelx_file_data_type) #arrays = f.file_server.miller_arrays valid_arrays = [] array_info = [] for array in arrays : if array.is_hendrickson_lattman_array() : continue elif (data_only) : if (not array.is_real_array()) and (not array.is_complex_array()) : continue labels = array.info().label_string() desc = get_array_description(array) array_info.append("%s (%s)" % (labels, desc)) valid_arrays.append(array) self.valid_arrays = valid_arrays if (len(valid_arrays) == 0) : msg = "No arrays of the supported types in this file." raise Sorry(msg) elif (len(valid_arrays) == 1) : if (set_array) : self.set_miller_array(valid_arrays[0]) return valid_arrays[0] else : #dlg = SelectArrayDialog(self, -1, "Select data") dlg = wx.SingleChoiceDialog(parent=None, message="Please select the data you wish to view:", caption="Select data", choices=array_info) # print("kau labels info is", array_info) #Kau added # print("Kau printing array_info from calling ", array_info) if (dlg.ShowModal() == wx.ID_OK) : sel = dlg.GetSelection() if (set_array) : self.set_miller_array(valid_arrays[sel]) wx.CallAfter(dlg.Destroy) self.settings_panel.update_column_choices(array_info, valid_arrays,sel) # kau added # self.settings_panel.update_column_choices(array_info,valid_arrays,sel) # kau added return valid_arrays[sel] wx.CallAfter(dlg.Destroy) raise Abort()
def clean_out_directory(parent=None, dir_name=None): if (dir_name is None): dir_name = os.getcwd() dlg1 = DirectoryCleanupDialog( parent=parent, title="Clean up directory", style=wx.CAPTION|wx.CLOSE_BOX|wx.RAISED_BORDER|\ wx.WS_EX_VALIDATE_RECURSIVELY) dlg1.SetDirectory(dir_name) dlg2 = None try: if (dlg1.ShowModal() == wx.ID_OK): dir_name = dlg1.GetDirectory() choices = dlg1.GetChoices() cleanup_obj = libtbx.path.clean_out_directory( path_name=dir_name, delete_kin_files="kin" in choices, delete_geo_files="geo" in choices, delete_map_files="map" in choices, delete_probe_files="probe" in choices, delete_temp_dirs="temp" in choices) if (cleanup_obj.n_total == 0): raise Sorry( "No files or directories matching the specified criteria.") else: dlg2 = ConfirmCleanupDialog(parent=parent, cleanup_obj=cleanup_obj) if (dlg2.ShowModal() == wx.ID_OK): cleanup_obj.run() wx.MessageBox( message="Action complete; %s of disk space freed." % cleanup_obj.get_freed_space()) return cleanup_obj else: raise Abort() else: raise Abort() finally: dlg1.Destroy() if (dlg2 is not None): dlg2.Destroy()
def run_function_as_detached_process_in_dialog( parent, thread_function, title, message, tmp_dir, callback=None, project_id=None, job_id=None): if (tmp_dir is None): tmp_dir = os.getcwd() params = runtime_utils.process_master_phil.extract() params.tmp_dir = tmp_dir if (job_id is not None): job_id = str(os.getpid()) + "_" + str(int(random.random() * 1000)) params.prefix = str(job_id) target = runtime_utils.detached_process_driver(target=thread_function) run_file = os.path.join(tmp_dir, "libtbx_run_%s.pkl" % job_id) easy_pickle.dump(run_file, target) params.run_file = run_file eff_file = os.path.join(tmp_dir, "libtbx_run_%s.eff" % job_id) runtime_utils.write_params(params, eff_file) dlg = ProcessDialog( parent=parent, message=message, caption=title, callback=callback) setup_process_gui_events( window=dlg, OnExcept=dlg.OnError, OnComplete=dlg.OnComplete) agent = event_agent( window=dlg, project_id=project_id, job_id=job_id) process = detached_process(params, proxy=agent) cb = event_agent(dlg, project_id=project_id, job_id=job_id) easy_run.call("libtbx.start_process \"%s\" &" % eff_file) result = None abort = False if (dlg.run(process) == wx.ID_OK): result = dlg.get_result() elif dlg.exception_raised(): dlg.handle_error() elif (dlg.was_aborted()): abort = True wx.CallAfter(dlg.Destroy) if (abort): raise Abort() return result
def do_import(filename): logger.info("Loading %s"%os.path.basename(filename)) try: datablocks = DataBlockFactory.from_json_file(filename) except ValueError: datablocks = DataBlockFactory.from_filenames([filename]) if len(datablocks) == 0: raise Abort("Could not load %s"%filename) if len(datablocks) > 1: raise Abort("Got multiple datablocks from file %s"%filename) # Ensure the indexer and downstream applications treat this as set of stills from dxtbx.imageset import ImageSet reset_sets = [] for imageset in datablocks[0].extract_imagesets(): imageset = ImageSet(imageset.reader(), imageset.indices()) imageset._models = imageset._models imageset.set_scan(None) imageset.set_goniometer(None) reset_sets.append(imageset) return DataBlockFactory.from_imageset(reset_sets)[0]
def get_rt_matrix(parent=None, enable_fractional=False): style = 0 if (enable_fractional): style = RT_DIALOG_ENABLE_FRACTIONAL dlg = RTDialog(parent=parent, title="Rotation/translation operator", wxtbxStyle=style) rt = None if (dlg.ShowModal() == wx.ID_OK): rt = dlg.GetMatrix() wx.CallAfter(dlg.Destroy) if (rt is None): raise Abort() return rt
def do_work(i, item_list): processor = Processor(copy.deepcopy(params), composite_tag="%04d" % i) for item in item_list: tag, filename = item datablock = do_import(filename) imagesets = datablock.extract_imagesets() if len(imagesets) == 0 or len(imagesets[0]) == 0: logger.info("Zero length imageset in file: %s" % filename) return if len(imagesets) > 1: raise Abort( "Found more than one imageset in file: %s" % filename) if len(imagesets[0]) > 1: raise Abort( "Found a multi-image file. Run again with pre_import=True" ) try: update_geometry(imagesets[0]) except RuntimeError as e: logger.warning( "Error updating geometry on item %s, %s" % (tag, str(e))) continue if self.reference_detector is not None: from dxtbx.model import Detector imagesets[0].set_detector( Detector.from_dict( self.reference_detector.to_dict())) processor.process_datablock(tag, datablock) processor.finalize()
def get_unique_symmetry( space_groups=(), unit_cells=(), sg_source_info=None, uc_source_info=None, parent=None, caption=None): assert (len(space_groups) > 0) or (len(unit_cells) > 0) non_unique = False for i_cell, uc in enumerate(unit_cells): j_cell = i_cell + 1 while (j_cell < len(unit_cells)): if (not uc.is_similar_to(unit_cells[j_cell])): non_unique = True break j_cell += 1 for i_sg, sg in enumerate(space_groups): j_sg = i_sg + 1 sg_number = sg.group().type().number() while (j_sg < len(space_groups)): other_number = space_groups[j_sg].group().type().number() if (sg_number != other_number): non_unique = True break j_sg += 1 final_cell = final_group = None if (non_unique): dlg = SymmetryChoiceDialog(parent=parent, title="Select unit cell and/or space group", caption=caption) dlg.SetUnitCells(unit_cells=unit_cells, source_info=uc_source_info) dlg.SetSpaceGroups(space_groups=space_groups, source_info=sg_source_info) if (dlg.ShowModal() == wx.ID_OK): final_cell = dlg.GetUnitCell() final_group = dlg.GetSpaceGroup() wx.CallAfter(dlg.Destroy) if (final_cell is None) and (final_group is None): raise Abort() else : final_cell = unit_cells[0] final_group = space_groups[0] from cctbx import crystal return crystal.symmetry( unit_cell=final_cell, space_group_info=final_group)
def select_file(self, parent, message, style=wx.OPEN, wildcard="All files (*.*)|*.*", current_file=None, multiple=False, save=None): if (save): style = wx.SAVE default_dir = self.last_dir default_file = "" if (current_file is not None) and (current_file != ""): if (os.path.isabs(current_file)): default_dir, default_file = os.path.split(current_file) else: default_file = current_file default_dir = to_unicode(default_dir) default_file = to_unicode(default_file) dlg = wx.FileDialog(parent=parent, message=message, defaultDir=default_dir, defaultFile=default_file, style=style, wildcard=wildcard) if (dlg.ShowModal() == wx.ID_OK): new_path = None if (multiple): new_path = dlg.GetPaths() if (new_path is not None) and (len(new_path) > 0): new_dir = os.path.dirname(new_path[0]) if (os.path.isdir(new_dir)): self.last_dir = new_dir else: new_path = dlg.GetPath() if (new_path != ""): self.last_dir = os.path.dirname(new_path) else: new_path = None wx.CallAfter(dlg.Destroy) return new_path else: wx.CallAfter(dlg.Destroy) raise Abort()
def run_function_as_process_in_dialog( parent, thread_function, title, message, callback=None, project_id=None, job_id=None): dlg = ProcessDialog( parent=parent, message=message, caption=title, callback=callback) setup_process_gui_events( window=dlg, OnExcept=dlg.OnError, OnComplete=dlg.OnComplete) cb = event_agent(dlg, project_id=project_id, job_id=job_id) p = thread_utils.process_with_callbacks( target=thread_function, callback_final=cb.callback_final, callback_err=cb.callback_error, buffer_stdout=True, sleep_after_start=1) result = None abort = False if (dlg.run(p) == wx.ID_OK): result = dlg.get_result() elif dlg.exception_raised(): dlg.handle_error() elif (dlg.was_aborted()): abort = True wx.CallAfter(dlg.Destroy) if (abort): raise Abort() return result
def merge_sequence_files (file_names, output_file, sequences=(), include_non_compliant=False, call_back_on_error=None, force_new_file=False) : assert (len(file_names) > 0) or (len(sequences) > 0) if (len(file_names)==1) and (len(sequences)==0) and (not force_new_file) : return file_names[0] seq_out = cStringIO.StringIO() for seq_file in file_names : objects, non_compliant = any_sequence_format(seq_file) if (objects is None) : msg = ("The file '%s' could not be parsed as one of the "+ "standard formats. This could either be a problem with the file, "+ "a non-standard format, or a bug in our code. For further help, "+ "please email the developers at [email protected].") % seq_file if (hasattr(call_back_on_error, "__call__")) : msg += " (This is not a fatal error, but the combined sequence "+\ "file will be incomplete.)" if (not call_back_on_error(msg)) : raise Abort() continue else : raise RuntimeError(msg) for seq_record in objects : name = str(seq_record.name) if (name == "") : name = "none" seq_out.write("> %s\n" % name) seq_out.write("%s\n" % seq_record.sequence) if (len(sequences) > 0) : for k, seq in enumerate(sequences) : seq_out.write("> seq%d\n" % (k+1)) seq_out.write("%s\n" % seq) f = open(output_file, "w") f.write(seq_out.getvalue()) f.close() return output_file
def Validate(self): # XXX why doesn't self.Validate() work? if self.GetValidator().Validate(self.GetParent()): return True else: raise Abort()
def _target_function07 (args, kwds, connection) : time.sleep(2) raise Abort()
class HKLViewFrame(wx.Frame): def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) self.parent = self.GetParent() self.view_2d = None self.view_3d = None # used by 2D subclass self.statusbar = self.CreateStatusBar() self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.miller_array = None app = wx.GetApp() if (getattr(app, "hklview_settings", None) is not None): # XXX copying the initial settings avoids awkward interactions when # multiple viewer windows are opened self.settings = copy.deepcopy(app.hklview_settings) else: self.settings = settings() self.create_settings_panel() self.sizer.Add(self.settings_panel, 0, wx.EXPAND) self.create_viewer_panel() self.sizer.Add(self.viewer, 1, wx.EXPAND | wx.ALL) self.SetupToolbar() self.SetupMenus() self.add_view_specific_functions() self.SetMenuBar(self.menubar) self.toolbar.Realize() self.SetSizerAndFit(self.sizer) self.SetMinSize(self.settings_panel.GetSize()) self.Bind(wx.EVT_CLOSE, self.OnClose, self) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self) self.Bind(wx.EVT_ACTIVATE, self.OnActive) self.viewer.SetFocus() def SetupToolbar(self): self.toolbar = self.CreateToolBar(style=wx.TB_3DBUTTONS | wx.TB_TEXT) self.toolbar.SetToolBitmapSize((32, 32)) btn = self.toolbar.AddLabelTool(id=-1, label="Load file", bitmap=icons.hkl_file.GetBitmap(), shortHelp="Load file", kind=wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnLoadFile, btn) btn = self.toolbar.AddLabelTool(id=-1, label="Save image", bitmap=icons.save_all.GetBitmap(), shortHelp="Save image", kind=wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnSave, btn) btn = self.toolbar.AddLabelTool( id=-1, label="Delete reflection", bitmap=bitmaps.fetch_icon_bitmap("actions", "editdelete"), # FIXME shortHelp="Delete reflection", kind=wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnDeleteReflection, btn) def SetupMenus(self): self.menubar = wx.MenuBar(-1) self.file_menu = wx.Menu() self.menubar.Append(self.file_menu, "File") item = wx.MenuItem(self.file_menu, -1, "Load data...\tCtrl-O") self.Bind(wx.EVT_MENU, self.OnLoadFile, item) self.file_menu.AppendItem(item) if (libtbx.env.has_module("phenix")): phenix_dir = os.path.dirname(libtbx.env.dist_path("phenix")) examples_dir = os.path.join(phenix_dir, "phenix_examples") if (os.path.isdir(examples_dir)): submenu = wx.Menu() self.file_menu.AppendSubMenu(submenu, "Load example data") examples_and_data = [ ("p9-sad", "p9.sca"), ("sec17-sad", "sec17.sca"), ("rnase-s", "rnase25.mtz"), ("porin-twin", "porin.mtz"), ] for subdir, data in examples_and_data: example_file = os.path.join(examples_dir, subdir, data) item = wx.MenuItem(submenu, -1, subdir) submenu.AppendItem(item) self.Bind(wx.EVT_MENU, lambda evt, f=example_file: self. load_reflections_file(f), item) def OnActive(self, event): if (self.IsShown()) and (type(self.viewer).__name__ != "_wxPyDeadObject"): self.viewer.Refresh() def create_viewer_panel(self): self.viewer = view_3d.hklview_3d(parent=self, size=(800, 600), style=wx.glcanvas.WX_GL_DOUBLEBUFFER) def create_settings_panel(self): self.settings_panel = settings_window(self, -1, style=wx.RAISED_BORDER) # print("I am printing type", type(self.settings_panel)) def add_view_specific_functions(self): item = wx.MenuItem(self.file_menu, -1, "Show 2D view") self.file_menu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnShow2D, item) btn = self.toolbar.AddLabelTool(id=-1, label="Show 2D view", bitmap=icons.hklview_2d.GetBitmap(), shortHelp="Show 2D view", kind=wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnShow2D, btn) btn = self.toolbar.AddLabelTool(id=-1, label="Clear labels", bitmap=icons.clear_left.GetBitmap(), shortHelp="Clear labels", kind=wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnClearLabels, btn) def update_clicked(self, index): #hkl, d_min=None, value=None) : if (index is None): self.settings_panel.clear_reflection_info() else: hkl, d_min, value = self.viewer.scene.get_reflection_info(index) self.settings_panel.update_reflection_info(hkl, d_min, value) def update_settings_for_unmerged(self): self.settings.expand_to_p1 = False self.settings.expand_anomalous = False self.settings_panel.get_control("expand_to_p1").SetValue(False) self.settings_panel.get_control("expand_to_p1").Enable(False) self.settings_panel.get_control("expand_anomalous").SetValue(False) self.settings_panel.get_control("expand_anomalous").Enable(False) self.settings_panel.get_control("scale_radii_multiplicity").Enable( False) def update_settings_for_merged(self, enable_multiplicity=False): self.settings_panel.get_control("expand_to_p1").Enable(True) self.settings_panel.get_control("expand_anomalous").Enable(True) if (enable_multiplicity): self.settings_panel.get_control("scale_radii_multiplicity").Enable( True) else: self.settings_panel.get_control("scale_radii_multiplicity").Enable( False) def process_miller_array(self, array): if (array is None): return if (array.is_hendrickson_lattman_array()): raise Sorry("Hendrickson-Lattman coefficients are not supported.") info = array.info() if isinstance(info, str): labels = "TEST DATA" else: labels = info.label_string() if (array.unit_cell() is None) or (array.space_group() is None): dlg = wxtbx.symmetry_dialog.SymmetryDialog(self, -1, "Enter symmetry") dlg.SetUnitCell(array.unit_cell()) dlg.SetSpaceGroup(array.space_group_info()) if (dlg.ShowModal() == wx.ID_OK): symm = dlg.GetSymmetry() array = array.customized_copy( crystal_symmetry=symm).set_info(info) wx.CallAfter(dlg.Destroy) details = [] merge = None if (not array.is_unique_set_under_symmetry()): merge = wx.MessageBox( "The data in the selected array are not symmetry-" + "unique, which usually means they are unmerged (but could also be due " + "to different indexing conventions). Do you want to merge equivalent " + "observations (preserving anomalous data if present), or view the " + "array unmodified? (Note that if you do not merge the array, the " + "options to expand to P1 or generate Friedel pairs will be be disabled" + ", and the 2D view will only show indices present in the file, rather " + "than a full pseudo-precession view.)", style=wx.YES_NO) if (merge == wx.YES): merge = True #array = array.merge_equivalents().array().set_info(info) details.append("merged") self.update_settings_for_merged(True) else: merge = False details.append("unmerged data") self.update_settings_for_unmerged() else: self.update_settings_for_merged() if array.is_complex_array(): array = array.amplitudes().set_info(info) details.append("as amplitudes") from iotbx.reflection_file_utils import looks_like_r_free_flags_info if (array.is_integer_array()) and (looks_like_r_free_flags_info(info)): from iotbx.reflection_file_utils import get_r_free_flags_scores score_array = get_r_free_flags_scores([array], None) test_flag_value = score_array.test_flag_values[0] array = array.customized_copy( data=(array.data() == test_flag_value)) array.set_info(info) sg = "%s" % array.space_group_info() uc = "a=%g b=%g c=%g angles=%g,%g,%g" % array.unit_cell().parameters() details_str = "" if (len(details) > 0): details_str = "(%s)" % ", ".join(details) array_info = group_args(labels=labels, details_str=details_str, merge=merge, sg=sg, uc=uc) return array, array_info def set_miller_array(self, array): if (array is None): return array, array_info = self.process_miller_array(array) self.statusbar.SetStatusText( "Data: %s %s (Space group: %s Unit Cell: %s)" % (array_info.labels, array_info.details_str, array_info.sg, array_info.uc)) self.settings_panel.d_min_ctrl.SetValue(array.d_min()) self.settings_panel.d_min_ctrl.SetRange(array.d_min(), 20.0) ##kau added starts # self.settings_panel.IoverSigI_ctrl.SetValue(array.sigma_filter(0.0).d_min()) # self.settings_panel.IoverSigI_ctrl.SetRange(array.sigma_filter(0.5).d_min(), 100.0) self.settings_panel.IoverSigI_ctrl.SetValue(0.0) self.settings_panel.IoverSigI_ctrl.SetRange(0.0, 100.0) ##Kau added ends self.settings_panel.set_index_span(array.index_span()) self.settings_panel.update_space_group_choices(array) # self.settings_panel.update_column_choices(array) # kau added if (type(self).__name__ == "HKLViewFrame"): if (array.indices().size() > 100000): if (self.settings.spheres): cnf = wx.MessageBox( message="Warning: this is a lot of reflections; " + "unless you have a very powerful graphics card, displaying " + "spheres may be slow and/or unstable, especially if data are " + "expanded to P1. Do you want to switch to a faster rendering " + "style?", style=wx.YES | wx.NO) if (cnf == wx.YES): self.settings.spheres = False self.settings_panel.spheres_ctrl.SetValue(False) self.miller_array = array # print("kau this is array ",type(array)) self.viewer.set_miller_array(array, zoom=True, merge=array_info.merge) self.viewer.Refresh() if (self.view_2d is not None): self.view_2d.set_miller_array(array) def update_settings(self, *args, **kwds): if (self.miller_array is None): return False self.viewer.update_settings(*args, **kwds) def set_space_group(self, space_group_info): # print("kau printing space_group_info ", space_group_info) if (self.miller_array is None): raise Sorry("No data loaded!") from cctbx import crystal symm = crystal.symmetry(space_group_info=space_group_info, unit_cell=self.miller_array.unit_cell()) array = self.miller_array.expand_to_p1().customized_copy( crystal_symmetry=symm) print "MERGING 2" array = array.merge_equivalents().array().set_info( self.miller_array.info()) self.viewer.set_miller_array(array, zoom=False) self.viewer.Refresh() #kau added starts here def set_column(self, column_sel): # print("kau printing column_sel ", column_sel) self.set_miller_array(self.valid_arrays[column_sel]) if (self.miller_array is None): raise Sorry("No data loaded!") # from cctbx import crystal # symm = crystal.symmetry( # space_group_info=space_group_info, # unit_cell=self.miller_array.unit_cell()) # array = self.miller_array.expand_to_p1().customized_copy( # crystal_symmetry=symm) # print "MERGING 2" # array = array.merge_equivalents().array().set_info(self.miller_array.info()) # array=self.miller_array.column_root_label(column_sel) # print("Kau this is array from set_column ", array) # settings_panel.array_storage() # self.viewer.set_miller_array(array[column_sel], zoom=False) self.viewer.Refresh() ##kau added ends here def delete_miller_index(self, hkl): if (self.miller_array is None): raise Sorry("No data loaded!") info = self.miller_array.info() self.miller_array = self.miller_array.delete_index(hkl).set_info(info) self.viewer.set_miller_array(self.miller_array, zoom=True) self.viewer.Refresh() def load_reflections_file(self, file_name, set_array=True, data_only=False): file_name = to_str(file_name) if (file_name != ""): from iotbx.reflection_file_reader import any_reflection_file from iotbx.gui_tools.reflections import get_array_description try: hkl_file = any_reflection_file(file_name) except Exception, e: raise Sorry(to_str(e)) arrays = hkl_file.as_miller_arrays( merge_equivalents=False, ) #observation_type_callback=misc_dialogs.get_shelx_file_data_type) #arrays = f.file_server.miller_arrays valid_arrays = [] array_info = [] for array in arrays: if array.is_hendrickson_lattman_array(): continue elif (data_only): if (not array.is_real_array()) and ( not array.is_complex_array()): continue labels = array.info().label_string() desc = get_array_description(array) array_info.append("%s (%s)" % (labels, desc)) valid_arrays.append(array) self.valid_arrays = valid_arrays if (len(valid_arrays) == 0): msg = "No arrays of the supported types in this file." raise Sorry(msg) elif (len(valid_arrays) == 1): if (set_array): self.set_miller_array(valid_arrays[0]) return valid_arrays[0] else: #dlg = SelectArrayDialog(self, -1, "Select data") dlg = wx.SingleChoiceDialog( parent=None, message="Please select the data you wish to view:", caption="Select data", choices=array_info) # print("kau labels info is", array_info) #Kau added # print("Kau printing array_info from calling ", array_info) if (dlg.ShowModal() == wx.ID_OK): sel = dlg.GetSelection() if (set_array): self.set_miller_array(valid_arrays[sel]) wx.CallAfter(dlg.Destroy) self.settings_panel.update_column_choices( array_info, valid_arrays, sel) # kau added # self.settings_panel.update_column_choices(array_info,valid_arrays,sel) # kau added return valid_arrays[sel] wx.CallAfter(dlg.Destroy) raise Abort()
def run(self): '''Execute the script.''' from dxtbx.datablock import DataBlockTemplateImporter from dials.util.options import flatten_datablocks from dials.util import log from logging import info from time import time from libtbx.utils import Abort # Parse the command line params, options = self.parser.parse_args(show_diff_phil=False) datablocks = flatten_datablocks(params.input.datablock) # Check we have some filenames if len(datablocks) == 0: # Check if a template has been set and print help if not, otherwise try to # import the images based on the template input if len(params.input.template) == 0: self.parser.print_help() exit(0) else: importer = DataBlockTemplateImporter(params.input.template, options.verbose) datablocks = importer.datablocks # Save the options self.options = options self.params = params self.load_reference_geometry() st = time() # Import stuff if len(datablocks) == 0: raise Abort('No datablocks specified') elif len(datablocks) > 1: raise Abort('Only 1 datablock can be processed at a time.') datablock = datablocks[0] if self.reference_detector is not None: for imageset in datablock.extract_imagesets(): imageset.set_detector(self.reference_detector) # Configure logging log.config(params.verbosity, info='dials.process.log', debug='dials.process.debug.log') # Log the diff phil diff_phil = self.parser.diff_phil.as_str() if diff_phil is not '': info('The following parameters have been modified:\n') info(diff_phil) if self.params.output.datablock_filename: from dxtbx.datablock import DataBlockDumper dump = DataBlockDumper(datablock) dump.as_json(self.params.output.datablock_filename) # Do the processing observed = self.find_spots(datablock) experiments, indexed = self.index(datablock, observed) experiments, indexed = self.refine(experiments, indexed) integrated = self.integrate(experiments, indexed) # Total Time info("") info("Total Time Taken = %f seconds" % (time() - st))