Package prompt :: Module spin
[hide private]
[frames] | no frames]

Source Code for Module prompt.spin

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2011 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  """Module containing the 'spin' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import User_fn_class, _build_doc 
 29  import arg_check 
 30  from generic_fns.mol_res_spin import copy_spin, create_pseudo_spin, create_spin, delete_spin, display_spin, id_string_doc, name_spin, number_spin, set_spin_element 
 31   
 32   
33 -class Spin(User_fn_class):
34 """Class for manipulating the spin data.""" 35
36 - def copy(self, pipe_from=None, spin_from=None, pipe_to=None, spin_to=None):
37 # Function intro text. 38 if self._exec_info.intro: 39 text = self._exec_info.ps3 + "spin.copy(" 40 text = text + "pipe_from=" + repr(pipe_from) 41 text = text + ", spin_from=" + repr(spin_from) 42 text = text + ", pipe_to=" + repr(pipe_to) 43 text = text + ", spin_to=" + repr(spin_to) + ")" 44 print(text) 45 46 # The argument checks. 47 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True) 48 arg_check.is_str(spin_from, 'spin from') 49 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True) 50 arg_check.is_str(spin_to, 'spin to', can_be_none=True) 51 52 # Execute the functional code. 53 copy_spin(pipe_from=pipe_from, spin_from=spin_from, pipe_to=pipe_to, spin_to=spin_to)
54 55 # The function doc info. 56 copy._doc_title = "Copy all data associated with a spin." 57 copy._doc_title_short = "Spin copying." 58 copy._doc_args = [ 59 ["pipe_from", "The data pipe containing the spin from which the data will be copied. This defaults to the current data pipe."], 60 ["spin_from", "The spin identifier string of the spin to copy the data from."], 61 ["pipe_to", "The data pipe to copy the data to. This defaults to the current data pipe."], 62 ["spin_to", "The spin identifier string of the spin to copy the data to."]] 63 copy._doc_desc = """ 64 This will copy all the data associated with the identified spin to the new, non-existent spin. The new spin must not already exist. 65 """ 66 copy._doc_examples = """ 67 To copy the spin data from spin 1 to the new spin 2, type: 68 69 relax> spin.copy(spin_from='@1', spin_to='@2') 70 71 72 To copy spin 1 of the molecule 'Old mol' to spin 5 of the molecule 'New mol', type: 73 74 relax> spin.copy(spin_from='#Old mol@1', spin_to='#New mol@5') 75 76 77 To copy the spin data of spin 1 from the data pipe 'm1' to 'm2', assuming the current 78 data pipe is 'm1', type: 79 80 relax> spin.copy(spin_from='@1', pipe_to='m2') 81 relax> spin.copy(pipe_from='m1', spin_from='@1', pipe_to='m2', spin_to='@1') 82 """ 83 _build_doc(copy) 84 85
86 - def create(self, spin_num=None, spin_name=None, res_num=None, res_name=None, mol_name=None):
87 # Function intro text. 88 if self._exec_info.intro: 89 text = self._exec_info.ps3 + "spin.create(" 90 text = text + "spin_num=" + repr(spin_num) 91 text = text + ", spin_name=" + repr(spin_name) 92 text = text + ", res_num=" + repr(res_num) 93 text = text + ", res_name=" + repr(res_name) 94 text = text + ", mol_name=" + repr(mol_name) + ")" 95 print(text) 96 97 # The argument checks. 98 arg_check.is_int(spin_num, 'spin number', can_be_none=True) 99 arg_check.is_str(spin_name, 'spin name', can_be_none=True) 100 arg_check.is_int(res_num, 'residue number', can_be_none=True) 101 arg_check.is_str(res_name, 'residue name', can_be_none=True) 102 arg_check.is_str(mol_name, 'molecule name', can_be_none=True) 103 104 # Execute the functional code. 105 create_spin(spin_num=spin_num, spin_name=spin_name, res_num=res_num, res_name=res_name, mol_name=mol_name)
106 107 # The function doc info. 108 create._doc_title = "Create a new spin." 109 create._doc_title_short = "Spin creation." 110 create._doc_args = [ 111 ["spin_num", "The spin number."], 112 ["spin_name", "The name of the spin."], 113 ["res_num", "The number of the residue to add the spin to."], 114 ["res_name", "The name of the residue to add the spin to."], 115 ["mol_name", "The name of the molecule to add the spin to."]] 116 create._doc_desc = """ 117 This will add a new spin data container to the relax data storage object. The same spin number cannot be used more than once. 118 """ 119 create._doc_examples = """ 120 The following sequence of commands will generate the sequence 1 C4, 2 C9, 3 C15: 121 122 relax> spin.create(1, 'C4') 123 relax> spin.create(2, 'C9') 124 relax> spin.create(3, 'C15') 125 """ 126 _build_doc(create) 127 128
129 - def create_pseudo(self, spin_name=None, spin_num=None, res_id=None, members=None, averaging='linear'):
130 # Function intro text. 131 if self._exec_info.intro: 132 text = self._exec_info.ps3 + "spin.create_pseudo(" 133 text = text + "spin_name=" + repr(spin_name) 134 text = text + ", spin_num=" + repr(spin_num) 135 text = text + ", res_id=" + repr(res_id) 136 text = text + ", members=" + repr(members) 137 text = text + ", averaging=" + repr(averaging) + ")" 138 print(text) 139 140 # The argument checks. 141 arg_check.is_str(spin_name, 'spin name') 142 arg_check.is_int(spin_num, 'spin number', can_be_none=True) 143 arg_check.is_str(res_id, 'residue ID string', can_be_none=True) 144 arg_check.is_str_list(members, 'members') 145 arg_check.is_str(averaging, 'positional averaging technique') 146 147 # Execute the functional code. 148 create_pseudo_spin(spin_num=spin_num, spin_name=spin_name, res_id=res_id, members=members, averaging=averaging)
149 150 # The function doc info. 151 create_pseudo._doc_title = "Create a spin system representing a pseudo-atom." 152 create_pseudo._doc_title_short = "Pseudo-atom creation." 153 create_pseudo._doc_args = [ 154 ["spin_name", "The name of the pseudo-atom spin."], 155 ["spin_num", "The spin number."], 156 ["res_id", "The molecule and residue ID string identifying the position to add the pseudo-spin to."], 157 ["members", "A list of the atoms (as spin ID strings) that the pseudo-atom is composed of."], 158 ["averaging", "The positional averaging technique."]] 159 create_pseudo._doc_desc = """ 160 This will create a spin data container representing a number of pre-existing spin containers as a pseudo-atom. The optional spin number must not already exist. 161 """ 162 create_pseudo._doc_examples = """ 163 The following will create the pseudo-atom named 'Q9' consisting of the protons '@H16', 164 '@H17', '@H18': 165 166 relax> spin.create_pseudo('Q9', members=['@H16', '@H17', '@H18']) 167 """ 168 create_pseudo._doc_additional = [id_string_doc] 169 _build_doc(create_pseudo) 170 171
172 - def delete(self, spin_id=None):
173 # Function intro text. 174 if self._exec_info.intro: 175 text = self._exec_info.ps3 + "spin.delete(" 176 text = text + "spin_id=" + repr(spin_id) + ")" 177 print(text) 178 179 # The argument checks. 180 arg_check.is_str(spin_id, 'spin identification string') 181 182 # Execute the functional code. 183 delete_spin(spin_id=spin_id)
184 185 # The function doc info. 186 delete._doc_title = "Delete spins." 187 delete._doc_title_short = "Spin deletion." 188 delete._doc_args = [ 189 ["spin_id", "The spin identifier string."]] 190 delete._doc_desc = """ 191 This can be used to delete a single or sets of spins. See the identification string documentation below for more information. 192 """ 193 delete._doc_additional = [id_string_doc] 194 _build_doc(delete) 195 196
197 - def display(self, spin_id=None):
198 # Function intro text. 199 if self._exec_info.intro: 200 text = self._exec_info.ps3 + "spin.display(" 201 text = text + "spin_id=" + repr(spin_id) + ")" 202 print(text) 203 204 # The argument checks. 205 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True) 206 207 # Execute the functional code. 208 display_spin(spin_id=spin_id)
209 210 # The function doc info. 211 display._doc_title = "Display information about the spin(s)." 212 display._doc_title_short = "Spin information." 213 display._doc_args = [ 214 ["spin_id", "The spin identification string."]] 215 display._doc_additional = [id_string_doc] 216 _build_doc(display) 217 218
219 - def element(self, spin_id=None, element=None, force=False):
220 # Function intro text. 221 if self._exec_info.intro: 222 text = self._exec_info.ps3 + "spin.element(" 223 text = text + "spin_id=" + repr(spin_id) 224 text = text + ", element=" + repr(element) 225 text = text + ", force=" + repr(force) + ")" 226 print(text) 227 228 # The argument checks. 229 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True) 230 arg_check.is_str(element, 'IUPAC element name') 231 arg_check.is_bool(force, 'force flag') 232 233 # Execute the functional code. 234 set_spin_element(spin_id=spin_id, element=element, force=force)
235 236 # The function doc info. 237 element._doc_title = "Set the element type of the spin." 238 element._doc_title_short = "Spin element setting." 239 element._doc_args = [ 240 ["spin_id", "The spin identification string corresponding to one or more spins."], 241 ["element", "The IUPAC element name."], 242 ["force", "A flag which if True will cause the element to be changed."]] 243 element._doc_desc = """ 244 This allows the element type of the spins to be set. 245 """ 246 element._doc_examples = """ 247 The set all spins of residue 1 to be carbons, type one of: 248 249 relax> spin.element('@1', 'C', force=True) 250 relax> spin.element(spin_id='@1', element='C', force=True) 251 """ 252 element._doc_additional = [id_string_doc] 253 _build_doc(element) 254 255
256 - def name(self, spin_id=None, name=None, force=False):
257 # Function intro text. 258 if self._exec_info.intro: 259 text = self._exec_info.ps3 + "spin.name(" 260 text = text + "spin_id=" + repr(spin_id) 261 text = text + ", name=" + repr(name) 262 text = text + ", force=" + repr(force) + ")" 263 print(text) 264 265 # The argument checks. 266 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True) 267 arg_check.is_str(name, 'new spin name') 268 arg_check.is_bool(force, 'force flag') 269 270 # Execute the functional code. 271 name_spin(spin_id=spin_id, name=name, force=force)
272 273 # The function doc info. 274 name._doc_title = "Name the spins." 275 name._doc_title_short = "Spin naming." 276 name._doc_args = [ 277 ["spin_id", "The spin identification string corresponding to one or more spins."], 278 ["name", "The new name."], 279 ["force", "A flag which if True will cause the spin to be renamed."]] 280 name._doc_desc = """ 281 This simply allows spins to be named (or renamed). Spin naming often essential. For example when reading Sparky peak list files, then the spin name must match that in the file. 282 """ 283 name._doc_examples = """ 284 The following sequence of commands will rename the sequence {1 C1, 2 C2, 3 C3} to {1 C11, 285 2 C12, 3 C13}: 286 287 relax> spin.name('@1', 'C11', force=True) 288 relax> spin.name('@2', 'C12', force=True) 289 relax> spin.name('@3', 'C13', force=True) 290 """ 291 name._doc_additional = [id_string_doc] 292 _build_doc(name) 293 294
295 - def number(self, spin_id=None, number=None, force=False):
296 # Function intro text. 297 if self._exec_info.intro: 298 text = self._exec_info.ps3 + "spin.number(" 299 text = text + "spin_id=" + repr(spin_id) 300 text = text + ", number=" + repr(number) 301 text = text + ", force=" + repr(force) + ")" 302 print(text) 303 304 # The argument checks. 305 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True) 306 arg_check.is_int(number, 'new spin number', can_be_none=True) 307 arg_check.is_bool(force, 'force flag') 308 309 # Execute the functional code. 310 number_spin(spin_id=spin_id, number=number, force=force)
311 312 # The function doc info. 313 number._doc_title = "Number the spins." 314 number._doc_title_short = "Spin numbering." 315 number._doc_args = [ 316 ["spin_id", "The spin identification string corresponding to a single spin."], 317 ["number", "The new spin number."], 318 ["force", "A flag which if True will cause the spin to be renumbered."]] 319 number._doc_desc = """ 320 This simply allows spins to be numbered. The new number cannot correspond to an existing spin number. 321 """ 322 number._doc_examples = """ 323 The following sequence of commands will renumber the sequence {1 C1, 2 C2, 3 C3} to 324 {-1 C1, -2 C2, -3 C3}: 325 326 relax> spin.number('@1', -1, force=True) 327 relax> spin.number('@2', -2, force=True) 328 relax> spin.number('@3', -3, force=True) 329 """ 330 number._doc_additional = [id_string_doc] 331 _build_doc(number)
332