Author: bugman Date: Thu Jun 30 18:28:43 2011 New Revision: 13352 URL: http://svn.gna.org/viewcvs/relax?rev=13352&view=rev Log: Created the structure.read_pdb GUI user function window and menu entry. Modified: branches/gui_testing/gui/menu.py branches/gui_testing/gui/user_functions/structure.py Modified: branches/gui_testing/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/menu.py?rev=13352&r1=13351&r2=13352&view=diff ============================================================================== --- branches/gui_testing/gui/menu.py (original) +++ branches/gui_testing/gui/menu.py Thu Jun 30 18:28:43 2011 @@ -229,8 +229,9 @@ [wx.NewId(), "crea&te", paths.icon_16x16.add, self.gui.user_functions.spin.create], [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.spin.delete] ]], - [wx.NewId(), "s&tructure", None, None, [ - [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.structure.delete] + [wx.NewId(), "s&tructure", paths.icon_16x16.structure, None, [ + [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.structure.delete], + [wx.NewId(), "read_&pdb", paths.icon_16x16.open, self.gui.user_functions.structure.read_pdb] ]], [wx.NewId(), "&value", paths.icon_16x16.value, None, [ [wx.NewId(), "&set", paths.icon_16x16.add, self.gui.user_functions.value.set] Modified: branches/gui_testing/gui/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/structure.py?rev=13352&r1=13351&r2=13352&view=diff ============================================================================== --- branches/gui_testing/gui/user_functions/structure.py (original) +++ branches/gui_testing/gui/user_functions/structure.py Thu Jun 30 18:28:43 2011 @@ -41,7 +41,7 @@ """The container class for holding all GUI elements.""" def delete(self, event): - """The spin.delete user function. + """The structure.delete user function. @param event: The wx event. @type event: wx event @@ -50,6 +50,22 @@ # Create the wizard. wizard = Wiz_window(size_x=600, size_y=400, title='Delete all structural data') page = Delete_page(wizard, self.gui, self.interpreter) + wizard.add_page(page) + + # Execute the wizard. + wizard.run() + + + def read_pdb(self, event): + """The structure.read_pdb user function. + + @param event: The wx event. + @type event: wx event + """ + + # Create the wizard. + wizard = Wiz_window(size_x=900, size_y=800, title='PDB reader') + page = Read_pdb_page(wizard, self.gui, self.interpreter) wizard.add_page(page) # Execute the wizard. @@ -66,7 +82,7 @@ def add_contents(self, sizer): - """Add the spin specific GUI elements. + """Add the structure specific GUI elements. @param sizer: A sizer object. @type sizer: wx.Sizer instance @@ -78,3 +94,65 @@ # Delete all structures. self.interpreter.structure.delete() + + + +class Read_pdb_page(UF_page): + """The structure.read_pdb() user function page.""" + + # Some class variables. + main_text = """The reading of PDB files into relax is quite a flexible procedure allowing for both models, defined as an ensemble of the same molecule but with different atomic positions, and different molecules within the same model. One of more molecules can exist in one or more models. The flexibility allows PDB models to be converted into different molecules and different PDB files loaded as the same molecule but as different models. This flexibility is controlled by the four keyword arguments 'read_mol', 'set_mol_name', 'read_model', and 'set_model_num'. + + A few different PDB parsers can be used to read the structural data. The choice of which to use depends on whether your PDB file is supported by that reader. These are selected by setting the 'parser' argument to one of: + + 'scientific' - the Scientific Python PDB parser. + 'internal' - a lower quality and less reliable, although faster, PDB parser built into relax. + + In a PDB file, the models are specified by the MODEL PDB record. All the supported PDB readers in relax recognise this. The molecule level is quite different between the Scientific Python and internal readers. For how Scientific Python defines molecules, please see its documentation. The internal reader is far simpler as it defines molecules using the TER PDB record. In both cases, the molecules will be numbered consecutively from 1. + + The 'set_mol_name' argument is used to name the molecules within the PDB (within one model). If not set, then the molecules will be named after the file name, with the molecule number appended if more than one exists. + + Note that relax will complain if it cannot work out what to do.""" + title = 'PDB loading' + + + def add_contents(self, sizer): + """Add the structure specific GUI elements. + + @param sizer: A sizer object. + @type sizer: wx.Sizer instance + """ + + # Add a file selection. + self.file = self.file_selection(sizer, "The PDB file:", title="PDB file selection") + + # The read_mol arg. + self.read_mol = self.input_field(sizer, "Read molecule number:", tooltip="This is the 'read_mol' user function argument.") + + # The set_mol_name arg. + self.set_mol_name = self.input_field(sizer, "Set the molecule name:", tooltip="This is the 'set_mol_name' user function argument.") + + # The read_model arg. + self.read_model = self.input_field(sizer, "Read model number:", tooltip="This is the 'read_model' user function argument.") + + # The set_model_num arg. + self.set_model_num = self.input_field(sizer, "Set the model number:", tooltip="This is the 'set_model_num' user function argument.") + + # The PDB reader (default to internal). + self.parser = self.combo_box(sizer, "The PDB parser:", choices=['internal', 'scientific'], tooltip="This is the 'parser' user function argument.") + self.parser.SetValue('internal') + + + def on_execute(self): + """Execute the user function.""" + + # The args. + file = gui_to_str(self.file.GetValue()) + read_mol = gui_to_str(self.read_mol.GetValue()) + set_mol_name = gui_to_str(self.set_mol_name.GetValue()) + read_model = gui_to_str(self.read_model.GetValue()) + set_model_num = gui_to_str(self.set_model_num.GetValue()) + parser = gui_to_str(self.parser.GetValue()) + + # Execute the user function. + self.interpreter.structure.read_pdb(file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num, parser=parser)