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

Source Code for Module prompt.molmol

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2012 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 'molmol' user function class for interacting with MOLMOL.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import User_fn_class, _build_doc 
 29  import arg_check 
 30  import colour 
 31  from generic_fns import molmol 
 32  from specific_fns.model_free.molmol import Molmol 
 33   
 34   
35 -class Molmol(User_fn_class):
36 """Class for interfacing with Molmol.""" 37
38 - def clear_history(self):
39 # Function intro text. 40 if self._exec_info.intro: 41 text = self._exec_info.ps3 + "molmol.clear_history()" 42 print(text) 43 44 # Execute the functional code. 45 molmol.clear_history()
46 47 # The function doc info. 48 clear_history._doc_title = "Clear the Molmol command history." 49 clear_history._doc_title_short = "Clear Molmol history.""" 50 clear_history._doc_desc = """ 51 This will clear the Molmol history from memory. 52 """ 53 _build_doc(clear_history) 54 55
56 - def command(self, command=None):
57 # Function intro text. 58 if self._exec_info.intro: 59 text = self._exec_info.ps3 + "molmol.command(" 60 text = text + "command=" + repr(command) + ")" 61 print(text) 62 63 # The argument checks. 64 arg_check.is_str(command, 'MOLMOL command') 65 66 # Execute the functional code. 67 molmol.command(command=command)
68 69 # The function doc info. 70 command._doc_title = "Execute a user supplied Molmol command." 71 command._doc_title_short = "Molmol command execution." 72 command._doc_args = [ 73 ["command", "The Molmol command to execute."] 74 ] 75 command._doc_desc = """ 76 This allows Molmol commands to be passed to the program. This can be useful for automation or scripting. 77 """ 78 command._doc_examples = """ 79 To reinitialise the Molmol instance, type: 80 81 relax> molmol.command("InitAll yes") 82 """ 83 _build_doc(command) 84 85
86 - def macro_apply(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None):
87 # Function intro text. 88 if self._exec_info.intro: 89 text = self._exec_info.ps3 + "molmol.macro_apply(" 90 text = text + "data_type=" + repr(data_type) 91 text = text + ", style=" + repr(style) 92 text = text + ", colour_start=" + repr(colour_start) 93 text = text + ", colour_end=" + repr(colour_end) 94 text = text + ", colour_list=" + repr(colour_list) + ")" 95 print(text) 96 97 # The argument checks. 98 arg_check.is_str(data_type, 'data type') 99 arg_check.is_str(style, 'style') 100 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True) 101 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True) 102 arg_check.is_str(colour_list, 'colour list', can_be_none=True) 103 104 # Execute the functional code. 105 molmol.macro_apply(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list)
106 107 # The function doc info. 108 macro_apply._doc_title = "Execute Molmol macros." 109 macro_apply._doc_title_short = "Molmol macro execution." 110 macro_apply._doc_args = [ 111 ["data_type", "The data type to map to the structure."], 112 ["style", "The style of the macro."], 113 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."], 114 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."], 115 ["colour_list", "The list of colours to match the start and end strings."] 116 ] 117 macro_apply._doc_desc = """ 118 This allows spin specific values to be mapped to a structure through Molmol macros. Currently only the 'classic' style, which is described below, is available. 119 """ 120 macro_apply._doc_examples = """ 121 To map the order parameter values, S2, onto the structure using the classic style, type: 122 123 relax> molmol.macro_apply('s2') 124 relax> molmol.macro_apply(data_type='s2') 125 relax> molmol.macro_apply(data_type='s2', style="classic") 126 """ 127 macro_apply._doc_additional = [ 128 colour._linear_gradient_doc, 129 Molmol.classic_style_doc, 130 colour.__molmol_colours_prompt_doc__, 131 colour.__x11_colours_prompt_doc__ 132 ] 133 _build_doc(macro_apply) 134 135
136 - def macro_run(self, file=None, dir='molmol'):
137 # Function intro text. 138 if self._exec_info.intro: 139 text = self._exec_info.ps3 + "molmol.macro_run(" 140 text = text + "file=" + repr(file) 141 text = text + ", dir=" + repr(dir) + ")" 142 print(text) 143 144 # The argument checks. 145 arg_check.is_str(file, 'file name') 146 arg_check.is_str(dir, 'directory name', can_be_none=True) 147 148 # Execute the functional code. 149 molmol.macro_run(file=file, dir=dir)
150 151 # The function doc info. 152 macro_run._doc_title = "Open and execute the Molmol macro file." 153 macro_run._doc_title_short = "Molmol macro file execution." 154 macro_run._doc_args = [ 155 ["file", "The name of the Molmol macro file."], 156 ["dir", "The directory name."], 157 ] 158 macro_run._doc_desc = """ 159 This user function is for opening and running a Molmol macro located within a text file. 160 """ 161 macro_run._doc_examples = """ 162 To execute the macro file 's2.mac' located in the directory 'molmol', type: 163 164 relax> molmol.macro_run(file='s2.mac') 165 relax> molmol.macro_run(file='s2.mac', dir='molmol') 166 """ 167 _build_doc(macro_run) 168 169
170 - def macro_write(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir='molmol', force=False):
171 # Function intro text. 172 if self._exec_info.intro: 173 text = self._exec_info.ps3 + "molmol.macro_write(" 174 text = text + "data_type=" + repr(data_type) 175 text = text + ", style=" + repr(style) 176 text = text + ", colour_start=" + repr(colour_start) 177 text = text + ", colour_end=" + repr(colour_end) 178 text = text + ", colour_list=" + repr(colour_list) 179 text = text + ", file=" + repr(file) 180 text = text + ", dir=" + repr(dir) 181 text = text + ", force=" + repr(force) + ")" 182 print(text) 183 184 # The argument checks. 185 arg_check.is_str(data_type, 'data type') 186 arg_check.is_str(style, 'style') 187 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True) 188 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True) 189 arg_check.is_str(colour_list, 'colour list', can_be_none=True) 190 arg_check.is_str_or_inst(file, 'file name', can_be_none=True) 191 arg_check.is_str(dir, 'directory name', can_be_none=True) 192 arg_check.is_bool(force, 'force flag') 193 194 # Execute the functional code. 195 molmol.macro_write(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list, file=file, dir=dir, force=force)
196 197 # The function doc info. 198 macro_write._doc_title = "Create Molmol macros." 199 macro_write._doc_title_short = "Molmol macro creation." 200 macro_write._doc_args = [ 201 ["data_type", "The data type to map to the structure."], 202 ["style", "The style of the macro."], 203 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."], 204 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."], 205 ["colour_list", "The list of colours to match the start and end strings."], 206 ["file", "The name of the file."], 207 ["dir", "The directory name."], 208 ["force", "A flag which, if set to True, will cause the file to be overwritten."] 209 ] 210 macro_write._doc_desc = """ 211 This allows residues specific values to be mapped to a structure through the creation of a Molmol '*.mac' macro which can be executed in Molmol by clicking on 'File, Macro, Execute User...'. Currently only the 'classic' style, which is described below, is available. 212 """ 213 macro_write._doc_examples = """ 214 To create a Molmol macro mapping the order parameter values, S2, onto the structure using 215 the classic style, type: 216 217 relax> molmol.macro_write('s2') 218 relax> molmol.macro_write(data_type='s2') 219 relax> molmol.macro_write(data_type='s2', style="classic", file='s2.mac', dir='molmol') 220 """ 221 macro_write._doc_additional = [ 222 colour._linear_gradient_doc, 223 Molmol.classic_style_doc, 224 colour.__molmol_colours_prompt_doc__, 225 colour.__x11_colours_prompt_doc__ 226 ] 227 _build_doc(macro_write) 228 229
230 - def ribbon(self):
231 # Function intro text. 232 if self._exec_info.intro: 233 text = self._exec_info.ps3 + "molmol.ribbon()" 234 print(text) 235 236 # Execute the functional code. 237 molmol.ribbon()
238 239 # The function doc info. 240 ribbon._doc_title = "Apply the Molmol ribbon style." 241 ribbon._doc_title_short = "Molmol ribbon style application." 242 ribbon._doc_desc = """ 243 This applies the Molmol ribbon style which is equivalent to clicking on 'ribbon' in the Molmol side menu. To do this, the following commands are executed: 244 245 CalcAtom 'H' 246 CalcAtom 'HN' 247 CalcSecondary 248 XMacStand ribbon.mac 249 """ 250 ribbon._doc_examples = """ 251 To apply the ribbon style to the PDB file loaded, type: 252 253 relax> molmol.ribbon() 254 """ 255 _build_doc(ribbon) 256 257
258 - def tensor_pdb(self, file=None):
259 # Function intro text. 260 if self._exec_info.intro: 261 text = self._exec_info.ps3 + "molmol.tensor_pdb(" 262 text = text + "file=" + repr(file) + ")" 263 print(text) 264 265 # The argument checks. 266 arg_check.is_str_or_inst(file, 'file name') 267 268 # Execute the functional code. 269 molmol.tensor_pdb(file=file)
270 271 # The function doc info. 272 tensor_pdb._doc_title = "Display the diffusion tensor PDB geometric object over the loaded PDB." 273 tensor_pdb._doc_title_short = "Diffusion tensor and structure display." 274 tensor_pdb._doc_args = [ 275 ["file", "The name of the PDB file containing the tensor geometric object."] 276 ] 277 tensor_pdb._doc_desc = """ 278 In executing this user function, a PDB file must have previously been loaded , a geometric object or polygon representing the Brownian rotational diffusion tensor will be overlain with the loaded PDB file and displayed within Molmol. The PDB file containing the geometric object must be created using the complementary structure.create_diff_tensor_pdb user function. 279 280 To display the diffusion tensor, the multiple commands will be executed. To overlay the structure with the diffusion tensor, everything will be selected and reoriented and moved to their original PDB frame positions: 281 282 SelectAtom '' 283 SelectBond '' 284 SelectAngle '' 285 SelectDist '' 286 SelectPrim '' 287 RotateInit 288 MoveInit 289 290 Next the tensor PDB file is read in, selected, and the covalent bonds of the PDB CONECT records calculated: 291 292 ReadPdb file 293 SelectMol '@file' 294 CalcBond 1 1 1 295 296 Then only the atoms and bonds of the geometric object are selected and the 'ball/stick' style applied: 297 298 SelectAtom '0' 299 SelectBond '0' 300 SelectAtom ':TNS' 301 SelectBond ':TNS' 302 XMacStand ball_stick.mac 303 304 The appearance is finally touched up: 305 306 RadiusAtom 1 307 SelectAtom ':TNS@C*' 308 RadiusAtom 1.5 309 """ 310 _build_doc(tensor_pdb) 311 312
313 - def view(self):
314 # Function intro text. 315 if self._exec_info.intro: 316 text = self._exec_info.ps3 + "molmol.view()" 317 print(text) 318 319 # Execute the functional code. 320 molmol.view()
321 322 # The function doc info. 323 view._doc_title = "View the collection of molecules from the loaded PDB file." 324 view._doc_title_short = "Molecule viewing." 325 view._doc_desc = """ 326 This will simply launch Molmol. 327 """ 328 view._doc_examples = """ 329 relax> molmol.view() 330 """ 331 _build_doc(view)
332