Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 def __init__(self, parent, title, ramalyze_data, ins_file):
     self.canvas = None
     self.ramalyze_data = ramalyze_data
     
     self._ins = Shelx(ins_file)
     self._residue_list = ['*'] + self._ins.residue_list()
     
     self.pos_type = 'general'
     self.residue_name = '*'
     self.point_type = 'All'
     
     self.types = ["general", "glycine", "cis-proline", "trans-proline", "pre-proline", "isoleucine or valine"]
     self._data_types = ['All', 'Allowed/Outlier', 'Outlier']
     
     plots.plot_frame.__init__(self, parent=parent, title=title)
Ejemplo n.º 4
0
 def start_new_refinement(self, title, refln, input, type, cycles, res, resl, options):
     id = self._get_next_jobid()
     
     os.mkdir(self._project.root() + '/' + str(id) + '_' + REFINEMENT_TYPES[type])
     #root = self._project.root() + '/' + str(id) + '_' + REFINEMENT_TYPES[type] + '/'+ str(id) + '_' + REFINEMENT_TYPES[type].lower()
     root = './' + str(id) + '_' + REFINEMENT_TYPES[type] + '/'+ str(id) + '_' + REFINEMENT_TYPES[type].lower()
     file = root + '.ins'
     
     print os.getcwd()
     
     shutil.copy2(input, file)
     shutil.copy2(refln, root + '.hkl')
     
     if type == FULL_MATRIX:
         shutil.copy2(input.replace('.res', '.pdb'), root + '_start.pdb')
     
     print input, file
     ins = Shelx(file)
     ins.set_type(type, cycles, options)
     ins.set_res(res, resl)
     ins.set_hklf(refln.find('_F.hkl') > -1)
     ins.write()
     
     self._running += 1
     self.set_status(str(self._running) + ' Job(s) Running')
     
     self._project.action(REFINEMENT_TYPES[type])
     
     tab = Holder(self._tabs)
     tab.start_refinement(type, root, title, res, resl, cycles, input, refln, id, options)
     
     self._tabs.AddPage(tab, str(id) + '_' + REFINEMENT_TYPES[type], True)
     tab.SetFocus()
     self.GetParent().SetSelection(1)
         
     return id, root
Ejemplo n.º 5
0
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)