Package user_functions :: Module j_coupling
[hide private]
[frames] | no frames]

Source Code for Module user_functions.j_coupling

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The j_coupling user function definitions.""" 
 24   
 25  # Python module imports. 
 26  import dep_check 
 27  if dep_check.wx_module: 
 28      from wx import FD_OPEN, FD_SAVE 
 29  else: 
 30      FD_OPEN = -1 
 31      FD_SAVE = -1 
 32   
 33  # relax module imports. 
 34  from graphics import WIZARD_IMAGE_PATH 
 35  from pipe_control import pipes, j_coupling 
 36  from user_functions.data import Uf_info; uf_info = Uf_info() 
 37  from user_functions.objects import Desc_container 
 38   
 39   
 40  # The user function class. 
 41  uf_class = uf_info.add_class('j_coupling') 
 42  uf_class.title = "Class for handling scalar couplings." 
 43  uf_class.menu_text = "&j_coupling" 
 44  uf_class.gui_icon = "relax.j_coupling" 
 45   
 46   
 47  # The j_coupling.copy user function. 
 48  uf = uf_info.add_uf('j_coupling.copy') 
 49  uf.title = "Copy J coupling data from one data pipe to another." 
 50  uf.title_short = "J coupling copying." 
 51  uf.add_keyarg( 
 52      name = "pipe_from", 
 53      py_type = "str", 
 54      desc_short = "source pipe", 
 55      desc = "The name of the pipe to copy the J coupling data from.", 
 56      wiz_element_type = 'combo', 
 57      wiz_combo_iter = pipes.pipe_names, 
 58      can_be_none = True 
 59  ) 
 60  uf.add_keyarg( 
 61      name = "pipe_to", 
 62      py_type = "str", 
 63      desc_short = "destination pipe", 
 64      desc = "The name of the pipe to copy the J coupling data to.", 
 65      wiz_element_type = 'combo', 
 66      wiz_combo_iter = pipes.pipe_names, 
 67      can_be_none = True 
 68  ) 
 69  # Description. 
 70  uf.desc.append(Desc_container()) 
 71  uf.desc[-1].add_paragraph("This function will copy J coupling data from one pipe to another.") 
 72  # Prompt examples. 
 73  uf.desc.append(Desc_container("Prompt examples")) 
 74  uf.desc[-1].add_paragraph("To copy all J coupling data from pipe 'DMSO' to pipe 'CDCl3', type one of:") 
 75  uf.desc[-1].add_prompt("relax> j_coupling.copy('DMSO', 'CDCl3')") 
 76  uf.desc[-1].add_prompt("relax> j_coupling.copy(pipe_from='DMSO', pipe_to='CDCl3')") 
 77  uf.backend = j_coupling.copy 
 78  uf.menu_text = "cop&y" 
 79  uf.gui_icon = "oxygen.actions.list-add" 
 80  uf.wizard_size = (750, 450) 
 81  uf.wizard_image = WIZARD_IMAGE_PATH + 'j_coupling.png' 
 82   
 83   
 84  # The j_coupling.delete user function. 
 85  uf = uf_info.add_uf('j_coupling.delete') 
 86  uf.title = "Delete the J coupling values." 
 87  uf.title_short = "J coupling deletion." 
 88  # Description. 
 89  uf.desc.append(Desc_container()) 
 90  uf.desc[-1].add_paragraph("This will delete all J coupling data in the current data pipe.") 
 91  # Prompt examples. 
 92  uf.desc.append(Desc_container("Prompt examples")) 
 93  uf.desc[-1].add_paragraph("To delete all J coupling data, type:") 
 94  uf.desc[-1].add_prompt("relax> j_coupling.delete()") 
 95  uf.backend = j_coupling.delete 
 96  uf.menu_text = "&delete" 
 97  uf.gui_icon = "oxygen.actions.list-remove" 
 98  uf.wizard_size = (750, 450) 
 99  uf.wizard_image = WIZARD_IMAGE_PATH + 'j_coupling.png' 
100   
101   
102  # The j_coupling.display user function. 
103  uf = uf_info.add_uf('j_coupling.display') 
104  uf.title = "Display the J coupling data in the current data pipe." 
105  uf.title_short = "J coupling display." 
106  uf.display = True 
107  # Description. 
108  uf.desc.append(Desc_container()) 
109  uf.desc[-1].add_paragraph("This will display all of the J coupling data in the current data pipe.") 
110  # Prompt examples. 
111  uf.desc.append(Desc_container("Prompt examples")) 
112  uf.desc[-1].add_paragraph("To display all J coupling data, type:") 
113  uf.desc[-1].add_prompt("relax> j_coupling.display()") 
114  uf.backend = j_coupling.display 
115  uf.menu_text = "di&splay" 
116  uf.gui_icon = "oxygen.actions.document-preview" 
117  uf.wizard_size = (750, 450) 
118  uf.wizard_image = WIZARD_IMAGE_PATH + 'j_coupling.png' 
119   
120   
121  # The j_coupling.read user function. 
122  uf = uf_info.add_uf('j_coupling.read') 
123  uf.title = "Read the J coupling data from file." 
124  uf.title_short = "J coupling data reading." 
125  uf.add_keyarg( 
126      name = "file", 
127      py_type = "str", 
128      arg_type = "file sel", 
129      desc_short = "file name", 
130      desc = "The name of the file containing the J coupling data.", 
131      wiz_filesel_style = FD_OPEN 
132  ) 
133  uf.add_keyarg( 
134      name = "dir", 
135      py_type = "str", 
136      arg_type = "dir", 
137      desc_short = "directory name", 
138      desc = "The directory where the file is located.", 
139      can_be_none = True 
140  ) 
141  uf.add_keyarg( 
142      name = "spin_id1_col", 
143      default = 1, 
144      py_type = "int", 
145      min = 1, 
146      desc_short = "first spin ID column", 
147      desc = "The spin ID string column for the first spin." 
148  ) 
149  uf.add_keyarg( 
150      name = "spin_id2_col", 
151      default = 2, 
152      py_type = "int", 
153      min = 1, 
154      desc_short = "second spin ID column", 
155      desc = "The spin ID string column for the second spin." 
156  ) 
157  uf.add_keyarg( 
158      name = "data_col", 
159      py_type = "int", 
160      desc_short = "data column", 
161      desc = "The J coupling data column.", 
162      can_be_none = True 
163  ) 
164  uf.add_keyarg( 
165      name = "error_col", 
166      py_type = "int", 
167      desc_short = "error column", 
168      desc = "The experimental error column.", 
169      can_be_none = True 
170  ) 
171  uf.add_keyarg( 
172      name = "sign_col", 
173      py_type = "int", 
174      desc_short = "sign column", 
175      desc = "A special column holding the sign of the J coupling, being either 1 or -1, in case this data is obtained separately.", 
176      can_be_none = True 
177  ) 
178  uf.add_keyarg( 
179      name = "sep", 
180      py_type = "str", 
181      desc_short = "column separator", 
182      desc = "The column separator (the default is white space).", 
183      wiz_element_type = "combo", 
184      wiz_combo_choices = ["white space", ",", ";", ":"], 
185      wiz_combo_data = [None, ",", ";", ":"], 
186      wiz_read_only = False, 
187      can_be_none = True 
188  ) 
189  # Description. 
190  uf.desc.append(Desc_container()) 
191  uf.desc[-1].add_paragraph("This will read J coupling data from a file.  If the sign of the J coupling has been determined by a different experiment, this information can be present in a different column having either the value of 1 or -1.") 
192  # Prompt examples. 
193  uf.desc.append(Desc_container("Prompt examples")) 
194  uf.desc[-1].add_paragraph("The following commands will read the J coupling data out of the file 'J.txt' where the columns are separated by the symbol ',':") 
195  uf.desc[-1].add_prompt("relax> j_coupling.read('J.txt', sep=',')") 
196  uf.desc[-1].add_paragraph("If the individual spin J coupling errors are located in the file 'j_err.txt' in column number 5 then, to read these values into relax, type one of:") 
197  uf.desc[-1].add_prompt("relax> j_coupling.read('j_err.txt', error_col=5)") 
198  uf.desc[-1].add_prompt("relax> j_coupling.read(file='j_err.txt', error_col=5)") 
199  uf.backend = j_coupling.read 
200  uf.menu_text = "&read" 
201  uf.gui_icon = "oxygen.actions.document-open" 
202  uf.wizard_height_desc = 300 
203  uf.wizard_size = (1000, 750) 
204  uf.wizard_image = WIZARD_IMAGE_PATH + 'j_coupling.png' 
205   
206   
207  # The j_coupling.write user function. 
208  uf = uf_info.add_uf('j_coupling.write') 
209  uf.title = "Write the J coupling data to file." 
210  uf.title_short = "J coupling writing." 
211  uf.add_keyarg( 
212      name = "file", 
213      py_type = "str", 
214      arg_type = "file sel", 
215      desc_short = "file name", 
216      desc = "The name of the file.", 
217      wiz_filesel_style = FD_SAVE 
218  ) 
219  uf.add_keyarg( 
220      name = "dir", 
221      py_type = "str", 
222      arg_type = "dir", 
223      desc_short = "directory name", 
224      desc = "The directory name.", 
225      can_be_none = True 
226  ) 
227  uf.add_keyarg( 
228      name = "force", 
229      default = False, 
230      py_type = "bool", 
231      desc_short = "force flag", 
232      desc = "A flag which if True will cause the file to be overwritten." 
233  ) 
234  # Description. 
235  uf.desc.append(Desc_container()) 
236  uf.desc[-1].add_paragraph("This will write the J coupling values to file.  If no directory name is given, the file will be placed in the current working directory.") 
237  uf.backend = j_coupling.write 
238  uf.menu_text = "&write" 
239  uf.gui_icon = "oxygen.actions.document-save" 
240  uf.wizard_size = (800, 500) 
241  uf.wizard_image = WIZARD_IMAGE_PATH + 'j_coupling.png' 
242