def _set_res(self, event): if len(self._ref_files) > 0 and len(self._in_files) > 0: ref = self._ref_files[self._reflections.GetCurrentSelection()] ins = self._in_files[self._structure.GetCurrentSelection()] if os.path.exists(ref) and os.path.exists(ins): hkl = hklf.reader(open(ref)) try: ma = hkl.as_miller_arrays(crystal_symmetry=crystal_symmetry_from_ins.extract_from(ins)) except: return rr = ma[0].resolution_range() self._res_high.SetValue(str(round(rr[1], 2))) self._res_low.SetValue(str(round(rr[0], 2))) ins_obj = Shelx(ins) self._hydrogens.SetValue(ins_obj.has_hydrogen()) self._residues.Clear() self._residue_list = [] for r in sorted(ins_obj.residue_list()): if r not in (ShelxData._r + ['HOH', 'DOD', 'CL', 'MG']) or (r in ['ASP', 'GLU', 'HIS', 'ARG']): self._residues.Append(r) self._residue_list.append(r)
class RotamerFrame(plots.plot_frame): def __init__(self, parent, title, rotalyze_data, ins_file): self.rotalyze_data = rotalyze_data self._ins = Shelx(ins_file) self._residue_list = self._ins.residue_list() self._data_types = ['All', 'Allowed/Outlier', 'Outlier'] self.residue_name = self._residue_list[0] self.point_type = 'All' self.plot = None plots.plot_frame.__init__(self, parent=parent, title=title) def create_plot_panel(self): self.plot = graphics.rotamer_plot() self.canvas = FigCanvas(self, -1, self.plot.figure) self.draw_plot() return self.canvas def draw_plot(self): stats = utils.get_rotarama_data(pos_type='general', convert_to_numpy_array=True) residue_name = 'GLN' points, coords = graphics.get_residue_rotamer_data(rotalyze_data=self.rotalyze_data, residue_name=self.residue_name, point_type=self.point_type) self.plot.draw_plot( stats=stats, title="Chi1-Chi2 plot for %s" % self.residue_name, points=points, xyz=coords, colormap="Blues", contours=None) if self.canvas is not None: self.canvas.draw() def draw_top_panel(self): self.top_panel = wx.Panel(parent=self, style=wx.SUNKEN_BORDER) self.top_sizer = wx.FlexGridSizer(rows=0, cols=4, vgap=5, hgap=5) self.top_sizer.Add(wx.StaticText(self, -1, 'Residue Name'), 1, wx.EXPAND|wx.ALL, 5) self.res_type = wx.ComboBox(self, -1, choices=self._residue_list, style=wx.CB_READONLY) self.res_type.Bind(wx.EVT_COMBOBOX, self._set_residue_name) self.top_sizer.Add(self.res_type, 1, wx.EXPAND|wx.ALL, 5) self.top_sizer.Add(wx.StaticText(self, -1, 'Show Data Points'), 1, wx.EXPAND|wx.ALL, 5) self.data_type = wx.ComboBox(self, -1, choices=self._data_types, style=wx.CB_READONLY) self.data_type.Bind(wx.EVT_COMBOBOX, self._set_data_type) self.top_sizer.Add(self.data_type, 1, wx.EXPAND|wx.ALL, 5) self.top_panel.SetSizer(self.top_sizer) def _set_data_type(self, event): self.point_type = self._data_types[self.data_type.GetCurrentSelection()] self.draw_plot() def _set_residue_name(self, event): self.residue_name = self._residue_list[self.res_type.GetCurrentSelection()] self.draw_plot() def OnSave(self, event): output_file = wx.FileSelector("Saved image name", default_path='', default_filename="plot.png", wildcard="Adobe PDF figure (*.pdf)|*.pdf|" + \ "PNG image (*.png)|*.png|" + \ "Postscript figure (*.ps)|*.ps", flags=wx.SAVE) if output_file != "" : self.plot.save_image(output_file)