Package gui :: Package user_functions :: Module sequence
[hide private]
[frames] | no frames]

Source Code for Module gui.user_functions.sequence

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """The sequence user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from string import split 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from generic_fns.pipes import cdp_name, pipe_names 
 32   
 33  # GUI module imports. 
 34  from base import UF_base, UF_page 
 35  from gui.paths import WIZARD_IMAGE_PATH 
 36  from gui.misc import gui_to_bool, gui_to_int, gui_to_str, str_to_gui 
 37   
 38   
 39  # The container class. 
40 -class Sequence(UF_base):
41 """The container class for holding all GUI elements.""" 42
43 - def copy(self):
44 """The sequence.copy user function.""" 45 46 # Execute the wizard. 47 wizard = self.create_wizard(size_x=700, size_y=500, name='sequence.copy', uf_page=Copy_page) 48 wizard.run()
49 50
51 - def read(self):
52 """The sequence.read user function.""" 53 54 # Execute the wizard. 55 wizard = self.create_wizard(size_x=900, size_y=700, name='sequence.read', uf_page=Read_page) 56 wizard.run()
57 58
59 - def write(self):
60 """The sequence.write user function.""" 61 62 # Execute the wizard. 63 wizard = self.create_wizard(size_x=900, size_y=700, name='sequence.write', uf_page=Write_page) 64 wizard.run()
65 66 67
68 -class Copy_page(UF_page):
69 """The sequence.copy() user function page.""" 70 71 # Some class variables. 72 image_path = WIZARD_IMAGE_PATH + 'sequence.png' 73 uf_path = ['sequence', 'copy'] 74
75 - def add_contents(self, sizer):
76 """Add the sequence specific GUI elements. 77 78 @param sizer: A sizer object. 79 @type sizer: wx.Sizer instance 80 """ 81 82 # The source pipe. 83 self.pipe_from = self.combo_box(sizer, "The source data pipe:", [], tooltip=self.uf._doc_args_dict['pipe_from']) 84 85 # The destination pipe. 86 self.pipe_to = self.combo_box(sizer, "The destination data pipe name:", [], tooltip=self.uf._doc_args_dict['pipe_to'])
87 88
89 - def on_display(self):
90 """Update the pipe name lists.""" 91 92 # Set the default pipe name. 93 if not gui_to_str(self.pipe_from.GetValue()): 94 self.pipe_from.SetValue(str_to_gui(cdp_name())) 95 if not gui_to_str(self.pipe_to.GetValue()): 96 self.pipe_to.SetValue(str_to_gui(cdp_name())) 97 98 # Clear the previous data. 99 self.pipe_from.Clear() 100 self.pipe_to.Clear() 101 102 # The list of pipe names. 103 for name in pipe_names(): 104 self.pipe_from.Append(str_to_gui(name)) 105 self.pipe_to.Append(str_to_gui(name))
106 107
108 - def on_execute(self):
109 """Execute the user function.""" 110 111 # Get the pipe names. 112 pipe_from = gui_to_str(self.pipe_from.GetValue()) 113 pipe_to = gui_to_str(self.pipe_to.GetValue()) 114 115 # Copy the sequence. 116 self.execute('sequence.copy', pipe_from=pipe_from, pipe_to=pipe_to)
117 118 119
120 -class Read_page(UF_page):
121 """The sequence.read() user function page.""" 122 123 # Some class variables. 124 image_path = WIZARD_IMAGE_PATH + 'sequence.png' 125 uf_path = ['sequence', 'read'] 126 127
128 - def add_contents(self, sizer):
129 """Add the sequence specific GUI elements. 130 131 @param sizer: A sizer object. 132 @type sizer: wx.Sizer instance 133 """ 134 135 # Add a file selection. 136 self.file = self.file_selection(sizer, "The sequence file:", message="Sequence file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'], preview=True) 137 138 # The spin ID restriction. 139 self.spin_id = self.spin_id_element(sizer, "Restrict data loading to certain spins:") 140 141 # The parameter file settings. 142 self.free_file_format(sizer, data_cols=False, padding=3, spacer=0)
143 144
145 - def on_execute(self):
146 """Execute the user function.""" 147 148 # The file name. 149 file = gui_to_str(self.file.GetValue()) 150 151 # No file. 152 if not file: 153 return 154 155 # Get the column numbers. 156 spin_id_col = gui_to_int(self.spin_id_col.GetValue()) 157 mol_name_col = gui_to_int(self.mol_name_col.GetValue()) 158 res_num_col = gui_to_int(self.res_num_col.GetValue()) 159 res_name_col = gui_to_int(self.res_name_col.GetValue()) 160 spin_num_col = gui_to_int(self.spin_num_col.GetValue()) 161 spin_name_col = gui_to_int(self.spin_name_col.GetValue()) 162 163 # The column separator. 164 sep = str(self.sep.GetValue()) 165 if sep == 'white space': 166 sep = None 167 168 # The spin ID. 169 spin_id = gui_to_str(self.spin_id.GetValue()) 170 171 # Read the sequence. 172 self.execute('sequence.read', file=file, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, sep=sep, spin_id=spin_id)
173 174 175
176 -class Write_page(UF_page):
177 """The sequence.write() user function page.""" 178 179 # Some class variables. 180 image_path = WIZARD_IMAGE_PATH + 'sequence.png' 181 uf_path = ['sequence', 'write'] 182 183
184 - def add_contents(self, sizer):
185 """Add the sequence specific GUI elements. 186 187 @param sizer: A sizer object. 188 @type sizer: wx.Sizer instance 189 """ 190 191 # Add a file selection. 192 self.file = self.file_selection(sizer, "The sequence file:", message="Sequence file selection", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 193 194 # The column separator. 195 self.sep = self.combo_box(sizer, "Column separator:", ["white space", ",", ";", ":", ""], tooltip=self.uf._doc_args_dict['sep'], read_only=False) 196 self.sep.SetValue(str_to_gui("white space")) 197 198 # The column flags. 199 self.mol_name_flag = self.boolean_selector(sizer, "Molecule name flag:", tooltip=self.uf._doc_args_dict['mol_name_flag']) 200 self.res_num_flag = self.boolean_selector(sizer, "Residue number flag:", tooltip=self.uf._doc_args_dict['res_num_flag']) 201 self.res_name_flag = self.boolean_selector(sizer, "Residue name flag:", tooltip=self.uf._doc_args_dict['res_name_flag']) 202 self.spin_num_flag = self.boolean_selector(sizer, "Spin number flag:", tooltip=self.uf._doc_args_dict['spin_num_flag']) 203 self.spin_name_flag = self.boolean_selector(sizer, "Spin name flag:", tooltip=self.uf._doc_args_dict['spin_name_flag']) 204 205 # The force flag. 206 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'])
207 208
209 - def on_execute(self):
210 """Execute the user function.""" 211 212 # The file name. 213 file = gui_to_str(self.file.GetValue()) 214 215 # No file. 216 if not file: 217 return 218 219 # The column separator. 220 sep = str(self.sep.GetValue()) 221 if sep == 'white space': 222 sep = None 223 224 # Get the column flags. 225 mol_name_flag = gui_to_bool(self.mol_name_flag.GetValue()) 226 res_num_flag = gui_to_bool(self.res_num_flag.GetValue()) 227 res_name_flag = gui_to_bool(self.res_name_flag.GetValue()) 228 spin_num_flag = gui_to_bool(self.spin_num_flag.GetValue()) 229 spin_name_flag = gui_to_bool(self.spin_name_flag.GetValue()) 230 231 # Force flag. 232 force = gui_to_bool(self.force.GetValue()) 233 234 # Read the sequence. 235 self.execute('sequence.write', file=file, sep=sep, mol_name_flag=mol_name_flag, res_num_flag=res_num_flag, res_name_flag=res_name_flag, spin_num_flag=spin_num_flag, spin_name_flag=spin_name_flag, force=force)
236