Ejemplo n.º 1
0
class NewPDB(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title)#, size=(330,340))

        self._input_sizer = wx.FlexGridSizer(cols=2, rows=0, hgap=5, vgap=5)
        self._browse = FileBrowser(self, '*.pdb', 'Select a PDB File')
        self._input_sizer.Add(wx.StaticText(self, -1, 'PDB File'), 0, wx.EXPAND|wx.TOP|wx.LEFT, 5)
        self._input_sizer.Add(self._browse.sizer())

        self._buttons = wx.BoxSizer(wx.HORIZONTAL)
        self._buttons.Add(wx.Button(self, 0, 'Import'), 1, wx.EXPAND|wx.ALL, 5)
        self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
        
        self._input_sizer.Add((10,10), 1, wx.EXPAND)
        self._input_sizer.Add(self._buttons, 1, wx.EXPAND)
        
        
        self.Bind(wx.EVT_BUTTON, self._import, id=0)
        self.Bind(wx.EVT_BUTTON, self._close, id=1)          
        
        self.main = wx.BoxSizer(wx.VERTICAL)
        self.main.Add(self._input_sizer, 0, wx.EXPAND|wx.ALL, 5)
        
        self.SetSizer(self.main)
        self.Fit()


    def _close(self, event):
        self.EndModal(0)

    def _import(self, event):
        self.EndModal(1)
        
    def get_file(self):
        return self._browse.file()
Ejemplo n.º 2
0
class NewCIF(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title)#, size=(330,340))

        self._browse = FileBrowser(self, 'CIF File (*.cif)|*.cif|MTZ File (*.mtz)|*.mtz', 'Select a reflection file', callback=self._refresh)
        self._input_sizer = wx.FlexGridSizer(cols=2, rows=0, hgap=5, vgap=5)
        self._inputs = [
            wx.StaticText(self, -1, 'Reflection'),
            self._browse.sizer(),
            wx.StaticText(self, -1, 'F, SigF'),
            wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
            wx.StaticText(self, -1, 'FreeR'),
            wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
        ]
        
        for i in range(len(self._inputs)):
            self._input_sizer.Add(self._inputs[i], 0, wx.EXPAND)

        self._buttons = wx.BoxSizer(wx.HORIZONTAL)
        self._buttons.Add(wx.Button(self, 0, 'Import'), 1, wx.EXPAND|wx.ALL, 5)
        self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
                
        self._input_sizer.Add((10,10), 1, wx.EXPAND)
        self._input_sizer.Add(self._buttons, 1, wx.EXPAND)
                
        self.Bind(wx.EVT_BUTTON, self._import, id=0)
        self.Bind(wx.EVT_BUTTON, self._close, id=1)          
        
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self._input_sizer, 1, wx.EXPAND|wx.ALL, 5)
                
        self.SetSizer(self.sizer)
        self.Fit()
        

    def _close(self, event):
        self.EndModal(0)

    def _import(self, event):
        self.EndModal(1)
        
    def get_values(self):
        return self._browse.file(), self._inputs[3].GetValue(), self._inputs[5].GetValue()

    def _refresh(self):
            m = reflection_file_reader.any_reflection_file(self._browse.file())
            
            self._inputs[3].Clear()
            self._inputs[5].Clear()
            
            for col in m.as_miller_arrays():
                if col.is_xray_intensity_array() or col.is_xray_amplitude_array():
                    self._inputs[3].Append(col.info().label_string())
                else:
                    self._inputs[5].Append(col.info().label_string())
