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

Source Code for Module prompt.molecule

  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 'molecule' 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 ALLOWED_MOL_TYPES, copy_molecule, create_molecule, delete_molecule, display_molecule, id_string_doc, name_molecule, type_molecule 
 31   
 32   
33 -class Molecule(User_fn_class):
34 """Class for manipulating the molecule data.""" 35
36 - def copy(self, pipe_from=None, mol_from=None, pipe_to=None, mol_to=None):
37 # Function intro text. 38 if self._exec_info.intro: 39 text = self._exec_info.ps3 + "molecule.copy(" 40 text = text + "pipe_from=" + repr(pipe_from) 41 text = text + ", mol_from=" + repr(mol_from) 42 text = text + ", pipe_to=" + repr(pipe_to) 43 text = text + ", mol_to=" + repr(mol_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(mol_from, 'molecule from') 49 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True) 50 arg_check.is_str(mol_to, 'molecule to', can_be_none=True) 51 52 # Execute the functional code. 53 copy_molecule(pipe_from=pipe_from, mol_from=mol_from, pipe_to=pipe_to, mol_to=mol_to)
54 55 # The function doc info. 56 copy._doc_title = "Copy all data associated with a molecule." 57 copy._doc_title_short = "Molecule copying." 58 copy._doc_args = [ 59 ["pipe_from", "The data pipe containing the molecule from which the data will be copied. This defaults to the current data pipe."], 60 ["mol_from", "The name of the molecule from which to copy data from."], 61 ["pipe_to", "The data pipe to copy the data to. This defaults to the current data pipe."], 62 ["mol_to", "The name of the new molecule. If left blank, the new molecule will have the same name as the old."]] 63 copy._doc_desc = """ 64 This will copy all the data associated with a molecule to a second molecule. This includes all residue and spin system information. The new molecule name must be unique in the destination data pipe. 65 """ 66 copy._doc_examples = """ 67 To copy the molecule data from the molecule 'GST' to the new molecule 'wt-GST', type: 68 69 relax> molecule.copy('#GST', '#wt-GST') 70 relax> molecule.copy(mol_from='#GST', mol_to='#wt-GST') 71 72 73 To copy the molecule data of the molecule 'Ap4Aase' from the data pipe 'm1' to 'm2', assuming the current 74 data pipe is 'm1', type: 75 76 relax> molecule.copy(mol_from='#ApAase', pipe_to='m2') 77 relax> molecule.copy(pipe_from='m1', mol_from='#ApAase', pipe_to='m2', mol_to='#ApAase') 78 """ 79 _build_doc(copy) 80 81
82 - def create(self, mol_name=None, mol_type=None):
83 # Function intro text. 84 if self._exec_info.intro: 85 text = self._exec_info.ps3 + "molecule.create(" 86 text = text + "mol_name=" + repr(mol_name) 87 text = text + ", mol_type=" + repr(mol_type) + ")" 88 print(text) 89 90 # The argument checks. 91 arg_check.is_str(mol_name, 'molecule name') 92 arg_check.is_str(mol_type, 'molecule type', can_be_none=True) 93 94 # Execute the functional code. 95 create_molecule(mol_name=mol_name, mol_type=mol_type)
96 97 # The function doc info. 98 create._doc_title = "Create a new molecule." 99 create._doc_title_short = "Molecule creation." 100 create._doc_args = [ 101 ["mol_name", "The name of the new molecule."], 102 ["mol_type", "The type of molecule."]] 103 create._doc_desc = """ 104 This adds a new molecule data container to the relax data storage object. The same molecule name cannot be used more than once. The molecule type need not be specified. However, if given, it should be one of""" 105 for _i in range(len(ALLOWED_MOL_TYPES)): 106 create._doc_desc = "%s '%s'," % (create._doc_desc, ALLOWED_MOL_TYPES[_i]) 107 create._doc_desc = "%s or '%s'." % (create._doc_desc, ALLOWED_MOL_TYPES[-1]) 108 create._doc_examples = """ 109 To create the molecules 'Ap4Aase', 'ATP', and 'MgF4', type: 110 111 relax> molecule.create('Ap4Aase') 112 relax> molecule.create('ATP') 113 relax> molecule.create('MgF4') 114 """ 115 _build_doc(create) 116 117
118 - def delete(self, mol_id=None):
119 # Function intro text. 120 if self._exec_info.intro: 121 text = self._exec_info.ps3 + "molecule.delete(" 122 text = text + "mol_id=" + repr(mol_id) + ")" 123 print(text) 124 125 # The argument checks. 126 arg_check.is_str(mol_id, 'molecule ID string') 127 128 # Execute the functional code. 129 delete_molecule(mol_id=mol_id)
130 131 # The function doc info. 132 delete._doc_title = "Deleting molecules from the relax data store." 133 delete._doc_title_short = "Molecule deletion." 134 delete._doc_args = [ 135 ["mol_id", "The molecule ID string."]] 136 delete._doc_desc = """ 137 This can be used to delete a single or sets of molecules from the relax data store. The molecule will be deleted from the current data pipe. 138 """ 139 delete._doc_additional = [id_string_doc] 140 _build_doc(delete) 141 142
143 - def display(self, mol_id=None):
144 # Function intro text. 145 if self._exec_info.intro: 146 text = self._exec_info.ps3 + "molecule.display(" 147 text = text + "mol_id=" + repr(mol_id) + ")" 148 print(text) 149 150 # The argument checks. 151 arg_check.is_str(mol_id, 'molecule ID string', can_be_none=True) 152 153 # Execute the functional code. 154 display_molecule(mol_id=mol_id)
155 156 # The function doc info. 157 display._doc_title = "Display the molecule information." 158 display._doc_title_short = "Molecule information." 159 display._doc_args = [ 160 ["mol_id", "The molecule ID string."]] 161 display._doc_additional = [id_string_doc] 162 _build_doc(display) 163 164
165 - def name(self, mol_id=None, name=None, force=False):
166 # Function intro text. 167 if self._exec_info.intro: 168 text = self._exec_info.ps3 + "molecule.name(" 169 text = text + "mol_id=" + repr(mol_id) 170 text = text + ", name=" + repr(name) 171 text = text + ", force=" + repr(force) + ")" 172 print(text) 173 174 # The argument checks. 175 arg_check.is_str(mol_id, 'molecule ID string', can_be_none=True) 176 arg_check.is_str(name, 'new molecule name') 177 arg_check.is_bool(force, 'force flag') 178 179 # Execute the functional code. 180 name_molecule(mol_id=mol_id, name=name, force=force)
181 182 # The function doc info. 183 name._doc_title = "Name a molecule." 184 name._doc_args = [ 185 ["mol_id", "The molecule ID string corresponding to one or more molecules."], 186 ["name", "The new molecule name."], 187 ["force", "A flag which if True will cause the molecule to be renamed."]] 188 name._doc_desc = """ 189 This simply allows molecules to be named (or renamed). 190 """ 191 name._doc_examples = """ 192 To rename the molecule 'Ap4Aase' to 'Inhib Ap4Aase', type one of: 193 194 relax> molecule.name('#Ap4Aase', 'Inhib Ap4Aase', True) 195 relax> molecule.name(mol_id='#Ap4Aase', name='Inhib Ap4Aase', force=True) 196 197 This assumes the molecule 'Ap4Aase' already exists. 198 """ 199 name._doc_additional = [id_string_doc] 200 _build_doc(name) 201 202
203 - def type(self, mol_id=None, type=None, force=False):
204 # Function intro text. 205 if self._exec_info.intro: 206 text = self._exec_info.ps3 + "molecule.type(" 207 text = text + "mol_id=" + repr(mol_id) 208 text = text + ", type=" + repr(type) 209 text = text + ", force=" + repr(force) + ")" 210 print(text) 211 212 # The argument checks. 213 arg_check.is_str(mol_id, 'molecule ID string', can_be_none=True) 214 arg_check.is_str(type, 'molecule type') 215 arg_check.is_bool(force, 'force flag') 216 217 # Execute the functional code. 218 type_molecule(mol_id=mol_id, type=type, force=force)
219 220 # The function doc info. 221 type._doc_title = "Set the molecule type." 222 type._doc_title_short = "Setting molecule type." 223 type._doc_args = [ 224 ["mol_id", "The molecule ID string corresponding to one or more molecules."], 225 ["type", "The molecule type."], 226 ["force", "A flag which if True will cause the molecule to type to be overwritten."]] 227 type._doc_desc = """ 228 This allows the type of the molecule to be specified. It can be one of: 229 230 """ 231 for _i in range(len(ALLOWED_MOL_TYPES)): 232 type._doc_desc = "%s '%s',\n" % (type._doc_desc, ALLOWED_MOL_TYPES[_i]) 233 type._doc_desc = "%s '%s'.\n" % (type._doc_desc, ALLOWED_MOL_TYPES[-1]) 234 type._doc_examples = """ 235 To set the molecule 'Ap4Aase' to the 'protein' type, type one of: 236 237 relax> molecule.type('#Ap4Aase', 'protein', True) 238 relax> molecule.type(mol_id='#Ap4Aase', type='protein', force=True) 239 """ 240 type._doc_additional = [id_string_doc] 241 _build_doc(type)
242