def OnBrowse (self, event) : flags = 0 if (self._path_style & WXTBX_PHIL_PATH_SAVE) : flags |= wx.FD_SAVE|wx.OVERWRITE_PROMPT else : flags |= wx.FD_OPEN path_manager = self.GetPathManager() new_path = None if (self._path_style & WXTBX_PHIL_PATH_DIRECTORY) : new_path = path_manager.select_directory( message="Choose a directory: %s" % self.GetName(), current_path=to_unicode(self.GetValue()), style=flags|wx.DD_NEW_DIR_BUTTON, parent=self) else : from iotbx import file_reader wildcard = file_reader.get_wildcard_strings(self._formats) new_path = path_manager.select_file( parent=self, message="Choose a file: %s" % self.GetName(), current_file=to_unicode(self.GetValue()), style=flags, wildcard=wildcard) if (new_path is not None) : if ('}' in new_path) or ('{' in new_path) : raise Sorry("Curly brackets ({}) are not allowed in pathnames.") self.SetValue(new_path) self.DoSendEvent()
def set_file (self, file_name) : self.file_name = os.path.abspath(file_name) from iotbx import file_reader import iotbx.pdb self._pdb_in = file_reader.any_file(file_name, force_type="pdb", raise_sorry_if_errors=True, raise_sorry_if_not_expected_format=True) self._pdb_in.check_file_type("pdb") self._hierarchy = self._pdb_in.file_object.hierarchy info_list = iotbx.pdb.show_file_summary( pdb_in=self._pdb_in.file_object, hierarchy=self._hierarchy) self.SetTitle("Info for %s" % to_unicode(self.file_name)) self.file_txt.SetLabel(to_unicode(self.file_name)) if (self.info_panel is not None) : self.panel_sizer.Detach(self.info_panel) self.info_panel.Destroy() self.info_panel = wx.Panel(self.panel, -1) self.panel_sizer.Add(self.info_panel, 1, wx.ALL|wx.EXPAND) szr = wx.BoxSizer(wx.VERTICAL) self.info_panel.SetSizer(szr) box = wx.StaticBox(self.info_panel, -1, "File contents:") box_szr = wx.StaticBoxSizer(box, wx.VERTICAL) szr.Add(box_szr, 1, wx.EXPAND|wx.ALL, 5) grid = wx.FlexGridSizer(cols=2) box_szr.Add(grid, 1, wx.EXPAND) for label, value in info_list : txt1 = wx.StaticText(self.info_panel, -1, label + ":") font = txt1.GetFont() font.SetWeight(wx.FONTWEIGHT_BOLD) txt1.SetFont(font) grid.Add(txt1, 0, ALN_FLAGS, 5) str_value = to_str(value) alert = False if (str_value.endswith("***")) : str_value = re.sub("\s*\*\*\*", "", str_value) alert = True txt2 = wx.StaticText(self.info_panel, -1, str_value) font2 = txt2.GetFont() font2.SetFamily(wx.FONTFAMILY_MODERN) if (alert) : font2.SetWeight(wx.FONTWEIGHT_BOLD) txt2.SetForegroundColour((200,0,0)) txt1.SetForegroundColour((200,0,0)) txt2.SetFont(font2) grid.Add(txt2, 0, ALN_FLAGS, 5) if (len(self._hierarchy.models()) == 1) : if (len(self._hierarchy.models()[0].chains()) > 1) : btn = wx.Button(self.info_panel, -1, "B-factors by chain...") szr.Add(btn, 0, wx.ALL, 5) self.Bind(wx.EVT_BUTTON, self.OnShowChainBstats, btn) szr.Fit(self.info_panel) self.panel.Layout() self.panel_sizer.Fit(self.panel) self.Fit()
def set_file (self, file_name) : self.file_name = os.path.abspath(file_name) from iotbx import file_reader self._hkl_in = file_reader.any_file(file_name, force_type="hkl", raise_sorry_if_errors=True, raise_sorry_if_not_expected_format=True) self._hkl_in.check_file_type("hkl") self.SetTitle("Info for %s" % to_unicode(self.file_name)) self.file_txt.SetLabel(to_unicode(self.file_name)) self.miller_arrays = self._hkl_in.file_server.miller_arrays labels = [ array.info().label_string() for array in self.miller_arrays ] self.array_choice.SetItems(labels) self.array_choice.SetSelection(0) self.set_miller_array(labels[0])
def load_image (self, file_name_or_data) : """The load_image() function displays the image from @p file_name_or_data. The chooser is updated appropriately. """ key = self.get_key(file_name_or_data) if (type(file_name_or_data) is dict) : self._img = rstbx.viewer.image(file_name_or_data) else : try : self._img = rstbx.viewer.image(key) except IOError : raise Sorry(("The file '%s' could not be recognized as a supported "+ "image format; please make sure it is actually a detector image.") % key) # Update the selection in the chooser. i = self.add_file_name_or_data(file_name_or_data) self.image_chooser.SetSelection(i) self.viewer.set_image(self._img) if (self.settings_frame is not None) : self.settings_frame.set_image(self._img) self.SetTitle(to_unicode(key)) self.update_statusbar() self.Layout()
def AppendText (self, text) : if UNICODE_BUILD : text = to_unicode(text) self.SetFont(wx.Font(self.font_size, wx.MODERN, wx.NORMAL, wx.NORMAL)) wx.TextCtrl.AppendText(self, text) # keep text to be a certain size for performance if (self.GetLastPosition() > self.character_limit): self.Remove(0,len(text))
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 set_file (self, file_name) : self.file_name = os.path.abspath(file_name) from iotbx import file_reader img_in = file_reader.any_file( file_name=file_name, valid_types=["img"], force_type="img", raise_sorry_if_errors=True, raise_sorry_if_not_expected_format=True) img_in.assert_file_type("img") self._img_in = img_in out = cStringIO.StringIO() img_in.file_object.show_header() img_in.file_object.show_header(out=out) self.SetTitle("Info for %s" % to_unicode(self.file_name)) self.file_txt.SetLabel(to_unicode(self.file_name)) if (self.info_panel is not None) : self.panel_sizer.Detach(self.info_panel) self.info_panel.Destroy() self.info_panel = wx.Panel(self.panel, -1) self.panel_sizer.Add(self.info_panel, 1, wx.ALL|wx.EXPAND) szr = wx.BoxSizer(wx.VERTICAL) self.info_panel.SetSizer(szr) box = wx.StaticBox(self.info_panel, -1, "File contents:") box_szr = wx.StaticBoxSizer(box, wx.VERTICAL) szr.Add(box_szr, 1, wx.EXPAND|wx.ALL, 5) grid = wx.FlexGridSizer(cols=2) box_szr.Add(grid, 1, wx.EXPAND) for line in out.getvalue().splitlines()[1:] : label, value = line.strip().split(":") txt1 = wx.StaticText(self.info_panel, -1, label + ":") font = txt1.GetFont() font.SetWeight(wx.FONTWEIGHT_BOLD) txt1.SetFont(font) grid.Add(txt1, 0, ALN_FLAGS, 5) txt2 = wx.StaticText(self.info_panel, -1, value) font2 = txt2.GetFont() font2.SetFamily(wx.FONTFAMILY_MODERN) txt2.SetFont(font2) grid.Add(txt2, 0, ALN_FLAGS, 5) szr.Fit(self.info_panel) self.panel.Layout() self.panel_sizer.Fit(self.panel) self.Fit()
def set_file (self, file_name, hierarchy=None) : self.file_name = os.path.abspath(file_name) from scitbx.array_family import flex if (hierarchy is None) : from iotbx import file_reader import iotbx.pdb pdb_in = file_reader.any_file(file_name, force_type="pdb", raise_sorry_if_errors=True, raise_sorry_if_not_expected_format=True) pdb_in.check_file_type("pdb") hierarchy = pdb_in.file_object.hierarchy if (len(hierarchy.models()) > 1) : raise Sorry("Multi-MODEL PDB files not supported.") self._hierarchy = hierarchy self.SetTitle("B-factors by chain for %s" % to_unicode(self.file_name)) self.file_txt.SetLabel(to_unicode(self.file_name)) chain_list = wx.ListCtrl(self.panel, -1, style=wx.LC_REPORT, size=(480,160)) chain_list.InsertColumn(0, "Chain info") chain_list.InsertColumn(1, "Mean B-iso (range)") chain_list.SetColumnWidth(0, 260) chain_list.SetColumnWidth(1, 200) for chain in hierarchy.models()[0].chains() : n_res = len(chain.residue_groups()) chain_atoms = chain.atoms() n_atoms = len(chain_atoms) main_conf = chain.conformers()[0] chain_type = "other" if (main_conf.is_protein()) : chain_type = "protein" elif (main_conf.is_na()) : chain_type = "nucleic acid" chain_info = "'%s' (%s, %d res., %d atoms)" % (chain.id, chain_type, n_res, n_atoms) b_iso = chain_atoms.extract_b() b_max = flex.max(b_iso) b_min = flex.min(b_iso) b_mean = flex.mean(b_iso) b_info = "%.2f (%.2f - %.2f)" % (b_mean, b_min, b_max) item = chain_list.InsertStringItem(sys.maxint, chain_info) chain_list.SetStringItem(item, 1, b_info) self.panel_sizer.Add(chain_list, 1, wx.EXPAND|wx.ALL, 5) self.panel.Layout() self.panel_sizer.Fit(self.panel) self.Fit()
def warn (self, message) : if (not isinstance(message, (six.text_type, six.binary_type))) : message = to_unicode(message) self.__call__(message="warn", data=message, accumulate=True, cached=True) if (self._log is not None) : log = self._log else : log = sys.stdout msg = "WARNING: %s\n" % message print("", file=log) for line in str_utils.line_breaker(msg, 72) : print(" " + line, file=log)
def select_directory(self, parent, message, current_path, style): default_path = self.last_dir if (current_path is not None) and (current_path != ""): default_path = current_path default_path = to_unicode(default_path) new_path = wx.DirSelector(message=message, defaultPath=default_path, style=style | wx.DD_NEW_DIR_BUTTON, parent=parent) if (new_path != ""): return new_path return None
def Validate(self, parent): self.ctrl = self.GetWindow() self.parent = parent try: raw_value = self.ctrl.GetValue() adj_value = self.parent.ReformatValue(value=raw_value) value = self.CheckFormat(value=adj_value) if type(value) in (list, tuple): reformatted = to_unicode(' '.join([str(v) for v in value])) else: reformatted = to_unicode(str(value)) except UnicodeEncodeError: self.ctrl.error_msg = "Only the standard UTF-8 character set is allowed." return False except Exception as e: self.ctrl.error_msg = str(e) return False else: self.ctrl.error_msg = None self.ctrl.SetValue(reformatted) return True
def SetValue (self, value) : if (value in [None, Auto]) : ValidatedTextCtrl.SetValue(self, "") else : if isinstance(value, str) : if wxtbx.is_unicode_build() : ValidatedTextCtrl.SetValue(self, to_unicode(value)) else : ValidatedTextCtrl.SetValue(self, value) else : if (not isinstance(value, unicode)) : raise RuntimeError("Improper value (type: %s) for control %s" % (type(value).__name__, self.GetName())) ValidatedTextCtrl.SetValue(self, value)
def show_text (self, text) : """ Create wx.StaticText object(s) with automatic wrapping. Double-newlines will be treated as paragraph breaks, otherwise newlines are replaced by spaces. """ assert (self._current_panel is not None) blocks = text.split("\n\n") for block in blocks : block = " ".join([ l.strip() for l in block.splitlines() ]).strip() wxtxt = wx.StaticText(parent=self._current_panel, label=to_unicode(block)) wxtxt.Wrap(TEXT_WIDTH) self._current_sizer.Add(wxtxt, 0, wx.ALL, 5)
def show_text(self, text): """ Create wx.StaticText object(s) with automatic wrapping. Double-newlines will be treated as paragraph breaks, otherwise newlines are replaced by spaces. """ assert (self._current_panel is not None) blocks = text.split("\n\n") for block in blocks: block = " ".join([l.strip() for l in block.splitlines()]).strip() wxtxt = wx.StaticText(parent=self._current_panel, label=to_unicode(block)) wxtxt.Wrap(TEXT_WIDTH) self._current_sizer.Add(wxtxt, 0, wx.ALL, 5)
def SetValue(self, value): if (value in [None, Auto]): ValidatedTextCtrl.SetValue(self, "") else : if isinstance(value, str): if wxtbx.is_unicode_build(): ValidatedTextCtrl.SetValue(self, to_unicode(value)) else : ValidatedTextCtrl.SetValue(self, value) else : if (not isinstance(value, unicode)): raise RuntimeError("Improper value (type: %s) for control %s" % (type(value).__name__, self.GetName())) ValidatedTextCtrl.SetValue(self, value)
def Validate(self, win): ctrl = self.GetWindow() try : value = to_unicode(ctrl.GetValue()) # if isinstance(value, str): # value = value.decode("utf-8") if (value == ""): ctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) return True reformatted = self.CheckFormat(value) if isinstance(reformatted, str): reformatted = to_unicode(reformatted) ctrl.SetValue(reformatted) ctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) #ctrl.SetFocus() ctrl.Refresh() return True except NotImplementedError : raise except Exception, e : ctrl_name = str(ctrl.GetName()) msg = "Inappropriate value given for \"%s\": %s" %(ctrl_name,str(e)) if (type(e).__name__ == "UnicodeEncodeError"): msg = ("You have entered characters which cannot be converted to "+ "Latin characters in the control '%s'; due to limitations of the "+ "underlying code, only the standard UTF-8 character set is "+ "allowed.") % ctrl_name wx.MessageBox(caption="Format error", message=msg) ctrl.SetBackgroundColour("red") # Don't set focus on Windows since messagebox is modal and thus # would automatically recapture focus leading to an endless UI loop if (sys.platform != 'win32'): ctrl.SetFocus() ctrl.Refresh() return False
def Validate (self, win) : ctrl = self.GetWindow() try : value = to_unicode(ctrl.GetValue()) # if isinstance(value, str) : # value = value.decode("utf-8") if (value == "") : ctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) return True reformatted = self.CheckFormat(value) if isinstance(reformatted, str) : reformatted = to_unicode(reformatted) ctrl.SetValue(reformatted) ctrl.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) #ctrl.SetFocus() ctrl.Refresh() return True except NotImplementedError : raise except Exception, e : ctrl_name = str(ctrl.GetName()) msg = "Inappropriate value given for \"%s\": %s" %(ctrl_name,str(e)) if (type(e).__name__ == "UnicodeEncodeError") : msg = ("You have entered characters which cannot be converted to "+ "Latin characters in the control '%s'; due to limitations of the "+ "underlying code, only the standard UTF-8 character set is "+ "allowed.") % ctrl_name wx.MessageBox(caption="Format error", message=msg) ctrl.SetBackgroundColour("red") # Don't set focus on Windows since messagebox is modal and thus # would automatically recapture focus leading to an endless UI loop if (sys.platform != 'win32'): ctrl.SetFocus() ctrl.Refresh() return False
def plot_table_text(self, data): data = [[to_unicode(i) for i in j] for j in data] stripes = zip(*data) col_ws = [max([len(i) for i in strp]) for strp in stripes] set_ws = [5 if i <= 3 else i + 2 for i in col_ws] lines = [] for item in data: for i in item: idx = item.index(i) width = set_ws[idx] item[idx] = i.ljust(width, u' ') line = u''.join(item) lines.append(line) table_txt = u'\n'.join(lines) return table_txt
def select_directory (self, parent, message, current_path, style) : default_path = self.last_dir if (current_path is not None) and (current_path != "") : default_path = current_path default_path = to_unicode(default_path) new_path = wx.DirSelector( message=message, defaultPath=default_path, style=style|wx.DD_NEW_DIR_BUTTON, parent=parent) if (new_path != "") : return new_path return None
def __init__ (self, *args, **kwds) : saved_value = None if (kwds.get('value', "") != ""): saved_value = kwds['value'] kwds['value'] = "" super(ValidatedTextCtrl, self).__init__(*args, **kwds) font = wx.Font(wxtbx.default_font_size, wx.MODERN, wx.NORMAL, wx.NORMAL) self.SetFont(font) style = self.GetWindowStyle() if (not style & wx.TE_PROCESS_ENTER) : style |= wx.TE_PROCESS_ENTER self.SetWindowStyle(style) self.SetValidator(self.CreateValidator()) self.Bind(wx.EVT_TEXT_ENTER, self.OnEnter, self) self.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self) if saved_value is not None: if (type(saved_value) == str): save_value = to_unicode(saved_value) self.SetValue(saved_value)
def __init__(self, *args, **kwds): saved_value = None if (kwds.get('value', "") != ""): saved_value = kwds['value'] kwds['value'] = "" super(ValidatedTextCtrl, self).__init__(*args, **kwds) font = wx.Font(wxtbx.default_font_size, wx.MODERN, wx.NORMAL, wx.NORMAL) self.SetFont(font) style = self.GetWindowStyle() if (not style & wx.TE_PROCESS_ENTER): style |= wx.TE_PROCESS_ENTER self.SetWindowStyle(style) self.SetValidator(self.CreateValidator()) self.Bind(wx.EVT_TEXT_ENTER, self.OnEnter, self) self.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self) if saved_value is not None: if (type(saved_value) == str): save_value = to_unicode(saved_value) self.SetValue(saved_value)
def set_file(self, file_name): self.file_txt.SetLabel(to_unicode(file_name))
def set_file (self, file_name) : self.file_txt.SetLabel(to_unicode(file_name))
def SetValue(self, value): if (value is None) or (value is Auto): self._path_text.SetValue("") else : value = to_unicode(value) self._path_text.SetValue(value)
def WriteText (self, text) : if UNICODE_BUILD : text = to_unicode(text) self.SetFont(wx.Font(self.font_size, wx.MODERN, wx.NORMAL, wx.NORMAL)) wx.TextCtrl.WriteText(self, text)
def SetValue (self, value) : if (value is None) or (value is Auto) : self._path_text.SetValue("") else : value = to_unicode(value) self._path_text.SetValue(value)
def table_one(self): ''' Constructs Table 1 for GUI or logging ''' A = u'\N{ANGSTROM SIGN}' d = u'\N{DEGREE SIGN}' a = u'\N{GREEK SMALL LETTER ALPHA}' b = u'\N{GREEK SMALL LETTER BETA}' g = u'\N{GREEK SMALL LETTER GAMMA}' s = u'\N{GREEK SMALL LETTER SIGMA}' h = u'\u00BD' uc_edges = '{:4.2f}, {:4.2f}, {:4.2f}'.format(self.info['mean_a'][-1], self.info['mean_b'][-1], self.info['mean_c'][-1]) uc_angles = '{:4.2f}, {:4.2f}, {:4.2f}'.format(self.info['mean_alpha'][-1], self.info['mean_beta'][-1], self.info['mean_gamma'][-1]) res_total = '{:4.2f} - {:4.2f}'.format(self.info['total_res_max'][-1], self.info['total_res_min'][-1]) res_last_shell = '{:4.2f} - {:4.2f}' \ ''.format(self.info['binned_resolution'][-1][-1], self.info['binned_resolution'][-1][-2]) t1_rlabels = [u.to_unicode(u'No. of images'), u.to_unicode(u'Space Group'), u.to_unicode(u'Cell dimensions'), u.to_unicode(u' a, b, c ({}) '.format(A)), u.to_unicode(u' {}, {}, {} ({}) '.format(a, b, g, d)), u.to_unicode(u'Resolution ({}) '.format(A)), u.to_unicode(u'Completeness (%)'), u.to_unicode(u'Multiplicity'), u.to_unicode(u'I / {}(I) '.format(s)), u.to_unicode(u'CC{} '.format(h)), u.to_unicode(u'R_merge')] t1_data = [['{}'.format(self.info['n_frames_good'][-1])], ['{}'.format(self.info['space_group_info'][ -1].symbol_and_number())], [''], ['{}'.format(uc_edges)], ['{}'.format(uc_angles)], ['{} ({})'.format(res_total, res_last_shell)], ['{:4.2f} ({:4.2f})'.format(self.info['total_completeness'][-1], self.info['binned_completeness'][-1][-1])], ['{:4.2f} ({:4.2f})'.format(self.info['total_n_obs'][-1], self.info['binned_n_obs'][-1][-1])], ['{:4.2f} ({:4.2f})'.format(self.info['total_i_o_sigi'][-1], self.info['binned_i_o_sigi'][-1][-1])], ['{:4.2f} ({:4.2f})'.format(self.info['total_cc12'][-1], self.info['binned_cc12'][-1][-1])], ['{:4.2f} ({:4.2f})'.format(self.info['total_rmerge'][-1], self.info['binned_rmerge'][-1][-1])] ] return t1_rlabels, t1_data
def __init__(self, path, find_unused_imports=False, find_bad_indentation=True, flag_absolute_import=False, flag_print_function=False): self.path = path self.is_executable = os.access(path, os.X_OK) self.dos_format = False self.n_tabs_or_trailing_whitespace = [] self.n_trailing_empty_lines = 0 self.missing_eol = False self.n_bare_excepts = 0 self.unused_imports = None self.n_from_future_import_division = -1 self.flag_absolute_import = flag_absolute_import self.n_from_future_import_absolute_import = -1 self.flag_print_function = flag_print_function self.n_from_future_import_print_function = -1 self.bad_indentation = None self.file_should_be_empty = False if self.ignore_file(): return bytes = to_unicode(open(path, "rb").read()) if (len(bytes) > 0): if (bytes[-1] != "\n"): self.missing_eol = True else: bytes = bytes[:-1] text = bytes.split("\n") for i, line in enumerate(text): if (line.endswith("\r")): line = line[:-1] self.dos_format = True clean_line = line.expandtabs().rstrip() if (clean_line != line): self.n_tabs_or_trailing_whitespace.append(i+1) if (len(clean_line) == 0): self.n_trailing_empty_lines += 1 else: self.n_trailing_empty_lines = 0 if (path.endswith(".py")): self.n_from_future_import_division = 0 self.n_from_future_import_absolute_import = 0 self.n_from_future_import_print_function = 0 py_lines = bytes.splitlines() self.file_should_be_empty = True for line in py_lines: if self.file_should_be_empty and line.strip() != '' and not self.from_future_pat.search(line): self.file_should_be_empty = False if self.from_future_import_division_pat.search(line): self.n_from_future_import_division += 1 if self.from_future_import_absolute_import_pat.search(line): self.n_from_future_import_absolute_import += 1 if self.from_future_import_print_function_pat.search(line): self.n_from_future_import_print_function += 1 ls = line.strip() if ( ls.startswith("except") and ls[6:].strip().startswith(":") and not ls.endswith(" # intentional")): self.n_bare_excepts += 1 if (find_unused_imports and path.endswith(".py")): self.unused_imports = find_unused_imports_crude.inspect( py_lines=py_lines) if (find_bad_indentation) : self.bad_indentation = detect_indentation_problems(path)
def table_one(self): ''' Constructs Table 1 for GUI or logging ''' A = u'\N{ANGSTROM SIGN}' d = u'\N{DEGREE SIGN}' a = u'\N{GREEK SMALL LETTER ALPHA}' b = u'\N{GREEK SMALL LETTER BETA}' g = u'\N{GREEK SMALL LETTER GAMMA}' s = u'\N{GREEK SMALL LETTER SIGMA}' h = u'\u00BD' uc_edges = '{:4.2f}, {:4.2f}, {:4.2f}'.format(self.info['mean_a'][-1], self.info['mean_b'][-1], self.info['mean_c'][-1]) uc_angles = '{:4.2f}, {:4.2f}, {:4.2f}'.format( self.info['mean_alpha'][-1], self.info['mean_beta'][-1], self.info['mean_gamma'][-1]) res_total = '{:4.2f} - {:4.2f}'.format(self.info['total_res_max'][-1], self.info['total_res_min'][-1]) res_last_shell = '{:4.2f} - {:4.2f}' \ ''.format(self.info['binned_resolution'][-1][-2], self.info['binned_resolution'][-1][-1]) t1_rlabels = [ u.to_unicode(u'No. of accepted images'), u.to_unicode(u'No. of rejected images'), u.to_unicode(u'Space Group'), u.to_unicode(u'Cell dimensions'), u.to_unicode(u' a, b, c ({}) '.format(A)), u.to_unicode(u' {}, {}, {} ({}) '.format(a, b, g, d)), u.to_unicode(u'Resolution ({}) '.format(A)), u.to_unicode(u'Completeness (%)'), u.to_unicode(u'Multiplicity'), u.to_unicode(u'I / {}(I) '.format(s)), u.to_unicode(u'CC{} '.format(h)), u.to_unicode(u'R_merge') ] n_frames_bad = self.info['n_frames_bad_cc'][-1] + \ self.info['n_frames_bad_G'][-1] + \ self.info['n_frames_bad_uc'][-1] + \ self.info['n_frames_bad_gamma_e'][-1] + \ self.info['n_frames_bad_SE'][-1] t1_data = [ ['{}'.format(self.info['n_frames_good'][-1])], ['{}'.format(n_frames_bad)], [ '{}'.format( self.info['space_group_info'][-1].symbol_and_number()) ], [''], ['{}'.format(uc_edges)], ['{}'.format(uc_angles)], ['{} ({})'.format(res_total, res_last_shell)], [ '{:4.2f} ({:4.2f})'.format( self.info['total_completeness'][-1], self.info['binned_completeness'][-1][-1]) ], [ '{:4.2f} ({:4.2f})'.format(self.info['total_n_obs'][-1], self.info['binned_n_obs'][-1][-1]) ], [ '{:4.2f} ({:4.2f})'.format( self.info['total_i_o_sigi'][-1], self.info['binned_i_o_sigi'][-1][-1]) ], [ '{:4.2f} ({:4.2f})'.format( self.info['total_cc12'][-1], self.info['binned_cc12'][-1][-1] * 100) ], [ '{:4.2f} ({:4.2f})'.format(self.info['total_rmerge'][-1], self.info['binned_rmerge'][-1][-1]) ] ] return t1_rlabels, t1_data
def get_node_data(xml_node, node_name): child_nodes = xml_node.getElementsByTagName(node_name) return to_unicode(child_nodes[0].childNodes[0].data)