Ejemplo n.º 3
0
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title)#, size=(330,340))

        self._browse = FileBrowser(self, 'CIF File (*.cif)|*.cif|MTZ File (*.mtz)|*.mtz', 'Select a reflection file', callback=self._refresh)
        self._input_sizer = wx.FlexGridSizer(cols=2, rows=0, hgap=5, vgap=5)
        self._inputs = [
            wx.StaticText(self, -1, 'Reflection'),
            self._browse.sizer(),
            wx.StaticText(self, -1, 'F, SigF'),
            wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
            wx.StaticText(self, -1, 'FreeR'),
            wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
        ]
        
        for i in range(len(self._inputs)):
            self._input_sizer.Add(self._inputs[i], 0, wx.EXPAND)

        self._buttons = wx.BoxSizer(wx.HORIZONTAL)
        self._buttons.Add(wx.Button(self, 0, 'Import'), 1, wx.EXPAND|wx.ALL, 5)
        self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
                
        self._input_sizer.Add((10,10), 1, wx.EXPAND)
        self._input_sizer.Add(self._buttons, 1, wx.EXPAND)
                
        self.Bind(wx.EVT_BUTTON, self._import, id=0)
        self.Bind(wx.EVT_BUTTON, self._close, id=1)          
        
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self._input_sizer, 1, wx.EXPAND|wx.ALL, 5)
                
        self.SetSizer(self.sizer)
        self.Fit()
