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

Source Code for Module user_functions.j_coupling

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