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

Source Code for Module prompt.residue

  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 'residue' 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_residue, create_residue, delete_residue, display_residue, id_string_doc, name_residue, number_residue 
 31   
 32   
33 -class Residue(User_fn_class):
34 """Class for manipulating the residue data.""" 35
36 - def copy(self, pipe_from=None, res_from=None, pipe_to=None, res_to=None):
37 # Function intro text. 38 if self._exec_info.intro: 39 text = self._exec_info.ps3 + "residue.copy(" 40 text = text + "pipe_from=" + repr(pipe_from) 41 text = text + ", res_from=" + repr(res_from) 42 text = text + ", pipe_to=" + repr(pipe_to) 43 text = text + ", res_to=" + repr(res_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(res_from, 'residue from') 49 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True) 50 arg_check.is_str(res_to, 'residue to', can_be_none=True) 51 52 # Execute the functional code. 53 copy_residue(pipe_from=pipe_from, res_from=res_from, pipe_to=pipe_to, res_to=res_to)
54 55 # The function doc info. 56 copy._doc_title = "Copy all data associated with a residue." 57 copy._doc_title_short = "Residue copying." 58 copy._doc_args = [ 59 ["pipe_from", "The data pipe containing the residue from which the data will be copied. This defaults to the current data pipe."], 60 ["res_from", "The residue ID string of the residue to copy the data from."], 61 ["pipe_to", "The data pipe to copy the data to. This defaults to the current data pipe."], 62 ["res_to", "The residue ID string of the residue to copy the data to."]] 63 copy._doc_desc = """ 64 This will copy all the data associated with the identified residue to the new, non-existent residue. The new residue cannot currently exist. 65 """ 66 copy._doc_examples = """ 67 To copy the residue data from residue 1 to the new residue 2, type: 68 69 relax> residue.copy(res_from=':1', res_to=':2') 70 71 72 To copy residue 1 of the molecule 'Old mol' to residue 5 of the molecule 'New mol', type: 73 74 relax> residue.copy(res_from='#Old mol:1', res_to='#New mol:5') 75 76 77 To copy the residue data of residue 1 from the data pipe 'm1' to 'm2', assuming the current 78 data pipe is 'm1', type: 79 80 relax> residue.copy(res_from=':1', pipe_to='m2') 81 relax> residue.copy(pipe_from='m1', res_from=':1', pipe_to='m2', res_to=':1') 82 """ 83 _build_doc(copy) 84 85
86 - def create(self, 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 + "residue.create(" 90 text = text + "res_num=" + repr(res_num) 91 text = text + ", res_name=" + repr(res_name) 92 text = text + ", mol_name=" + repr(mol_name) + ")" 93 print(text) 94 95 # The argument checks. 96 arg_check.is_int(res_num, 'residue number') 97 arg_check.is_str(res_name, 'residue name', can_be_none=True) 98 arg_check.is_str(mol_name, 'molecule name', can_be_none=True) 99 100 # Execute the functional code. 101 create_residue(res_num=res_num, res_name=res_name, mol_name=mol_name)
102 103 # The function doc info. 104 create._doc_title = "Create a new residue." 105 create._doc_title_short = "Residue creation." 106 create._doc_args = [ 107 ["res_num", "The residue number."], 108 ["res_name", "The name of the residue."], 109 ["mol_name", "The name of the molecule to add the residue to."]] 110 create._doc_desc = """ 111 Using this, a new sequence can be generated without using the sequence user functions. However if the sequence already exists, the new residue will be added to the end of the residue list (the residue numbers of this list need not be sequential). The same residue number cannot be used more than once. A corresponding single spin system will be created for this residue. The spin system number and name or additional spin systems can be added later if desired. 112 """ 113 create._doc_examples = """ 114 The following sequence of commands will generate the sequence 1 ALA, 2 GLY, 3 LYS: 115 116 relax> residue.create(1, 'ALA') 117 relax> residue.create(2, 'GLY') 118 relax> residue.create(3, 'LYS') 119 """ 120 _build_doc(create) 121 122
123 - def delete(self, res_id=None):
124 # Function intro text. 125 if self._exec_info.intro: 126 text = self._exec_info.ps3 + "residue.delete(" 127 text = text + "res_id=" + repr(res_id) + ")" 128 print(text) 129 130 # The argument checks. 131 arg_check.is_str(res_id, 'residue ID string') 132 133 # Execute the functional code. 134 delete_residue(res_id=res_id)
135 136 # The function doc info. 137 delete._doc_title = "Delete residues from the current data pipe." 138 delete._doc_title_short = "Residue deletion." 139 delete._doc_args = [ 140 ["res_id", "The residue ID string."]] 141 delete._doc_desc = """ 142 This can be used to delete a single or sets of residues. See the ID string documentation for more information. If spin system/atom ids are included a RelaxError will be raised. 143 """ 144 delete._doc_additional = [id_string_doc] 145 _build_doc(delete) 146 147
148 - def display(self, res_id=None):
149 # Function intro text. 150 if self._exec_info.intro: 151 text = self._exec_info.ps3 + "residue.display(" 152 text = text + "res_id=" + repr(res_id) + ")" 153 print(text) 154 155 # The argument checks. 156 arg_check.is_str(res_id, 'residue ID string', can_be_none=True) 157 158 # Execute the functional code. 159 display_residue(res_id=res_id)
160 161 # The function doc info. 162 display._doc_title = "Display information about the residue(s)." 163 display._doc_args = [ 164 ["res_id", "The residue ID string."]] 165 display._doc_additional = [id_string_doc] 166 _build_doc(display) 167 168
169 - def name(self, res_id=None, name=None, force=False):
170 # Function intro text. 171 if self._exec_info.intro: 172 text = self._exec_info.ps3 + "residue.name(" 173 text = text + "res_id=" + repr(res_id) 174 text = text + ", name=" + repr(name) 175 text = text + ", force=" + repr(force) + ")" 176 print(text) 177 178 # The argument checks. 179 arg_check.is_str(res_id, 'residue ID string') 180 arg_check.is_str(name, 'new residue name') 181 arg_check.is_bool(force, 'force flag') 182 183 # Execute the functional code. 184 name_residue(res_id=res_id, name=name, force=force)
185 186 # The function doc info. 187 name._doc_title = "Name the residues." 188 name._doc_title_short = "Residue naming." 189 name._doc_args = [ 190 ["res_id", "The residue ID string corresponding to one or more residues."], 191 ["name", "The new name."], 192 ["force", "A flag which if True will cause the residue to be renamed."]] 193 name._doc_desc = """ 194 This simply allows residues to be named (or renamed). 195 """ 196 name._doc_examples = """ 197 The following sequence of commands will rename the sequence {1 ALA, 2 GLY, 3 LYS} to {1 XXX, 198 2 XXX, 3 XXX}: 199 200 relax> residue.name(':1', 'XXX', force=True) 201 relax> residue.name(':2', 'XXX', force=True) 202 relax> residue.name(':3', 'XXX', force=True) 203 204 Alternatively: 205 206 relax> residue.name(':1,2,3', 'XXX', force=True) 207 """ 208 name._doc_additional = [id_string_doc] 209 _build_doc(name) 210 211
212 - def number(self, res_id=None, number=None, force=False):
213 # Function intro text. 214 if self._exec_info.intro: 215 text = self._exec_info.ps3 + "residue.number(" 216 text = text + "res_id=" + repr(res_id) 217 text = text + ", number=" + repr(number) 218 text = text + ", force=" + repr(force) + ")" 219 print(text) 220 221 # The argument checks. 222 arg_check.is_str(res_id, 'residue ID string') 223 arg_check.is_int(number, 'new residue number') 224 arg_check.is_bool(force, 'force flag') 225 226 # Execute the functional code. 227 number_residue(res_id=res_id, number=number, force=force)
228 229 # The function doc info. 230 number._doc_title = "Number the residues." 231 number._doc_title_short = "Residue numbering." 232 number._doc_args = [ 233 ["res_id", "The residue ID string corresponding to a single residue."], 234 ["number", "The new residue number."], 235 ["force", "A flag which if True will cause the residue to be renumbered."]] 236 number._doc_desc = """ 237 This simply allows residues to be numbered. The new number cannot correspond to an existing residue. 238 """ 239 number._doc_examples = """ 240 The following sequence of commands will renumber the sequence {1 ALA, 2 GLY, 3 LYS} to 241 {101 ALA, 102 GLY, 103 LYS}: 242 243 relax> residue.number(':1', 101, force=True) 244 relax> residue.number(':2', 102, force=True) 245 relax> residue.number(':3', 103, force=True) 246 """ 247 number._doc_additional = [id_string_doc] 248 _build_doc(number)
249