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 self.viewer.isnewfile = True #self.params.NGL_HKLviewer.mergedata = None self.viewer.iarray = -1 self.viewer.colour_scene_id = -1 self.viewer.radii_scene_id = -1 self.viewer.match_valarrays = [] self.viewer.proc_arrays = [] self.spacegroup_choices = [] display.reset_settings() self.settings = display.settings() self.viewer.settings = self.params.NGL_HKLviewer.viewer self.viewer.mapcoef_fom_dict = {} try: hkl_file = any_reflection_file(file_name) 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 except Exception as e: self.NewFileLoaded = False self.mprint(to_str(e)) arrays = [] valid_arrays = [] self.array_infostrs = [] self.array_infotpls = [] 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()) \ and (not array.is_integer_array()) and (not array.is_bool_array()) : self.mprint('Ignoring miller array \"%s\" of %s' \ %(array.info().label_string(), type(array.data()[0]) ) ) continue self.array_infostrs.append( ArrayInfo(array, self.mprint).infostr) self.array_infotpls.append( ArrayInfo(array, self.mprint).infotpl) valid_arrays.append(array) self.valid_arrays = valid_arrays self.mprint("Miller arrays in this file:") for e in self.array_infostrs: self.mprint("%s" % e) self.NewFileLoaded = True if (len(valid_arrays) == 0): msg = "No arrays of the supported types in this file." self.mprint(msg) self.NewFileLoaded = False return False elif (len(valid_arrays) >= 1): if (set_array): self.set_miller_array() return True
def prepare_dataloading(self): self.viewer.isnewfile = True #self.params.mergedata = None self.params.viewer.scene_id = None self.viewer.colour_scene_id = None self.viewer.radii_scene_id = None self.viewer.match_valarrays = [] self.viewer.proc_arrays = {} self.spacegroup_choices = [] self.origarrays = {} display.reset_settings() self.settings = display.settings() self.viewer.settings = self.params.viewer self.viewer.mapcoef_fom_dict = {} self.viewer.sceneid_from_arrayid = [] self.hklfile_history = [] self.tncsvec = None self.loaded_file_name = ""
def LoadReflectionsFile(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 self.viewer.isnewfile = True self.viewer.iarray = 0 self.viewer.icolourcol = 0 self.viewer.iradiicol = 0 display.reset_settings() self.settings = display.settings() self.viewer.settings = self.settings self.viewer.mapcoef_fom_dict = {} 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 = [] self.array_info = [] for array in arrays: #if array.is_hendrickson_lattman_array() : # continue #elif (data_only) : if (data_only): if (not array.is_real_array()) and ( not array.is_complex_array()): continue self.array_info.append(ArrayInfo(array).infostr) valid_arrays.append(array) self.valid_arrays = valid_arrays for i, e in enumerate(self.array_info): self.mprint("%d, %s" % (i, e)) 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]
def load_reflections_file(self, file_name, set_array=True, data_only=False): file_name = to_str(file_name) if (file_name != ""): self.mprint("Reading file...") from iotbx.reflection_file_reader import any_reflection_file self.viewer.isnewfile = True #self.params.NGL_HKLviewer.mergedata = None self.params.NGL_HKLviewer.viewer.scene_id = None self.viewer.colour_scene_id = None self.viewer.radii_scene_id = None self.viewer.match_valarrays = [] self.viewer.proc_arrays = [] self.spacegroup_choices = [] display.reset_settings() self.settings = display.settings() self.viewer.settings = self.params.NGL_HKLviewer.viewer self.viewer.mapcoef_fom_dict = {} self.hklfile_history = [] self.tncsvec = None try : hkl_file = any_reflection_file(file_name) 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 if hkl_file._file_type == 'ccp4_mtz': self.hklfile_history = list(hkl_file._file_content.history()) for e in self.hklfile_history: if "TNCS NMOL" in e and "VECTOR" in e: svec = e.split()[-3:] t1 = float(svec[0]) t2 = float(svec[1]) t3 = float(svec[2]) if (t1*t1 + t2*t2 + t3*t3) > 0.0: self.tncsvec = [ t1, t2, t3 ] self.mprint("tNCS vector found in header of mtz file: %s" %str(svec) ) except Exception as e : self.NewFileLoaded=False self.mprint(to_str(e)) arrays = [] valid_arrays = [] self.viewer.array_infostrs = [] self.viewer.array_infotpls = [] 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()) \ and (not array.is_integer_array()) and (not array.is_bool_array()) : self.mprint('Ignoring miller array \"%s\" of %s' \ %(array.info().label_string(), type(array.data()[0]) ) ) continue self.viewer.array_infostrs.append( ArrayInfo(array, self.mprint).infostr ) self.viewer.array_infotpls.append( ArrayInfo(array, self.mprint).infotpl ) valid_arrays.append(array) self.valid_arrays = valid_arrays self.mprint("Miller arrays in this file:") for e in self.viewer.array_infostrs: self.mprint("%s" %e) self.mprint("\n") self.NewFileLoaded = True if (len(valid_arrays) == 0): msg = "No arrays of the supported types in this file." self.mprint(msg) self.NewFileLoaded=False return False elif (len(valid_arrays) >= 1): if (set_array): self.set_miller_array() self.viewer.superset_all_miller_arrays() mydict = { "info": self.infostr, "array_infotpls": self.viewer.array_infotpls, "bin_infotpls": self.viewer.bin_infotpls, "html_url": self.viewer.url, "tncsvec": self.tncsvec, "merge_data": self.params.NGL_HKLviewer.merge_data, "spacegroups": [e.symbol_and_number() for e in self.spacegroup_choices], "NewFileLoaded": self.NewFileLoaded } self.SendInfoToGUI(mydict) return True