Ejemplo n.º 4
0
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title)

        self._root = None
        
        self.input_sizer = wx.FlexGridSizer(cols=2, rows=0, vgap=5, hgap=5)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Title'), 0, wx.EXPAND|wx.ALL, 5)
        self._title = wx.TextCtrl(self, -1, '')
        self.input_sizer.Add(self._title, 0, wx.EXPAND|wx.ALL, 5)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Project Root'), 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
        self._browser = FileBrowser(self, '', 'Select a Project Directory', dir=True)
        self.input_sizer.Add(self._browser.sizer(), 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
            
        self._buttons = wx.BoxSizer(wx.HORIZONTAL)
        self._buttons.Add(wx.Button(self, 0, 'Create'), 1, wx.EXPAND|wx.ALL, 5)
        self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
                
        self.Bind(wx.EVT_BUTTON, self._create, id=0)
        self.Bind(wx.EVT_BUTTON, self._cancel, id=1)    
        
        self.input_sizer.Add((10,10), 1, wx.EXPAND)
        self.input_sizer.Add(self._buttons, 1, wx.EXPAND|wx.ALL, 5)
        
        self.SetSizer(self.input_sizer)
        self.Fit()
Ejemplo n.º 5
0
    def __init__(self, parent, id, title, inputs, refls, in_files, ref_files, selected_refls=None, selected_struct=None, resh=None):
        wx.Dialog.__init__(self, parent, id, title)

        self._in_files = in_files
        self._ref_files = ref_files
        self._residue_list = []
        
        if not selected_refls in refls:
            selected_refls = None
    
        if not selected_struct in inputs:
            selected_struct = None
        
        self.input_sizer = wx.FlexGridSizer(rows=0, cols=2, vgap=5, hgap=5)
        self.input_sizer.Add(wx.StaticText(self, -1, 'Title'))

        self._title = wx.TextCtrl(self, -1, '', (30, 200))
        self.input_sizer.Add(self._title, 0, wx.EXPAND)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Reflections'))
        self._reflections = wx.ComboBox(self, -1, choices=refls, style=wx.CB_READONLY)
        self._reflections.Bind(wx.EVT_COMBOBOX, self._set_res)
        self._view_refs = metallicbutton.MetallicButton(self, 0, '', '', bitmaps.fetch_icon_bitmap('actions', 'viewmag', scale=(16,16)), size=(22, 20))
        self.Bind(wx.EVT_BUTTON, self._view_file, self._view_refs)
        
        self._refs_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._refs_sizer.Add(self._view_refs, 0, wx.EXPAND|wx.RIGHT, 5)
        self._refs_sizer.Add(self._reflections, 1, wx.EXPAND)
        
        self.input_sizer.Add(self._refs_sizer, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Structure'))
        self._structure = wx.ComboBox(self, -1, choices=inputs, style=wx.CB_READONLY)
        self._structure.Bind(wx.EVT_COMBOBOX, self._set_res)
        self._view_struct = metallicbutton.MetallicButton(self, 1, '', '', bitmaps.fetch_icon_bitmap('actions', 'viewmag', scale=(16,16)), size=(22, 20))
        self.Bind(wx.EVT_BUTTON, self._view_file, self._view_struct)
        
        self._struct_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._struct_sizer.Add(self._view_struct, 0, wx.EXPAND|wx.RIGHT, 5)
        self._struct_sizer.Add(self._structure, 1, wx.EXPAND)
        
        self.input_sizer.Add(self._struct_sizer, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Type'))
        self._refinement_type = wx.ComboBox(self, -1, REFINEMENT_TYPES[0], choices=REFINEMENT_TYPES, style=wx.CB_READONLY)
        self._refinement_type.Bind(wx.EVT_COMBOBOX, self._set_type)
        self.input_sizer.Add(self._refinement_type, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Target'))
        self._target = wx.ComboBox(self, -1, REFINEMENT_TARGETS[0], choices=REFINEMENT_TARGETS, style=wx.CB_READONLY)
        self._target.Bind(wx.EVT_COMBOBOX, self._set_target)
        self.input_sizer.Add(self._target, 0, wx.EXPAND)
        
        self.input_sizer.Add(wx.StaticText(self, -1, 'Cycles'))
        self._cycles = wx.SpinCtrl(self, -1, value='10')
        self.input_sizer.Add(self._cycles, 0)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Resolution'))
        self._res_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._res_high = wx.TextCtrl(self, -1, '')
        self._res_low = wx.TextCtrl(self, -1, '')
        self._res_sizer.Add(self._res_high)
        self._res_sizer.Add(self._res_low)
        self.input_sizer.Add(self._res_sizer, 0)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Options'))
        self._opt_sizer = wx.BoxSizer(wx.VERTICAL)

        self._auto = wx.CheckBox(self, -1, 'Auto Refinement', (10, 10))
        self._opt_sizer.Add(self._auto)
        self._auto.Bind(wx.EVT_CHECKBOX, self._set_auto)
        
        self._hydrogens = wx.CheckBox(self, -1, 'Add Hydrogens', (10, 10))
        self._opt_sizer.Add(self._hydrogens)

        self._anis = wx.CheckBox(self, -1, 'Anisotropic', (10, 10))
        self._opt_sizer.Add(self._anis)
        
        self._bloc = wx.CheckBox(self, -1, 'BLOC Refinement', (10, 10))
        self._opt_sizer.Add(self._bloc)
                             
        self._rfree = wx.CheckBox(self, -1, 'Include Rfree Set', (10, 10))
        self._opt_sizer.Add(self._rfree, 0)
        
        self.input_sizer.Add(self._opt_sizer, 0, wx.EXPAND)
        
        self._residues_title = wx.StaticText(self, -1, 'Unrestrained Residues')
        self._residues_title.Wrap(100)
        self.input_sizer.Add(self._residues_title)
        self._residues = wx.ListBox(self, 26, wx.DefaultPosition, (40, 100), [], wx.LB_MULTIPLE)

        self.input_sizer.Add(self._residues, 0, wx.EXPAND)
        
        self._ur_title = wx.StaticText(self, -1, 'Un-/Restrained Cycles')
        self._ur_title.Wrap(100)
        self._ur_cycles = wx.SpinCtrl(self, -1, value='5')
        self.input_sizer.Add(self._ur_title, 0, wx.EXPAND)
        self.input_sizer.Add(self._ur_cycles, 0)
        
        self._total_title = wx.StaticText(self, -1, 'Total Cycles')
        self._total_cycles = wx.SpinCtrl(self, -1, value='1')
        self.input_sizer.Add(self._total_title, 0, wx.EXPAND)
        self.input_sizer.Add(self._total_cycles, 0)
    
        self._custom_file = FileBrowser(self, 'Text File (*.txt)|*.txt', 'Select a text file containing custom shelx commands')
        self._custom_text = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE, size=(-1, 100))
        
        self.input_sizer.Add(wx.StaticText(self, -1, 'Custom Commands'), 0, wx.EXPAND)
        
        self.custom_sizer = wx.BoxSizer(wx.VERTICAL)
        self.custom_sizer.Add(self._custom_file.sizer(), 0, wx.EXPAND)
        self.custom_sizer.Add(self._custom_text, 0, wx.EXPAND)
        
        self.input_sizer.Add(self.custom_sizer, 0, wx.EXPAND)
        
        self._button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._startb = wx.Button(self, 0, 'Start')
        self._startb.Bind(wx.EVT_BUTTON, self._start)
        self._button_sizer.Add(self._startb, 1, wx.EXPAND|wx.ALL, 5)
        self._cancel = wx.Button(self, 1, 'Cancel')
        self._cancel.Bind(wx.EVT_BUTTON, self._close)
        self._button_sizer.Add(self._cancel, 1, wx.EXPAND|wx.ALL, 5)
        
        self.input_sizer.Add((10,10))
        self.input_sizer.Add(self._button_sizer, 0, wx.EXPAND)
        
        
        self.main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_sizer.Add(self.input_sizer, 0, wx.EXPAND|wx.ALL, 5)
        #self.main_sizer.Add(self._button_sizer, 0, wx.EXPAND|wx.CENTER, 10)
        
        self.SetSizer(self.main_sizer)

        for c in [self._residues, self._residues_title, self._rfree, self._bloc, self._ur_title, self._ur_cycles, self._total_title, self._total_cycles]:
            c.Hide()

        self.Fit()
    
        if selected_refls in refls or selected_struct in inputs:
            if selected_refls in refls:
                self._reflections.SetStringSelection(selected_refls)
            if selected_struct in inputs:
                self._structure.SetStringSelection(selected_struct)
        else:
            self._hydrogens.SetValue(0)

        self._set_res('')

        if resh is not None:
            self._res_high.SetValue(str(resh))
Ejemplo n.º 6
0
class NewRefinement(wx.Dialog):

    def __init__(self, parent, id, title, inputs, refls, in_files, ref_files, selected_refls=None, selected_struct=None, resh=None):
        wx.Dialog.__init__(self, parent, id, title)

        self._in_files = in_files
        self._ref_files = ref_files
        self._residue_list = []
        
        if not selected_refls in refls:
            selected_refls = None
    
        if not selected_struct in inputs:
            selected_struct = None
        
        self.input_sizer = wx.FlexGridSizer(rows=0, cols=2, vgap=5, hgap=5)
        self.input_sizer.Add(wx.StaticText(self, -1, 'Title'))

        self._title = wx.TextCtrl(self, -1, '', (30, 200))
        self.input_sizer.Add(self._title, 0, wx.EXPAND)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Reflections'))
        self._reflections = wx.ComboBox(self, -1, choices=refls, style=wx.CB_READONLY)
        self._reflections.Bind(wx.EVT_COMBOBOX, self._set_res)
        self._view_refs = metallicbutton.MetallicButton(self, 0, '', '', bitmaps.fetch_icon_bitmap('actions', 'viewmag', scale=(16,16)), size=(22, 20))
        self.Bind(wx.EVT_BUTTON, self._view_file, self._view_refs)
        
        self._refs_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._refs_sizer.Add(self._view_refs, 0, wx.EXPAND|wx.RIGHT, 5)
        self._refs_sizer.Add(self._reflections, 1, wx.EXPAND)
        
        self.input_sizer.Add(self._refs_sizer, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Structure'))
        self._structure = wx.ComboBox(self, -1, choices=inputs, style=wx.CB_READONLY)
        self._structure.Bind(wx.EVT_COMBOBOX, self._set_res)
        self._view_struct = metallicbutton.MetallicButton(self, 1, '', '', bitmaps.fetch_icon_bitmap('actions', 'viewmag', scale=(16,16)), size=(22, 20))
        self.Bind(wx.EVT_BUTTON, self._view_file, self._view_struct)
        
        self._struct_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._struct_sizer.Add(self._view_struct, 0, wx.EXPAND|wx.RIGHT, 5)
        self._struct_sizer.Add(self._structure, 1, wx.EXPAND)
        
        self.input_sizer.Add(self._struct_sizer, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Type'))
        self._refinement_type = wx.ComboBox(self, -1, REFINEMENT_TYPES[0], choices=REFINEMENT_TYPES, style=wx.CB_READONLY)
        self._refinement_type.Bind(wx.EVT_COMBOBOX, self._set_type)
        self.input_sizer.Add(self._refinement_type, 0, wx.EXPAND)

        self.input_sizer.Add(wx.StaticText(self, -1, 'Target'))
        self._target = wx.ComboBox(self, -1, REFINEMENT_TARGETS[0], choices=REFINEMENT_TARGETS, style=wx.CB_READONLY)
        self._target.Bind(wx.EVT_COMBOBOX, self._set_target)
        self.input_sizer.Add(self._target, 0, wx.EXPAND)
        
        self.input_sizer.Add(wx.StaticText(self, -1, 'Cycles'))
        self._cycles = wx.SpinCtrl(self, -1, value='10')
        self.input_sizer.Add(self._cycles, 0)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Resolution'))
        self._res_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._res_high = wx.TextCtrl(self, -1, '')
        self._res_low = wx.TextCtrl(self, -1, '')
        self._res_sizer.Add(self._res_high)
        self._res_sizer.Add(self._res_low)
        self.input_sizer.Add(self._res_sizer, 0)
            
        self.input_sizer.Add(wx.StaticText(self, -1, 'Options'))
        self._opt_sizer = wx.BoxSizer(wx.VERTICAL)

        self._auto = wx.CheckBox(self, -1, 'Auto Refinement', (10, 10))
        self._opt_sizer.Add(self._auto)
        self._auto.Bind(wx.EVT_CHECKBOX, self._set_auto)
        
        self._hydrogens = wx.CheckBox(self, -1, 'Add Hydrogens', (10, 10))
        self._opt_sizer.Add(self._hydrogens)

        self._anis = wx.CheckBox(self, -1, 'Anisotropic', (10, 10))
        self._opt_sizer.Add(self._anis)
        
        self._bloc = wx.CheckBox(self, -1, 'BLOC Refinement', (10, 10))
        self._opt_sizer.Add(self._bloc)
                             
        self._rfree = wx.CheckBox(self, -1, 'Include Rfree Set', (10, 10))
        self._opt_sizer.Add(self._rfree, 0)
        
        self.input_sizer.Add(self._opt_sizer, 0, wx.EXPAND)
        
        self._residues_title = wx.StaticText(self, -1, 'Unrestrained Residues')
        self._residues_title.Wrap(100)
        self.input_sizer.Add(self._residues_title)
        self._residues = wx.ListBox(self, 26, wx.DefaultPosition, (40, 100), [], wx.LB_MULTIPLE)

        self.input_sizer.Add(self._residues, 0, wx.EXPAND)
        
        self._ur_title = wx.StaticText(self, -1, 'Un-/Restrained Cycles')
        self._ur_title.Wrap(100)
        self._ur_cycles = wx.SpinCtrl(self, -1, value='5')
        self.input_sizer.Add(self._ur_title, 0, wx.EXPAND)
        self.input_sizer.Add(self._ur_cycles, 0)
        
        self._total_title = wx.StaticText(self, -1, 'Total Cycles')
        self._total_cycles = wx.SpinCtrl(self, -1, value='1')
        self.input_sizer.Add(self._total_title, 0, wx.EXPAND)
        self.input_sizer.Add(self._total_cycles, 0)
    
        self._custom_file = FileBrowser(self, 'Text File (*.txt)|*.txt', 'Select a text file containing custom shelx commands')
        self._custom_text = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE, size=(-1, 100))
        
        self.input_sizer.Add(wx.StaticText(self, -1, 'Custom Commands'), 0, wx.EXPAND)
        
        self.custom_sizer = wx.BoxSizer(wx.VERTICAL)
        self.custom_sizer.Add(self._custom_file.sizer(), 0, wx.EXPAND)
        self.custom_sizer.Add(self._custom_text, 0, wx.EXPAND)
        
        self.input_sizer.Add(self.custom_sizer, 0, wx.EXPAND)
        
        self._button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._startb = wx.Button(self, 0, 'Start')
        self._startb.Bind(wx.EVT_BUTTON, self._start)
        self._button_sizer.Add(self._startb, 1, wx.EXPAND|wx.ALL, 5)
        self._cancel = wx.Button(self, 1, 'Cancel')
        self._cancel.Bind(wx.EVT_BUTTON, self._close)
        self._button_sizer.Add(self._cancel, 1, wx.EXPAND|wx.ALL, 5)
        
        self.input_sizer.Add((10,10))
        self.input_sizer.Add(self._button_sizer, 0, wx.EXPAND)
        
        
        self.main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_sizer.Add(self.input_sizer, 0, wx.EXPAND|wx.ALL, 5)
        #self.main_sizer.Add(self._button_sizer, 0, wx.EXPAND|wx.CENTER, 10)
        
        self.SetSizer(self.main_sizer)

        for c in [self._residues, self._residues_title, self._rfree, self._bloc, self._ur_title, self._ur_cycles, self._total_title, self._total_cycles]:
            c.Hide()

        self.Fit()
    
        if selected_refls in refls or selected_struct in inputs:
            if selected_refls in refls:
                self._reflections.SetStringSelection(selected_refls)
            if selected_struct in inputs:
                self._structure.SetStringSelection(selected_struct)
        else:
            self._hydrogens.SetValue(0)

        self._set_res('')

        if resh is not None:
            self._res_high.SetValue(str(resh))

    
    def _view_file(self, event):
        file = self._in_files[self._structure.GetCurrentSelection()] if event.GetId() else self._ref_files[self._reflections.GetCurrentSelection()]
    
        if os.path.exists(file):
            cmd = 'open -a TextEdit'
            subprocess.Popen(cmd.split() +[file])
    
    def _set_auto(self, event):
        v = self._auto.GetValue() == 1
        self._ur_title.Show(v)
        self._ur_cycles.Show(v)
        self._total_title.Show(v)
        self._total_cycles.Show(v)
    
        self.Fit()
    
    def _set_target(self, event):
        if self._target.GetCurrentSelection() == CGLS:
            self._bloc.Hide()
        else:
            self._bloc.Show()

        self.main_sizer.Layout()
        self.Fit()

    def _set_type(self, event):
        if self._refinement_type.GetCurrentSelection() == FULL_MATRIX:
            self._cycles.SetValue(1)
            
            #self._bloc.Show()
            self._rfree.Show()
            self._target.SetSelection(1)
            self._target.Disable()
        else:
            self._cycles.SetValue(10)
            self._target.SetSelection(0)
            self._target.Enable()
            #self._bloc.Hide()
            self._rfree.Hide()
        
        if self._refinement_type.GetCurrentSelection() == PART_UNRESTRAINED:
            self._residues_title.Show()
            self._residues.Show()
        else:
            self._residues_title.Hide()
            self._residues.Hide()

        self._set_target('')
                
        self.main_sizer.Layout()
        self.Fit()
                
    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)

    
    def _close(self, event):
        self.EndModal(0)
    
    def _start(self, event):
        self.EndModal(1)

    def get_values(self):
        ty = self._refinement_type.GetCurrentSelection()
        if ty == -1:
            ty = 0
        tg = self._target.GetCurrentSelection()
        if tg == -1:
            tg = 0
        
        residues = []
        selected = self._residues.GetSelections()
        for s in selected:
            residues.append(self._residue_list[s])
        
        #title, refln, input, type, cycles, res, resl, residues
        return self._title.GetValue(),self._reflections.GetCurrentSelection(),self._structure.GetCurrentSelection(),ty,self._cycles.GetValue(),float(self._res_high.GetValue()),float(self._res_low.GetValue()),{'residues': residues,'hydrogens': self._hydrogens.GetValue(),'bloc': self._bloc.GetValue(),'rfree': self._rfree.GetValue(), 'auto': self._auto.GetValue(), 'ur_cycles': self._ur_cycles.GetValue(), 'total_cycles': self._total_cycles.GetValue(), 'anis': self._anis.GetValue(), 'custom': self._custom_file.file(), 'custom_text': str(self._custom_text.GetValue()), 'target': tg}