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

Source Code for Module user_functions.structure

   1  ############################################################################### 
   2  #                                                                             # 
   3  # Copyright (C) 2003-2015 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 structure user function definitions.""" 
  24   
  25  # Python module imports. 
  26  from numpy import eye 
  27  from os import sep 
  28  import dep_check 
  29  if dep_check.wx_module: 
  30      from wx import FD_OPEN, FD_SAVE 
  31  else: 
  32      FD_OPEN = -1 
  33      FD_SAVE = -1 
  34   
  35  # relax module imports. 
  36  from graphics import WIZARD_IMAGE_PATH 
  37  from pipe_control.pipes import pipe_names 
  38  import pipe_control.structure.geometric 
  39  import pipe_control.structure.main 
  40  from user_functions.data import Uf_info; uf_info = Uf_info() 
  41  from user_functions.data import Uf_tables; uf_tables = Uf_tables() 
  42  from user_functions.objects import Desc_container 
  43  from user_functions.wildcards import WILDCARD_STRUCT_GAUSSIAN_ALL, WILDCARD_STRUCT_PDB_ALL, WILDCARD_STRUCT_XYZ_ALL 
  44   
  45   
  46  # Text for the multi-structure paragraph. 
  47  paragraph_multi_struct = "Support for multiple structures is provided by the data pipes, model numbers and molecule names arguments.  Each data pipe, model and molecule combination will be treated as a separate structure.  As only atomic coordinates with the same residue name and number and atom name will be assembled, structures with slightly different atomic structures can be compared.  If the list of models is not supplied, then all models of all data pipes will be used.  If the optional molecules list is supplied, each molecule in the list will be considered as a separate structure for comparison between each other." 
  48  paragraph_atom_id = "The atom ID string, which uses the same notation as the spin ID, can be used to restrict the coordinates compared to a subset of molecules, residues, or atoms.  For example to only use backbone heavy atoms in a protein, set the atom ID to '@N,C,CA,O', assuming those are the names of the atoms in the 3D structural file." 
  49  paragraph_displace_id = "The displacement ID string, which is similar to the atom ID, gives finer control over which atoms are translated and rotated by the algorithm.  When not set this allows, for example, to align structures based on a set of backbone heavy atoms and the backbone protons and side-chains are displaced by default.  Or if set to the same as the atom ID, if a single domain is aligned, then just that domain will be displaced." 
  50   
  51   
  52  # The user function class. 
  53  uf_class = uf_info.add_class('structure') 
  54  uf_class.title = "Class containing the structural related functions." 
  55  uf_class.menu_text = "&structure" 
  56  uf_class.gui_icon = "relax.structure" 
  57   
  58   
  59  # The structure.add_atom user function. 
  60  uf = uf_info.add_uf('structure.add_atom') 
  61  uf.title = "Add an atom." 
  62  uf.title_short = "Atom creation." 
  63  uf.add_keyarg( 
  64      name = "mol_name", 
  65      py_type = "str", 
  66      desc_short = "molecule name", 
  67      desc = "The name of molecule container to create or add the atom to.", 
  68      can_be_none = True 
  69  ) 
  70  uf.add_keyarg( 
  71      name = "atom_name", 
  72      py_type = "str", 
  73      desc_short = "atom name", 
  74      desc = "The atom name." 
  75  ) 
  76  uf.add_keyarg( 
  77      name = "res_name", 
  78      py_type = "str", 
  79      desc_short = "residue name", 
  80      desc = "The residue name." 
  81  ) 
  82  uf.add_keyarg( 
  83      name = "res_num", 
  84      py_type = "int", 
  85      min = -10000, 
  86      max = 10000, 
  87      desc_short = "residue number", 
  88      desc = "The residue number." 
  89  ) 
  90  uf.add_keyarg( 
  91      name = "pos", 
  92      py_type = "float_object", 
  93      desc_short = "atomic position", 
  94      desc = "The atomic coordinates.  For specifying different coordinates for each model of the ensemble, a list of lists can be supplied.", 
  95      list_titles = ['X coordinate', 'Y coordinate', 'Z coordinate'] 
  96  ) 
  97  uf.add_keyarg( 
  98      name = "element", 
  99      py_type = "str", 
 100      desc_short = "element", 
 101      desc = "The element name.", 
 102      wiz_element_type = "combo", 
 103      wiz_combo_choices = ["N", "C", "H", "O", "P"], 
 104      can_be_none = True 
 105  ) 
 106  uf.add_keyarg( 
 107      name = "atom_num", 
 108      py_type = "int", 
 109      desc_short = "atom number", 
 110      desc = "The optional atom number.", 
 111      can_be_none = True 
 112  ) 
 113  uf.add_keyarg( 
 114      name = "chain_id", 
 115      py_type = "str", 
 116      desc_short = "optional chain ID", 
 117      desc = "The optional chain ID string.", 
 118      can_be_none = True 
 119  ) 
 120  uf.add_keyarg( 
 121      name = "segment_id", 
 122      py_type = "str", 
 123      desc_short = "optional segment ID", 
 124      desc = "The optional segment ID string.", 
 125      can_be_none = True 
 126  ) 
 127  uf.add_keyarg( 
 128      name = "pdb_record", 
 129      py_type = "str", 
 130      desc_short = "optional PDB record name", 
 131      desc = "The optional PDB record name, e.g. 'ATOM' or 'HETATM'.", 
 132      can_be_none = True 
 133  ) 
 134  # Description. 
 135  uf.desc.append(Desc_container()) 
 136  uf.desc[-1].add_paragraph("This allows atoms to be added to the internal structural object.  To use the same atomic coordinates for all models, the atomic position can be an array of 3 values.  Alternatively different coordinates can be used for each model if the atomic position is a rank-2 array where the first dimension matches the number of models currently present.") 
 137  uf.backend = pipe_control.structure.main.add_atom 
 138  uf.menu_text = "&add_atom" 
 139  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
 140  uf.wizard_size = (900, 700) 
 141  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 142   
 143   
 144  # The structure.add_model user function. 
 145  uf = uf_info.add_uf('structure.add_model') 
 146  uf.title = "Add a new model." 
 147  uf.title_short = "Model creation." 
 148  uf.add_keyarg( 
 149      name = "model_num", 
 150      py_type = "int", 
 151      desc_short = "model number", 
 152      desc = "The number of the new model." 
 153  ) 
 154  # Description. 
 155  uf.desc.append(Desc_container()) 
 156  uf.desc[-1].add_paragraph("This allows new models to be added to the internal structural object.  Note that no structural information is allowed to be present.") 
 157  uf.backend = pipe_control.structure.main.add_model 
 158  uf.menu_text = "&add_model" 
 159  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
 160  uf.wizard_size = (700, 400) 
 161  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 162   
 163   
 164  # The structure.atomic_fluctuations user function. 
 165  uf = uf_info.add_uf('structure.atomic_fluctuations') 
 166  uf.title = "Create an interatomic distance fluctuation correlation matrix." 
 167  uf.title_short = "Interatomic distance fluctuation correlation matrix." 
 168  uf.add_keyarg( 
 169      name = "pipes", 
 170      py_type = "str_list", 
 171      desc_short = "data pipes", 
 172      desc = "The data pipes to generate the interatomic distance fluctuation correlation matrix for.", 
 173      wiz_combo_iter = pipe_names, 
 174      wiz_read_only = False, 
 175      can_be_none = True 
 176  ) 
 177  uf.add_keyarg( 
 178      name = "models", 
 179      py_type = "int_list_of_lists", 
 180      desc_short = "model list for each data pipe", 
 181      desc = "The list of models for each data pipe to generate the interatomic distance fluctuation correlation matrix for.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
 182      can_be_none = True 
 183  ) 
 184  uf.add_keyarg( 
 185      name = "molecules", 
 186      py_type = "str_list_of_lists", 
 187      desc_short = "molecule list for each data pipe", 
 188      desc = "The list of molecules for each data pipe to generate the interatomic distance fluctuation correlation matrix for.  This allows differently named molecules in the same or different data pipes to be superimposed.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
 189      can_be_none = True 
 190  ) 
 191  uf.add_keyarg( 
 192      name = "atom_id", 
 193      py_type = "str", 
 194      desc_short = "atom identification string", 
 195      desc = "The atom identification string of the coordinates of interest.  This can be used to restrict the correlation matrix to one atom per residue, for example.", 
 196      can_be_none = True 
 197  ) 
 198  uf.add_keyarg( 
 199      name = "measure", 
 200      py_type = "str", 
 201      default = "distance", 
 202      desc_short = "measure", 
 203      desc = "The type of fluctuation to investigate.  This allows for both interatomic distance and vector angle fluctuations to be calculated.", 
 204      wiz_element_type = "combo", 
 205      wiz_combo_choices = ["Interatomic distance fluctuations", "Interatomic vector angle fluctuations", "Interatomic parallax shift fluctuations"], 
 206      wiz_combo_data = ["distance", "angle", "parallax shift"] 
 207  ) 
 208  uf.add_keyarg( 
 209      name = "file", 
 210      py_type = "str_or_inst", 
 211      arg_type = "file sel", 
 212      desc_short = "file name", 
 213      desc = "The name of the text file to create.", 
 214      wiz_filesel_style = FD_SAVE 
 215  ) 
 216  uf.add_keyarg( 
 217      name = "format", 
 218      py_type = "str", 
 219      default = "text", 
 220      desc_short = "output format", 
 221      desc = "The output format.  For all formats other than the text file, a second file will be created with the same name as the text file but with the appropriate file extension added.", 
 222      wiz_element_type = "combo", 
 223      wiz_combo_choices = ["Text file", "Gnuplot script"], 
 224      wiz_combo_data = ["text", "gnuplot"] 
 225  ) 
 226  uf.add_keyarg( 
 227      name = "dir", 
 228      py_type = "str", 
 229      arg_type = "dir", 
 230      desc_short = "directory name", 
 231      desc = "The directory to save the file to.", 
 232      can_be_none = True 
 233  ) 
 234  uf.add_keyarg( 
 235      name = "force", 
 236      default = False, 
 237      py_type = "bool", 
 238      desc_short = "force flag", 
 239      desc = "A flag which if set to True will cause any pre-existing files to be overwritten." 
 240  ) 
 241  # Description. 
 242  uf.desc.append(Desc_container()) 
 243  uf.desc[-1].add_paragraph("This is used to visualise the interatomic fluctuations between different structures.  By setting the measure argument, different categories of fluctuations can seen:") 
 244  uf.desc[-1].add_item_list_element("'distance'", "The interatomic distance fluctuations is the default option.  The corrected sample standard deviation (SD) is calculated for the distances between all atom pairs, resulting in a pairwise matrix of SD values.  This is frame independent and hence is superimposition independent.") 
 245  uf.desc[-1].add_item_list_element("'angle'", "The interatomic vector angle fluctuations.  The corrected sample standard deviation (SD) is calculated for the angles between the inter atom vectors all atom pairs to an average vector.  This also produces a pairwise matrix of SD values.") 
 246  uf.desc[-1].add_item_list_element("'parallax shift'", "The interatomic parallax shift fluctuations.  The corrected sample standard deviation (SD) is calculated for the parallax shift between the inter atom vectors all atom pairs to an average vector.  This also produces a pairwise matrix of SD values.  The parallax shift is calculated as the dot product of the interatomic vector and the unit average vector, times the unit average vector.  It is a frame and superimposition dependent measure close to orthogonal to the interatomic distance fluctuations.  It is similar to the angle measure however, importantly, it is independent of the distance between the two atoms.") 
 247  uf.desc[-1].add_paragraph("For the output file, the currently supported formats are:") 
 248  uf.desc[-1].add_item_list_element("'text'", "This is the default value and will result in a single text file being created.") 
 249  uf.desc[-1].add_item_list_element("'gnuplot'", "This will create a both a text file with the data and a script for visualising the correlation matrix using gnuplot.  The script will have the same name as the text file, however the file extension will be changed to *.gnu.") 
 250  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
 251  uf.desc[-1].add_paragraph(paragraph_atom_id) 
 252  # Prompt examples. 
 253  uf.desc.append(Desc_container("Prompt examples")) 
 254  uf.desc[-1].add_paragraph("To create the interatomic distance fluctuation correlation matrix for the models 1, 3, and 5, type:") 
 255  uf.desc[-1].add_prompt("relax> structure.atomic_fluctuations(models=[[1, 3, 5]], file='atomic_fluctuation_matrix')") 
 256  uf.desc[-1].add_paragraph("To create the interatomic distance fluctuation correlation matrix for the molecules 'A', 'B', 'C', and 'D', type:") 
 257  uf.desc[-1].add_prompt("relax> structure.atomic_fluctuations(molecules=[['A', 'B', 'C', 'D']], file='atomic_fluctuation_matrix')") 
 258  uf.backend = pipe_control.structure.main.atomic_fluctuations 
 259  uf.menu_text = "&atomic_fluctuations" 
 260  uf.wizard_height_desc = 370 
 261  uf.wizard_size = (1000, 750) 
 262  uf.wizard_apply_button = False 
 263  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 264   
 265   
 266  # The structure.com user function. 
 267  uf = uf_info.add_uf('structure.com') 
 268  uf.title = "Calculate the centre of mass (CoM) for all structures." 
 269  uf.title_short = "Centre of mass calculation." 
 270  uf.add_keyarg( 
 271      name = "model", 
 272      py_type = "int", 
 273      desc_short = "model", 
 274      desc = "The optional structural model number to restrict the calculation of the centre of mass to.", 
 275      can_be_none = True 
 276  ) 
 277  uf.add_keyarg( 
 278      name = "atom_id", 
 279      py_type = "str", 
 280      desc_short = "atom ID string", 
 281      desc = "The atom identification string to restrict the CoM calculation to.", 
 282      can_be_none = True 
 283  ) 
 284  # Description. 
 285  uf.desc.append(Desc_container()) 
 286  uf.desc[-1].add_paragraph("This user function will calculate the centre of mass (CoM) for all loaded structures, printing out the position and storing it in the current data pipe.") 
 287  # Prompt examples. 
 288  uf.desc.append(Desc_container("Prompt examples")) 
 289  uf.desc[-1].add_paragraph("To determine the centre of mass of all structure, simply type:") 
 290  uf.desc[-1].add_prompt("relax> structure.com()") 
 291  uf.backend = pipe_control.structure.main.com 
 292  uf.menu_text = "co&m" 
 293  uf.wizard_size = (600, 400) 
 294  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 295   
 296   
 297  # The structure.connect_atom user function. 
 298  uf = uf_info.add_uf('structure.connect_atom') 
 299  uf.title = "Connect two atoms." 
 300  uf.title_short = "Atom connection." 
 301  uf.add_keyarg( 
 302      name = "index1", 
 303      py_type = "int", 
 304      max = 10000, 
 305      desc_short = "index 1", 
 306      desc = "The global index of the first atom." 
 307  ) 
 308  uf.add_keyarg( 
 309      name = "index2", 
 310      py_type = "int", 
 311      max = 10000, 
 312      desc_short = "index 2", 
 313      desc = "The global index of the second atom." 
 314  ) 
 315  # Description. 
 316  uf.desc.append(Desc_container()) 
 317  uf.desc[-1].add_paragraph("This allows atoms to be connected in the internal structural object.  The global index is normally equal to the PDB atom number minus 1.") 
 318  uf.backend = pipe_control.structure.main.connect_atom 
 319  uf.menu_text = "co&nnect_atom" 
 320  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 321   
 322   
 323  # The structure.create_diff_tensor_pdb user function. 
 324  uf = uf_info.add_uf('structure.create_diff_tensor_pdb') 
 325  uf.title = "Create a PDB file to represent the diffusion tensor." 
 326  uf.title_short = "Diffusion tensor PDB file creation." 
 327  uf.add_keyarg( 
 328      name = "scale", 
 329      default = 1.8e-6, 
 330      py_type = "num", 
 331      desc_short = "scaling factor", 
 332      desc = "Value for scaling the diffusion rates." 
 333  ) 
 334  uf.add_keyarg( 
 335      name = "file", 
 336      default = "tensor.pdb", 
 337      py_type = "str", 
 338      arg_type = "file sel", 
 339      desc_short = "file name", 
 340      desc = "The name of the PDB file.", 
 341      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
 342      wiz_filesel_style = FD_SAVE 
 343  ) 
 344  uf.add_keyarg( 
 345      name = "dir", 
 346      py_type = "str", 
 347      arg_type = "dir", 
 348      desc_short = "directory name", 
 349      desc = "The directory to place the file into.", 
 350      can_be_none = True 
 351  ) 
 352  uf.add_keyarg( 
 353      name = "force", 
 354      default = False, 
 355      py_type = "bool", 
 356      desc_short = "force flag", 
 357      desc = "A flag which, if set to True, will overwrite the any pre-existing file." 
 358  ) 
 359  # Description. 
 360  uf.desc.append(Desc_container()) 
 361  uf.desc[-1].add_paragraph("This creates a PDB file containing an artificial geometric structure to represent the diffusion tensor.  A structure must have previously been read into relax.  The diffusion tensor is represented by an ellipsoidal, spheroidal, or spherical geometric object with its origin located at the centre of mass (of the selected residues).  This diffusion tensor PDB file can subsequently read into any molecular viewer.") 
 362  uf.desc[-1].add_paragraph("There are four different types of residue within the PDB.  The centre of mass of the selected residues is represented as a single carbon atom of the residue 'COM'.  The ellipsoidal geometric shape consists of numerous H atoms of the residue 'TNS'.  The axes of the tensor, when defined, are presented as the residue 'AXS' and consist of carbon atoms: one at the centre of mass and one at the end of each eigenvector.  Finally, if Monte Carlo simulations were run and the diffusion tensor parameters were allowed to vary then there will be multiple 'SIM' residues, one for each simulation.  These are essentially the same as the 'AXS' residue, representing the axes of the simulated tensors, and they will appear as a distribution.") 
 363  uf.desc[-1].add_paragraph("As the Brownian rotational diffusion tensor is a measure of the rate of rotation about different axes - the larger the geometric object, the faster the diffusion of a molecule.  For example the diffusion tensor of a water molecule is much larger than that of a macromolecule.") 
 364  uf.desc[-1].add_paragraph("The effective global correlation time experienced by an XH bond vector, not to be confused with the Lipari and Szabo parameter tau_e, will be approximately proportional to the component of the diffusion tensor parallel to it.  The approximation is not exact due to the multiexponential form of the correlation function of Brownian rotational diffusion.  If an XH bond vector is parallel to the longest axis of the tensor, it will be unaffected by rotations about that axis, which are the fastest rotations of the molecule, and therefore its effective global correlation time will be maximal.") 
 365  uf.desc[-1].add_paragraph("To set the size of the diffusion tensor within the PDB frame the unit vectors used to generate the geometric object are first multiplied by the diffusion tensor (which has the units of inverse seconds) then by the scaling factor (which has the units of second Angstroms and has the default value of 1.8e-6 s.Angstrom).  Therefore the rotational diffusion rate per Angstrom is equal the inverse of the scale value (which defaults to 5.56e5 s^-1.Angstrom^-1).  Using the default scaling value for spherical diffusion, the correspondence between global correlation time, Diso diffusion rate, and the radius of the sphere for a number of discrete cases will be:") 
 366  table = uf_tables.add_table(label="table: diff tensor PDB scaling", caption="Diffusion tensor PDB representation sizes using the default scaling for different diffusion tensors", caption_short="Diffusion tensor PDB scaling.") 
 367  table.add_headings(["tm (ns)", "Diso (s^-1)", "Radius (Angstrom)"]) 
 368  table.add_row(["1", "1.67e8", "300"]) 
 369  table.add_row(["3", "5.56e7", "100"]) 
 370  table.add_row(["10", "1.67e7", "30"]) 
 371  table.add_row(["30", "5.56e6", "10"]) 
 372  uf.desc[-1].add_table(table.label) 
 373  uf.desc[-1].add_paragraph("The scaling value has been fixed to facilitate comparisons within or between publications, but can be changed to vary the size of the tensor geometric object if necessary.  Reporting the rotational diffusion rate per Angstrom within figure legends would be useful.") 
 374  uf.desc[-1].add_paragraph("To create the tensor PDB representation, a number of algorithms are utilised.  Firstly the centre of mass is calculated for the selected residues and is represented in the PDB by a C atom.  Then the axes of the diffusion are calculated, as unit vectors scaled to the appropriate length (multiplied by the eigenvalue Dx, Dy, Dz, Dpar, Dper, or Diso as well as the scale value), and a C atom placed at the position of this vector plus the centre of mass.  Finally a uniform distribution of vectors on a sphere is generated using spherical coordinates.  By incrementing the polar angle using an arccos distribution, a radial array of vectors representing latitude are created while incrementing the azimuthal angle evenly creates the longitudinal vectors.  These unit vectors, which are distributed within the PDB frame and are of 1 Angstrom in length, are first rotated into the diffusion frame using a rotation matrix (the spherical diffusion tensor is not rotated).  Then they are multiplied by the diffusion tensor matrix to extend the vector out to the correct length, and finally multiplied by the scale value so that the vectors reasonably superimpose onto the macromolecular structure.  The last set of algorithms place all this information into a PDB file.  The distribution of vectors are represented by H atoms and are all connected using PDB CONECT records.  Each H atom is connected to its two neighbours on the both the longitude and latitude.  This creates a geometric PDB object with longitudinal and latitudinal lines.") 
 375  uf.backend = pipe_control.structure.main.create_diff_tensor_pdb 
 376  uf.menu_text = "&create_diff_tensor_pdb" 
 377  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
 378  uf.wizard_height_desc = 450 
 379  uf.wizard_size = (1000, 750) 
 380  uf.wizard_apply_button = False 
 381  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'create_diff_tensor_pdb.png' 
 382   
 383   
 384  # The structure.create_rotor_pdb user function. 
 385  uf = uf_info.add_uf('structure.create_rotor_pdb') 
 386  uf.title = "Create a PDB file representation of a rotor." 
 387  uf.title_short = "Rotor PDB representation." 
 388  uf.add_keyarg( 
 389      name = "file", 
 390      default = "rotor.pdb", 
 391      py_type = "str", 
 392      arg_type = "file sel", 
 393      desc_short = "file name", 
 394      desc = "The name of the PDB file.", 
 395      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
 396      wiz_filesel_style = FD_SAVE 
 397  ) 
 398  uf.add_keyarg( 
 399      name = "dir", 
 400      py_type = "str", 
 401      arg_type = "dir", 
 402      desc_short = "directory name", 
 403      desc = "The directory to place the file into.", 
 404      can_be_none = True 
 405  ) 
 406  uf.add_keyarg( 
 407      name = "rotor_angle", 
 408      default = 0.0, 
 409      py_type = "float", 
 410      desc_short = "rotor angle", 
 411      desc = "The angle of the rotor motion in degrees." 
 412  ) 
 413  uf.add_keyarg( 
 414      name = "axis", 
 415      py_type = "float_array", 
 416      dim = 3, 
 417      desc_short = "rotor axis vector", 
 418      desc = "The vector defining the rotor axis." 
 419  ) 
 420  uf.add_keyarg( 
 421      name = "axis_pt", 
 422      py_type = "float_array", 
 423      dim = 3, 
 424      desc_short = "rotor axis point", 
 425      desc = "A point lying anywhere on the rotor axis.  This is used to define the position of the axis in 3D space." 
 426  ) 
 427  uf.add_keyarg( 
 428      name = "centre", 
 429      py_type = "float_array", 
 430      dim = 3, 
 431      desc_short = "central point", 
 432      desc = "The central point of the representation.  If this point is not on the rotor axis, then the closest point on the axis will be used for the centre." 
 433  ) 
 434  uf.add_keyarg( 
 435      name = "span", 
 436      default = 2e-9, 
 437      py_type = "num", 
 438      desc_short = "representation span", 
 439      desc = "The distance from the central point to the rotor blades (meters)." 
 440  ) 
 441  uf.add_keyarg( 
 442      name = "blade_length", 
 443      default = 5e-10, 
 444      py_type = "num", 
 445      desc_short = "blade length", 
 446      desc = "The length of the representative rotor blades." 
 447  ) 
 448  uf.add_keyarg( 
 449      name = "force", 
 450      default = False, 
 451      py_type = "bool", 
 452      desc_short = "force flag", 
 453      desc = "A flag which if True will overwrite the file if it already exists." 
 454  ) 
 455  uf.add_keyarg( 
 456      name = "staggered", 
 457      default = False, 
 458      py_type = "bool", 
 459      desc_short = "staggered flag", 
 460      desc = "A flag which if True will cause the rotor blades to be staggered.  This is used to avoid blade overlap." 
 461  ) 
 462  # Description. 
 463  uf.desc.append(Desc_container()) 
 464  uf.desc[-1].add_paragraph("This creates a PDB file representation of a rotor motional model.  The model axis is defined by a vector and a single point on the axis.  The centre of the representation will be taken as the point on the rotor axis closest to the given centre position.  The size of the representation is defined by the span, which is the distance from the central point to the rotors, and the length of the blades.") 
 465  # Prompt examples. 
 466  uf.desc.append(Desc_container("Prompt examples")) 
 467  uf.desc[-1].add_paragraph("The following is a synthetic example:") 
 468  uf.desc[-1].add_prompt("relax> structure.create_rotor_pdb(file='rotor.pdb', rotor_angle=20.0, axis=[0., 0., 1.], axis_pt=[1., 1., 0.], centre=[0., 0., 2.], span=2e-9, blade_length=1e-9)") 
 469  uf.backend = pipe_control.structure.geometric.create_rotor_pdb 
 470  uf.menu_text = "create_&rotor_pdb" 
 471  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
 472  uf.wizard_height_desc = 400 
 473  uf.wizard_size = (900, 700) 
 474  uf.wizard_apply_button = False 
 475  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 476   
 477   
 478  # The structure.create_vector_dist user function. 
 479  uf = uf_info.add_uf('structure.create_vector_dist') 
 480  uf.title = "Create a PDB file representation of the distribution of XH bond vectors." 
 481  uf.title_short = "XH vector distribution PDB representation." 
 482  uf.add_keyarg( 
 483      name = "length", 
 484      default = 2e-9, 
 485      py_type = "num", 
 486      desc_short = "vector length", 
 487      desc = "The length of the vectors in the PDB representation (meters)." 
 488  ) 
 489  uf.add_keyarg( 
 490      name = "file", 
 491      default = "XH_dist.pdb", 
 492      py_type = "str", 
 493      arg_type = "file sel", 
 494      desc_short = "file name", 
 495      desc = "The name of the PDB file.", 
 496      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
 497      wiz_filesel_style = FD_SAVE 
 498  ) 
 499  uf.add_keyarg( 
 500      name = "dir", 
 501      py_type = "str", 
 502      arg_type = "dir", 
 503      desc_short = "directory name", 
 504      desc = "The directory to place the file into.", 
 505      can_be_none = True 
 506  ) 
 507  uf.add_keyarg( 
 508      name = "symmetry", 
 509      default = True, 
 510      py_type = "bool", 
 511      desc_short = "symmetry flag", 
 512      desc = "A flag which if True will create a second chain with reversed XH bond orientations." 
 513  ) 
 514  uf.add_keyarg( 
 515      name = "force", 
 516      default = False, 
 517      py_type = "bool", 
 518      desc_short = "force flag", 
 519      desc = "A flag which if True will overwrite the file if it already exists." 
 520  ) 
 521  # Description. 
 522  uf.desc.append(Desc_container()) 
 523  uf.desc[-1].add_paragraph("This creates a PDB file containing an artificial vectors, the length of which default to 20 Angstrom.  A structure must have previously been read into relax.  The origin of the vector distribution is located at the centre of mass (of the selected residues).  This vector distribution PDB file can subsequently be read into any molecular viewer.") 
 524  uf.desc[-1].add_paragraph("Because of the symmetry of the diffusion tensor reversing the orientation of the XH bond vector has no effect.  Therefore by setting the symmetry flag two chains 'A' and 'B' will be added to the PDB file whereby chain 'B' is chain 'A' with the XH bonds reversed.") 
 525  uf.backend = pipe_control.structure.geometric.create_vector_dist 
 526  uf.menu_text = "cr&eate_vector_dist" 
 527  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
 528  uf.wizard_height_desc = 400 
 529  uf.wizard_size = (900, 700) 
 530  uf.wizard_apply_button = False 
 531  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'create_vector_dist.png' 
 532   
 533   
 534  # The structure.get_pos user function. 
 535  uf = uf_info.add_uf('structure.get_pos') 
 536  uf.title = "Extract the atomic positions from the loaded structures for the given spins." 
 537  uf.title_short = "Atomic position extraction." 
 538  uf.add_keyarg( 
 539      name = "spin_id", 
 540      py_type = "str", 
 541      desc_short = "spin ID string", 
 542      desc = "The spin identification string.", 
 543      can_be_none = True 
 544  ) 
 545  uf.add_keyarg( 
 546      name = "ave_pos", 
 547      default = True, 
 548      py_type = "bool", 
 549      desc_short = "average position flag", 
 550      desc = "A flag specifying if the position of the atom is to be averaged across models." 
 551  ) 
 552  # Description. 
 553  uf.desc.append(Desc_container()) 
 554  uf.desc[-1].add_paragraph("This allows the atomic positions of the spins to be extracted from the loaded structures.  This is automatically performed by the structure.load_spins user function, but if the sequence information is generated in other ways, this user function allows the structural information to be obtained.") 
 555  uf.desc[-1].add_paragraph("If averaging the atomic positions, then average position of all models will be loaded into the spin container.  Otherwise the positions from all models will be loaded separately.") 
 556  # Prompt examples. 
 557  uf.desc.append(Desc_container("Prompt examples")) 
 558  uf.desc[-1].add_paragraph("For a model-free backbone amide nitrogen analysis whereby the N spins have already been created, to obtain the backbone N positions from the file '1F3Y.pdb' (which is a single protein), type the following two user functions:") 
 559  uf.desc[-1].add_prompt("relax> structure.read_pdb('1F3Y.pdb')") 
 560  uf.desc[-1].add_prompt("relax> structure.get_pos(spin_id='@N')") 
 561  uf.backend = pipe_control.structure.main.get_pos 
 562  uf.menu_text = "&get_pos" 
 563  uf.wizard_height_desc = 300 
 564  uf.wizard_size = (800, 600) 
 565  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 566   
 567   
 568  # The structure.delete user function. 
 569  uf = uf_info.add_uf('structure.delete') 
 570  uf.title = "Delete structural information." 
 571  uf.title_short = "Structure deletion." 
 572  uf.add_keyarg( 
 573      name = "atom_id", 
 574      py_type = "str", 
 575      desc_short = "atom ID string", 
 576      desc = "The atom identification string.", 
 577      can_be_none = True 
 578  ) 
 579  uf.add_keyarg( 
 580      name = "model", 
 581      py_type = "int", 
 582      desc_short = "structural model", 
 583      desc = "Individual structural models from a loaded ensemble can be deleted by specifying the model number.", 
 584      can_be_none = True 
 585  ) 
 586  uf.add_keyarg( 
 587      name = "verbosity", 
 588      default = 1, 
 589      py_type = "int", 
 590      desc_short = "verbosity level", 
 591      desc = "The amount of information to print out.  Set to zero to silence the user function, or one to see all messages." 
 592  ) 
 593  uf.add_keyarg( 
 594      name = "spin_info", 
 595      default = True, 
 596      py_type = "bool", 
 597      desc_short = "spin information flag", 
 598      desc = "A flag which if True will cause all structural information in the spin containers and interatomic data containers to be deleted as well.  If False, then only the 3D structural data will be deleted." 
 599  ) 
 600  # Description. 
 601  uf.desc.append(Desc_container()) 
 602  uf.desc[-1].add_paragraph("This will delete structural information from the current data pipe.  All spin and sequence information loaded from these structures will be preserved - this only affects the structural data.  The atom ID argument can be used to restrict deletion to parts of the loaded molecules, or the model argument can be used to delete individual structural models from an ensemble.") 
 603  # Prompt examples. 
 604  uf.desc.append(Desc_container("Prompt examples")) 
 605  uf.desc[-1].add_paragraph("To delete everything, simply type:") 
 606  uf.desc[-1].add_prompt("relax> structure.delete()") 
 607  uf.desc[-1].add_paragraph("To delete residues 50 to 100 of the molecule called 'Ap4Aase', type one of:") 
 608  uf.desc[-1].add_prompt("relax> structure.delete(':50-100')") 
 609  uf.desc[-1].add_prompt("relax> structure.delete(atom_id=':50-100')") 
 610  uf.backend = pipe_control.structure.main.delete 
 611  uf.menu_text = "&delete" 
 612  uf.gui_icon = "oxygen.actions.list-remove" 
 613  uf.wizard_size = (800, 550) 
 614  uf.wizard_apply_button = False 
 615  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 616   
 617   
 618  # The structure.displacement user function. 
 619  uf = uf_info.add_uf('structure.displacement') 
 620  uf.title = "Determine the rotational and translational displacement between a set of models or molecules." 
 621  uf.title_short = "Rotational and translational displacement." 
 622  uf.add_keyarg( 
 623      name = "pipes", 
 624      py_type = "str_list", 
 625      desc_short = "data pipes", 
 626      desc = "The data pipes to determine the displacements for.", 
 627      wiz_combo_iter = pipe_names, 
 628      wiz_read_only = False, 
 629      can_be_none = True 
 630  ) 
 631  uf.add_keyarg( 
 632      name = "models", 
 633      py_type = "int_list_of_lists", 
 634      desc_short = "model list for each data pipe", 
 635      desc = "The list of models for each data pipe to determine the displacements for.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
 636      can_be_none = True 
 637  ) 
 638  uf.add_keyarg( 
 639      name = "molecules", 
 640      py_type = "str_list_of_lists", 
 641      desc_short = "molecule list for each data pipe", 
 642      desc = "The list of molecules for each data pipe to determine the displacements for.  This allows differently named molecules in the same or different data pipes to be superimposed.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
 643      can_be_none = True 
 644  ) 
 645  uf.add_keyarg( 
 646      name = "atom_id", 
 647      py_type = "str", 
 648      desc_short = "atom identification string", 
 649      desc = "The atom identification string of the coordinates of interest.", 
 650      can_be_none = True 
 651  ) 
 652  uf.add_keyarg( 
 653      name = "centroid", 
 654      py_type = "float_array", 
 655      desc_short = "centroid position", 
 656      desc = "The alternative position of the centroid.", 
 657      can_be_none = True 
 658  ) 
 659  # Description. 
 660  uf.desc.append(Desc_container()) 
 661  uf.desc[-1].add_paragraph("This user function allows the rotational and translational displacement between different models or molecules to be calculated.  The information will be printed out in various formats and held in the relax data store.  This is directional, so there is a starting and ending position for each displacement.  Therefore the displacements in all directions between all models and molecules will be calculated.") 
 662  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
 663  uf.desc[-1].add_paragraph(paragraph_atom_id) 
 664  uf.desc[-1].add_paragraph("By supplying the position of the centroid, an alternative position than the standard rigid body centre is used as the focal point of the motion.  The allows, for example, a pivot of a rotational domain motion to be specified.  This is not a formally correct algorithm, all translations will be zero, but does give an indication to the amplitude of the pivoting angle.") 
 665  # Prompt examples. 
 666  uf.desc.append(Desc_container("Prompt examples")) 
 667  uf.desc[-1].add_paragraph("To determine the rotational and translational displacements between all sets of models, type:") 
 668  uf.desc[-1].add_prompt("relax> structure.displacement()") 
 669  uf.backend = pipe_control.structure.main.displacement 
 670  uf.menu_text = "displace&ment" 
 671  uf.wizard_height_desc = 450 
 672  uf.wizard_size = (1000, 750) 
 673  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 674   
 675   
 676  # The structure.find_pivot user function. 
 677  uf = uf_info.add_uf('structure.find_pivot') 
 678  uf.title = "Find the pivot point of the motion of a set of structures." 
 679  uf.title_short = "Pivot search." 
 680  uf.add_keyarg( 
 681      name = "pipes", 
 682      py_type = "str_list", 
 683      desc_short = "data pipes", 
 684      desc = "The data pipes to use in the motional pivot algorithm.", 
 685      wiz_combo_iter = pipe_names, 
 686      wiz_read_only = False, 
 687      can_be_none = True 
 688  ) 
 689  uf.add_keyarg( 
 690      name = "models", 
 691      py_type = "int_list_of_lists", 
 692      desc_short = "model list for each data pipe", 
 693      desc = "The list of models for each data pipe to use in the motional pivot algorithm.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
 694      can_be_none = True 
 695  ) 
 696  uf.add_keyarg( 
 697      name = "molecules", 
 698      py_type = "str_list_of_lists", 
 699      desc_short = "molecule list for each data pipe", 
 700      desc = "The list of molecules for each data pipe to use in the motional pivot algorithm.  This allows differently named molecules in the same or different data pipes to be used.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
 701      can_be_none = True 
 702  ) 
 703  uf.add_keyarg( 
 704      name = "atom_id", 
 705      py_type = "str", 
 706      desc_short = "atom ID string", 
 707      desc = "The atom identification string of the coordinates of interest.", 
 708      can_be_none = True 
 709  ) 
 710  uf.add_keyarg( 
 711      name = "init_pos", 
 712      py_type = "float_array", 
 713      desc_short = "initial pivot position", 
 714      desc = "The initial position of the pivot.", 
 715      can_be_none = True 
 716  ) 
 717  uf.add_keyarg( 
 718      name = "func_tol", 
 719      default = 1e-5, 
 720      py_type = "num", 
 721      desc_short = "function tolerance", 
 722      desc = "The function tolerance.  This is used to terminate minimisation once the function value between iterations is less than the tolerance.  The default value is 1e-5." 
 723  ) 
 724  uf.add_keyarg( 
 725      name = "box_limit", 
 726      default = 200, 
 727      py_type = "int", 
 728      desc_short = "box constraint limit", 
 729      desc = "The pivot point is constrained withing a box of +/- x Angstrom the using the logarithmic barrier function together with simplex optimisation.  This argument is the value of x." 
 730  ) 
 731  # Description. 
 732  uf.desc.append(Desc_container()) 
 733  uf.desc[-1].add_paragraph("This is used to find pivot point of motion between a set of structural models.  If the list of models is not supplied, then all models will be used.") 
 734  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
 735  uf.desc[-1].add_paragraph(paragraph_atom_id) 
 736  uf.desc[-1].add_paragraph("By supplying the position of the centroid, an alternative position than the standard rigid body centre is used as the focal point of the superimposition.  The allows, for example, the superimposition about a pivot point.") 
 737  uf.backend = pipe_control.structure.main.find_pivot 
 738  uf.menu_text = "&find_pivot" 
 739  uf.wizard_height_desc = 450 
 740  uf.wizard_size = (1000, 750) 
 741  uf.wizard_apply_button = False 
 742  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 743   
 744   
 745  # The structure.load_spins user function. 
 746  uf = uf_info.add_uf('structure.load_spins') 
 747  uf.title = "Load spins from the structure into the relax data store." 
 748  uf.title_short = "Loading spins from structure." 
 749  uf.add_keyarg( 
 750      name = "spin_id", 
 751      py_type = "str", 
 752      arg_type = "spin ID", 
 753      desc_short = "spin ID string", 
 754      desc = "The spin identification string for the selective loading of certain spins into the relax data store.", 
 755      wiz_combo_choices = ["@N", "@C", "@H", "@O", "@P", "@NE1", "@HE1", ":A@C2", ":A@C8", ":G@N1", ":G@C8", ":C@C5", ":C@C5", ":U@N3", ":U@C5", ":U@C6"], 
 756      can_be_none = True 
 757  ) 
 758  uf.add_keyarg( 
 759      name = "from_mols", 
 760      py_type = "str_list", 
 761      desc_short = "molecules to load spins from", 
 762      desc = "The list of similar, but not necessarily identical molecules to load spin information from.", 
 763      wiz_read_only = False, 
 764      can_be_none = True 
 765  ) 
 766  uf.add_keyarg( 
 767      name = "mol_name_target", 
 768      py_type = "str", 
 769      desc_short = "target molecule name", 
 770      desc = "The name of target molecule container, overriding the name of the loaded structures.", 
 771      can_be_none = True 
 772  ) 
 773  uf.add_keyarg( 
 774      name = "ave_pos", 
 775      default = True, 
 776      py_type = "bool", 
 777      desc_short = "average position flag", 
 778      desc = "A flag specifying if the position of the atom is to be averaged across models." 
 779  ) 
 780  # Description. 
 781  uf.desc.append(Desc_container()) 
 782  uf.desc[-1].add_paragraph("This allows a sequence to be generated within the relax data store using the atomic information from the structure already associated with this data pipe.  The spin ID string is used to select which molecules, which residues, and which atoms will be recognised as spin systems within relax.  If the spin ID is left unspecified, then all molecules, residues, and atoms will be placed within the data store (and all atoms will be treated as spins).") 
 783  uf.desc[-1].add_paragraph("As an alternative to using structural models, by specifying the list of molecules to load spins from similar though not necessarily identical molecules will be combined.  In this case, the target molecule name must be supplied to create a single combined molecule.  And only a single model can be loaded in the current data pipe.  The spin numbering will be dropped to allow for sequential atom numbering in the PDB and other formats.  Therefore only the residue number and name and atom name will be preserved for creating the spin containers.  If the spin is only present in a subset of the structures, then the positional information will only be taken from that subset and hence the number of positions might be different for different spins.") 
 784  uf.desc[-1].add_paragraph("If averaging the atomic positions, then average position of all models or molecules will be loaded into the spin container.  Otherwise the positions from all models or molecules will be loaded separately.") 
 785  # Prompt examples. 
 786  uf.desc.append(Desc_container("Prompt examples")) 
 787  uf.desc[-1].add_paragraph("For a model-free backbone amide nitrogen analysis, to load just the backbone N sequence from the file '1F3Y.pdb' (which is a single protein), type the following two user functions:") 
 788  uf.desc[-1].add_prompt("relax> structure.read_pdb('1F3Y.pdb')") 
 789  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id='@N')") 
 790  uf.desc[-1].add_paragraph("For an RNA analysis of adenine C8 and C2, guanine C8 and N1, cytidine C5 and C6, and uracil N3, C5, and C6, type the following series of commands (assuming that the PDB file with this atom naming has already been read):") 
 791  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":A@C8\")") 
 792  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":A@C2\")") 
 793  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":G@C8\")") 
 794  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":G@N1\")") 
 795  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":C@C5\")") 
 796  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":C@C6\")") 
 797  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":U@N3\")") 
 798  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":U@C5\")") 
 799  uf.desc[-1].add_prompt("relax> structure.load_spins(spin_id=\":U@C6\")") 
 800  uf.desc[-1].add_paragraph("Alternatively using some Python programming:") 
 801  uf.desc[-1].add_prompt("relax> for id in [\":A@C8\", \":A@C2\", \":G@C8\", \":G@N1\", \":C@C5\", \":C@C6\", \":U@N3\", \":U@C5\", \":U@C6\"]:") 
 802  uf.desc[-1].add_prompt("relax>     structure.load_spins(spin_id=id)") 
 803  uf.backend = pipe_control.structure.main.load_spins 
 804  uf.menu_text = "&load_spins" 
 805  uf.gui_icon = "relax.spin" 
 806  uf.wizard_height_desc = 500 
 807  uf.wizard_size = (900, 700) 
 808  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'load_spins.png' 
 809   
 810   
 811  # The structure.mean user function. 
 812  uf = uf_info.add_uf('structure.mean') 
 813  uf.title = "Calculate the mean structure from all loaded models." 
 814  uf.title_short = "Mean structure." 
 815  uf.add_keyarg( 
 816      name = "pipes", 
 817      py_type = "str_list", 
 818      desc_short = "data pipes", 
 819      desc = "The data pipes containing structures to average.", 
 820      wiz_combo_iter = pipe_names, 
 821      wiz_read_only = False, 
 822      can_be_none = True 
 823  ) 
 824  uf.add_keyarg( 
 825      name = "models", 
 826      py_type = "int_list_of_lists", 
 827      desc_short = "model list for each data pipe", 
 828      desc = "The list of models for each data pipe containing structures to average.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
 829      can_be_none = True 
 830  ) 
 831  uf.add_keyarg( 
 832      name = "molecules", 
 833      py_type = "str_list_of_lists", 
 834      desc_short = "molecule list for each data pipe", 
 835      desc = "The list of molecules for each data pipe to average.  This allows differently named molecules in the same or different data pipes to be averaged.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
 836      can_be_none = True 
 837  ) 
 838  uf.add_keyarg( 
 839      name = "atom_id", 
 840      py_type = "str", 
 841      desc_short = "atom identification string", 
 842      desc = "The atom identification string of the coordinates of interest.  This can be used to restrict the averaged structure to one atom per residue, for example.", 
 843      can_be_none = True 
 844  ) 
 845  uf.add_keyarg( 
 846      name = "set_mol_name", 
 847      py_type = "str", 
 848      desc_short = "averaged molecule name", 
 849      desc = "Set the optional name of the averaged molecule.", 
 850      can_be_none = True 
 851  ) 
 852  uf.add_keyarg( 
 853      name = "set_model_num", 
 854      py_type = "int", 
 855      desc_short = "averaged model number", 
 856      desc = "Set the optional model number of the averaged molecule.", 
 857      can_be_none = True 
 858  ) 
 859  # Description. 
 860  uf.desc.append(Desc_container()) 
 861  uf.desc[-1].add_paragraph("This will calculate and store the mean structure from a collection of related molecules.  If a new molecule name or model number is not supplied, the mean structure will replace all the models in the internal structural object.  This is provided as a structural aid, specifically for superimposition purposes.") 
 862  uf.backend = pipe_control.structure.main.average_structure 
 863  uf.menu_text = "&mean" 
 864  uf.gui_icon = "oxygen.categories.applications-education" 
 865  uf.wizard_size = (800, 600) 
 866  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
 867   
 868   
 869  # The structure.read_gaussian user function. 
 870  uf = uf_info.add_uf('structure.read_gaussian') 
 871  uf.title = "Reading structures from Gaussian log files." 
 872  uf.title_short = "Gaussian log structure reading." 
 873  uf.add_keyarg( 
 874      name = "file", 
 875      py_type = "str", 
 876      arg_type = "file sel", 
 877      desc_short = "file name", 
 878      desc = "The name of the Gaussian log file.", 
 879      wiz_filesel_wildcard = WILDCARD_STRUCT_GAUSSIAN_ALL, 
 880      wiz_filesel_style = FD_OPEN 
 881  ) 
 882  uf.add_keyarg( 
 883      name = "dir", 
 884      py_type = "str", 
 885      arg_type = "dir", 
 886      desc_short = "directory name", 
 887      desc = "The directory where the file is located.", 
 888      can_be_none = True 
 889  ) 
 890  uf.add_keyarg( 
 891      name = "set_mol_name", 
 892      py_type = "str_or_str_list", 
 893      desc_short = "setting of molecule names", 
 894      desc = "Set the names of the read molecules.  If unset, then the molecules will be automatically labelled based on the file name or other information.  This can either be a single name or a list of names.", 
 895      can_be_none = True 
 896  ) 
 897  uf.add_keyarg( 
 898      name = "set_model_num", 
 899      py_type = "int_or_int_list", 
 900      desc_short = "setting of model numbers", 
 901      desc = "Set the model numbers of the loaded molecules.  This can be a single number or list of numbers.", 
 902      can_be_none = True 
 903  ) 
 904  uf.add_keyarg( 
 905      name = "verbosity", 
 906      default = 1, 
 907      py_type = "int", 
 908      desc_short = "verbosity level", 
 909      desc = "The amount of information to print out.  Set to zero to silence the user function, or one to see all messages." 
 910  ) 
 911  # Description. 
 912  uf.desc.append(Desc_container()) 
 913  uf.desc[-1].add_paragraph("The atomic positions from a Gaussian log file can be read into relax.  If optimisation has been preformed, the last set of atomic coordinates from the log will be read to obtain the final structure.  The log file can be Gzip or Bzip2 compressed.") 
 914  uf.desc[-1].add_paragraph("The setting of molecule names is used to name the molecules within the Gaussian file.  If not set, then the molecules will be named after the file name, with the molecule number appended if more than one exists.  By setting the molecule name or setting the model number, the loaded structure can be stored as a specific model or as a different molecule.") 
 915  # Prompt examples. 
 916  uf.desc.append(Desc_container("Prompt examples")) 
 917  uf.desc[-1].add_paragraph("To load all structures from the Gaussian file 'taxol.log' in the directory '~/logs', including all models and all molecules, type one of:") 
 918  uf.desc[-1].add_prompt("relax> structure.read_gaussian('taxol.log', '~/logs')") 
 919  uf.desc[-1].add_prompt("relax> structure.read_gaussian(file='taxol.log', dir=logs')") 
 920  uf.backend = pipe_control.structure.main.read_gaussian 
 921  uf.menu_text = "read_&gaussian" 
 922  uf.gui_icon = "oxygen.actions.document-open" 
 923  uf.wizard_height_desc = 400 
 924  uf.wizard_size = (900, 600) 
 925  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'read_xyz.png' 
 926   
 927   
 928  # The structure.read_pdb user function. 
 929  uf = uf_info.add_uf('structure.read_pdb') 
 930  uf.title = "Reading structures from PDB files." 
 931  uf.title_short = "PDB reading." 
 932  uf.add_keyarg( 
 933      name = "file", 
 934      py_type = "str", 
 935      arg_type = "file sel", 
 936      desc_short = "file name", 
 937      desc = "The name of the PDB file.", 
 938      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
 939      wiz_filesel_style = FD_OPEN 
 940  ) 
 941  uf.add_keyarg( 
 942      name = "dir", 
 943      py_type = "str", 
 944      arg_type = "dir", 
 945      desc_short = "directory name", 
 946      desc = "The directory where the file is located.", 
 947      can_be_none = True 
 948  ) 
 949  uf.add_keyarg( 
 950      name = "read_mol", 
 951      py_type = "int_or_int_list", 
 952      desc_short = "molecule number to read", 
 953      desc = "If set, only the given molecule(s) will be read.  The molecules are numbered consecutively from 1.  If unset, then all molecules will be loaded.  By providing a list of numbers such as [1, 2], multiple molecules will be read.", 
 954      can_be_none = True 
 955  ) 
 956  uf.add_keyarg( 
 957      name = "set_mol_name", 
 958      py_type = "str_or_str_list", 
 959      desc_short = "setting of molecule names", 
 960      desc = "Set the names of the read molecules.  If unset, then the molecules will be automatically labelled based on the file name or other information.  This can either be a single name or a list of names.", 
 961      can_be_none = True 
 962  ) 
 963  uf.add_keyarg( 
 964      name = "read_model", 
 965      py_type = "int_or_int_list", 
 966      desc_short = "model to read", 
 967      desc = "If set, only the given model number(s) from the PDB file will be read.  Otherwise all models will be read.  This can be a single number or list of numbers.", 
 968      can_be_none = True 
 969  ) 
 970  uf.add_keyarg( 
 971      name = "set_model_num", 
 972      py_type = "int_or_int_list", 
 973      desc_short = "setting of model numbers", 
 974      desc = "Set the model numbers of the loaded molecules.  If unset, then the PDB model numbers will be preserved if they exist.  This can be a single number or list of numbers.", 
 975      can_be_none = True 
 976  ) 
 977  uf.add_keyarg( 
 978      name = "alt_loc", 
 979      py_type = "str", 
 980      desc_short = "alternate location indicator", 
 981      desc = "The PDB ATOM record 'Alternate location indicator' field value.", 
 982      can_be_none = True 
 983  ) 
 984  uf.add_keyarg( 
 985      name = "verbosity", 
 986      default = 1, 
 987      py_type = "int", 
 988      desc_short = "verbosity level", 
 989      desc = "The amount of information to print out.  Set to zero to silence the user function, or one to see all messages." 
 990  ) 
 991  uf.add_keyarg( 
 992      name = "merge", 
 993      default = False, 
 994      py_type = "bool", 
 995      desc_short = "merge structure flag", 
 996      desc = "A flag which if set to True will try to merge the PDB structure into the currently loaded structures." 
 997  ) 
 998  # Description. 
 999  uf.desc.append(Desc_container()) 
1000  uf.desc[-1].add_paragraph("The reading of PDB files into relax is quite a flexible procedure allowing for both models, defined as an ensemble of the same molecule but with different atomic positions, and different molecules within the same model.  One of more molecules can exist in one or more models.  The flexibility allows PDB models to be converted into different molecules and different PDB files loaded as the same molecule but as different models.") 
1001  uf.desc[-1].add_paragraph("In a PDB file, the models are specified by the MODEL PDB record.  All the supported PDB readers in relax recognise this.  The internal reader defines molecules using the TER PDB record.  In both cases, the molecules will be numbered consecutively from 1.") 
1002  uf.desc[-1].add_paragraph("Setting the molecule name allows the molecule within the PDB (within one model) to have a custom name.  If not set, then the molecules will be named after the file name, with the molecule number appended if more than one exists.") 
1003  uf.desc[-1].add_paragraph("Note that relax will complain if it cannot work out what to do.") 
1004  uf.desc[-1].add_paragraph("This is able to handle uncompressed, bzip2 compressed files, or gzip compressed files automatically.  The full file name including extension can be supplied, however, if the file cannot be found, this function will search for the file name with '.bz2' appended followed by the file name with '.gz' appended.") 
1005  uf.desc[-1].add_paragraph("If a PDB file contains alternative atomic locations, then the alternate location indicator must be specified to allow one of the multiple coordinate sets to be selected.") 
1006  # Prompt examples. 
1007  uf.desc.append(Desc_container("Prompt examples")) 
1008  uf.desc[-1].add_paragraph("To load all structures from the PDB file 'test.pdb' in the directory '~/pdb', including all models and all molecules, type one of:") 
1009  uf.desc[-1].add_prompt("relax> structure.read_pdb('test.pdb', '~/pdb')") 
1010  uf.desc[-1].add_prompt("relax> structure.read_pdb(file='test.pdb', dir='pdb')") 
1011  uf.desc[-1].add_paragraph("To load the 10th model from the file 'test.pdb' and naming it 'CaM', use one of:") 
1012  uf.desc[-1].add_prompt("relax> structure.read_pdb('test.pdb', read_model=10, set_mol_name='CaM')") 
1013  uf.desc[-1].add_prompt("relax> structure.read_pdb(file='test.pdb', read_model=10, set_mol_name='CaM')") 
1014  uf.desc[-1].add_paragraph("To load models 1 and 5 from the file 'test.pdb' as two different structures of the same model, type one of:") 
1015  uf.desc[-1].add_prompt("relax> structure.read_pdb('test.pdb', read_model=[1, 5], set_model_num=[1, 1])") 
1016  uf.desc[-1].add_prompt("relax> structure.read_pdb('test.pdb', set_mol_name=['CaM_1', 'CaM_2'], read_model=[1, 5], set_model_num=[1, 1])") 
1017  uf.desc[-1].add_paragraph("To load the files 'lactose_MCMM4_S1_1.pdb', 'lactose_MCMM4_S1_2.pdb', 'lactose_MCMM4_S1_3.pdb' and 'lactose_MCMM4_S1_4.pdb' as models, type the following sequence of commands:") 
1018  uf.desc[-1].add_prompt("relax> structure.read_pdb('lactose_MCMM4_S1_1.pdb', set_mol_name='lactose_MCMM4_S1', set_model_num=1)") 
1019  uf.desc[-1].add_prompt("relax> structure.read_pdb('lactose_MCMM4_S1_2.pdb', set_mol_name='lactose_MCMM4_S1', set_model_num=2)") 
1020  uf.desc[-1].add_prompt("relax> structure.read_pdb('lactose_MCMM4_S1_3.pdb', set_mol_name='lactose_MCMM4_S1', set_model_num=3)") 
1021  uf.desc[-1].add_prompt("relax> structure.read_pdb('lactose_MCMM4_S1_4.pdb', set_mol_name='lactose_MCMM4_S1', set_model_num=4)") 
1022  uf.backend = pipe_control.structure.main.read_pdb 
1023  uf.menu_text = "read_&pdb" 
1024  uf.gui_icon = "oxygen.actions.document-open" 
1025  uf.wizard_height_desc = 360 
1026  uf.wizard_size = (1000, 750) 
1027  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'read_pdb.png' 
1028   
1029   
1030  # The structure.read_xyz user function. 
1031  uf = uf_info.add_uf('structure.read_xyz') 
1032  uf.title = "Reading structures from XYZ files." 
1033  uf.title_short = "XYZ reading." 
1034  uf.add_keyarg( 
1035      name = "file", 
1036      py_type = "str", 
1037      arg_type = "file sel", 
1038      desc_short = "file name", 
1039      desc = "The name of the XYZ file.", 
1040      wiz_filesel_wildcard = WILDCARD_STRUCT_XYZ_ALL, 
1041      wiz_filesel_style = FD_OPEN 
1042  ) 
1043  uf.add_keyarg( 
1044      name = "dir", 
1045      py_type = "str", 
1046      arg_type = "dir", 
1047      desc_short = "directory name", 
1048      desc = "The directory where the file is located.", 
1049      can_be_none = True 
1050  ) 
1051  uf.add_keyarg( 
1052      name = "read_mol", 
1053      py_type = "int_or_int_list", 
1054      desc_short = "molecule number to read", 
1055      desc = "If set, only the given molecule(s) will be read.  The molecules are numbered consecutively from 1.  If unset, then all molecules will be loaded.  By providing a list of numbers such as [1, 2], multiple molecules will be read.", 
1056      can_be_none = True 
1057  ) 
1058  uf.add_keyarg( 
1059      name = "set_mol_name", 
1060      py_type = "str_or_str_list", 
1061      desc_short = "setting of molecule names", 
1062      desc = "Set the names of the read molecules.  If unset, then the molecules will be automatically labelled based on the file name or other information.  This can either be a single name or a list of names.", 
1063      can_be_none = True 
1064  ) 
1065  uf.add_keyarg( 
1066      name = "read_model", 
1067      py_type = "int_or_int_list", 
1068      desc_short = "model to read", 
1069      desc = "If set, only the given model number(s) from the PDB file will be read.  Otherwise all models will be read.  This can be a single number or list of numbers.", 
1070      can_be_none = True 
1071  ) 
1072  uf.add_keyarg( 
1073      name = "set_model_num", 
1074      py_type = "int_or_int_list", 
1075      desc_short = "setting of model numbers", 
1076      desc = "Set the model numbers of the loaded molecules.  If unset, then the PDB model numbers will be preserved if they exist.  This can be a single number or list of numbers.", 
1077      can_be_none = True 
1078  ) 
1079  uf.add_keyarg( 
1080      name = "verbosity", 
1081      default = 1, 
1082      py_type = "int", 
1083      desc_short = "verbosity level", 
1084      desc = "The amount of information to print out.  Set to zero to silence the user function, or one to see all messages." 
1085  ) 
1086  # Description. 
1087  uf.desc.append(Desc_container()) 
1088  uf.desc[-1].add_paragraph("The XYZ files with different models, which defined as an ensemble of the same molecule but with different atomic positions, can be read into relax.  If there are several molecules in one xyz file, please separate them into different files and then load them individually.  Loading different models and different molecules is controlled by specifying the molecule number read, setting the molecule names, specifying which model to read, and setting the model numbers.") 
1089  uf.desc[-1].add_paragraph("The setting of molecule names is used to name the molecules within the XYZ (within one model).  If not set, then the molecules will be named after the file name, with the molecule number appended if more than one exists.") 
1090  uf.desc[-1].add_paragraph("Note that relax will complain if it cannot work out what to do.") 
1091  # Prompt examples. 
1092  uf.desc.append(Desc_container("Prompt examples")) 
1093  uf.desc[-1].add_paragraph("To load all structures from the XYZ file 'test.xyz' in the directory '~/xyz', including all models and all molecules, type one of:") 
1094  uf.desc[-1].add_prompt("relax> structure.read_xyz('test.xyz', '~/xyz')") 
1095  uf.desc[-1].add_prompt("relax> structure.read_xyz(file='test.xyz', dir='xyz')") 
1096  uf.desc[-1].add_paragraph("To load the 10th model from the file 'test.xyz' and naming it 'CaM', use one of:") 
1097  uf.desc[-1].add_prompt("relax> structure.read_xyz('test.xyz', read_model=10, set_mol_name='CaM')") 
1098  uf.desc[-1].add_prompt("relax> structure.read_xyz(file='test.xyz', read_model=10, set_mol_name='CaM')") 
1099  uf.desc[-1].add_paragraph("To load models 1 and 5 from the file 'test.xyz' as two different structures of the same model, type one of:") 
1100  uf.desc[-1].add_prompt("relax> structure.read_xyz('test.xyz', read_model=[1, 5], set_model_num=[1, 1])") 
1101  uf.desc[-1].add_prompt("relax> structure.read_xyz('test.xyz', set_mol_name=['CaM_1', 'CaM_2'], read_model=[1, 5], set_model_num=[1, 1])") 
1102  uf.desc[-1].add_paragraph("To load the files 'test_1.xyz', 'test_2.xyz', 'test_3.xyz' and 'test_4.xyz' as models, type the  following sequence of commands:") 
1103  uf.desc[-1].add_prompt("relax> structure.read_xyz('test_1.xyz', set_mol_name='test_1', set_model_num=1)") 
1104  uf.desc[-1].add_prompt("relax> structure.read_xyz('test_2.xyz', set_mol_name='test_2', set_model_num=2)") 
1105  uf.desc[-1].add_prompt("relax> structure.read_xyz('test_3.xyz', set_mol_name='test_3', set_model_num=3)") 
1106  uf.desc[-1].add_prompt("relax> structure.read_xyz('test_4.xyz', set_mol_name='test_4', set_model_num=4)") 
1107  uf.backend = pipe_control.structure.main.read_xyz 
1108  uf.menu_text = "read_&xyz" 
1109  uf.gui_icon = "oxygen.actions.document-open" 
1110  uf.wizard_height_desc = 400 
1111  uf.wizard_size = (900, 700) 
1112  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'read_xyz.png' 
1113   
1114   
1115  # The structure.rmsd user function. 
1116  uf = uf_info.add_uf('structure.rmsd') 
1117  uf.title = "Determine the RMSD between structures." 
1118  uf.title_short = "Structural RMSD." 
1119  uf.add_keyarg( 
1120      name = "pipes", 
1121      py_type = "str_list", 
1122      desc_short = "data pipes", 
1123      desc = "The data pipes to determine the RMSD for.", 
1124      wiz_combo_iter = pipe_names, 
1125      wiz_read_only = False, 
1126      can_be_none = True 
1127  ) 
1128  uf.add_keyarg( 
1129      name = "models", 
1130      py_type = "int_list_of_lists", 
1131      desc_short = "model list for each data pipe", 
1132      desc = "The list of models for each data pipe to determine the RMSD for.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
1133      can_be_none = True 
1134  ) 
1135  uf.add_keyarg( 
1136      name = "molecules", 
1137      py_type = "str_list_of_lists", 
1138      desc_short = "molecule list for each data pipe", 
1139      desc = "The list of molecules for each data pipe to determine the RMSD for.  The RMSD will only be calculated for atoms with identical residue name and number and atom name.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
1140      can_be_none = True 
1141  ) 
1142  uf.add_keyarg( 
1143      name = "atom_id", 
1144      py_type = "str", 
1145      desc_short = "atom identification string", 
1146      desc = "The atom identification string of the coordinates of interest.", 
1147      can_be_none = True 
1148  ) 
1149  # Description. 
1150  uf.desc.append(Desc_container()) 
1151  uf.desc[-1].add_paragraph("This allows the root mean squared deviation (RMSD) between all structures to be calculated.  The RMSDs for individual structures to the mean structure will be calculated and reported, and then these values averaged for the global RMSD.  This will be stored in the structural object of the current data pipe.") 
1152  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
1153  uf.desc[-1].add_paragraph(paragraph_atom_id) 
1154  # Prompt examples. 
1155  uf.desc.append(Desc_container("Prompt examples")) 
1156  uf.desc[-1].add_paragraph("To determine the RMSD of all models in the current data pipe, simply type:") 
1157  uf.desc[-1].add_prompt("relax> structure.rmsd()") 
1158  uf.backend = pipe_control.structure.main.rmsd 
1159  uf.menu_text = "&rmsd" 
1160  uf.wizard_height_desc = 400 
1161  uf.wizard_size = (900, 700) 
1162  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1163   
1164   
1165  # The structure.rotate user function. 
1166  uf = uf_info.add_uf('structure.rotate') 
1167  uf.title = "Rotate the internal structural object about the given origin by the rotation matrix." 
1168  uf.title_short = "Structure rotation." 
1169  uf.add_keyarg( 
1170      name = "R", 
1171      py_type = "float_matrix", 
1172      default = eye(3), 
1173      dim = (3, 3), 
1174      desc_short = "rotation matrix", 
1175      desc = "The rotation matrix in forwards rotation notation." 
1176  ) 
1177  uf.add_keyarg( 
1178      name = "origin", 
1179      py_type = "float_array", 
1180      dim = 3, 
1181      desc_short = "origin of rotation", 
1182      desc = "The origin or pivot of the rotation.", 
1183      can_be_none = True 
1184  ) 
1185  uf.add_keyarg( 
1186      name = "model", 
1187      py_type = "int", 
1188      desc_short = "model", 
1189      desc = "The model to rotate (which if not set will cause all models to be rotated).", 
1190      can_be_none = True 
1191  ) 
1192  uf.add_keyarg( 
1193      name = "atom_id", 
1194      py_type = "str", 
1195      desc_short = "atom ID string", 
1196      desc = "The atom identification string.", 
1197      can_be_none = True 
1198  ) 
1199  # Description. 
1200  uf.desc.append(Desc_container()) 
1201  uf.desc[-1].add_paragraph("This is used to rotate the internal structural data by the given rotation matrix.  If the origin is supplied, then this will act as the pivot of the rotation.  Otherwise, all structural data will be rotated about the point [0, 0, 0].  The rotation can be restricted to one specific model.") 
1202  uf.backend = pipe_control.structure.main.rotate 
1203  uf.menu_text = "&rotate" 
1204  uf.wizard_height_desc = 300 
1205  uf.wizard_size = (800, 600) 
1206  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1207   
1208   
1209  # The structure.sequence_alignment user function. 
1210  uf = uf_info.add_uf('structure.sequence_alignment') 
1211  uf.title = "Multiple sequence alignment (MSA) of structural data." 
1212  uf.title_short = "Multiple sequence alignment." 
1213  uf.add_keyarg( 
1214      name = "pipes", 
1215      py_type = "str_list", 
1216      desc_short = "data pipes", 
1217      desc = "The data pipes to use in the sequence alignment.", 
1218      wiz_combo_iter = pipe_names, 
1219      wiz_read_only = False, 
1220      can_be_none = True 
1221  ) 
1222  uf.add_keyarg( 
1223      name = "models", 
1224      py_type = "int_list_of_lists", 
1225      desc_short = "model list for each data pipe", 
1226      desc = "The list of models for each data pipe to use in the sequence alignment.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
1227      can_be_none = True 
1228  ) 
1229  uf.add_keyarg( 
1230      name = "molecules", 
1231      py_type = "str_list_of_lists", 
1232      desc_short = "molecule list for each data pipe", 
1233      desc = "The list of molecules for each data pipe to use in the sequence alignment.  This allows differently named molecules in the same or different data pipes to be superimposed.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
1234      can_be_none = True 
1235  ) 
1236  uf.add_keyarg( 
1237      name = "msa_algorithm", 
1238      default = "Central Star", 
1239      py_type = "str", 
1240      desc_short = "multiple sequence alignment (MSA) algorithm", 
1241      desc = "The multiple sequence alignment (MSA) algorithm used to align all the primary sequence of all structures of interest.", 
1242      wiz_element_type = "combo", 
1243      wiz_combo_choices = ["Central Star", "residue number"], 
1244      wiz_read_only = True 
1245  ) 
1246  uf.add_keyarg( 
1247      name = "pairwise_algorithm", 
1248      default = None, 
1249      py_type = "str", 
1250      desc_short = "pairwise alignment algorithm", 
1251      desc = "The pairwise alignment algorithm to align each pair of sequences.", 
1252      wiz_element_type = "combo", 
1253      wiz_combo_choices = ["NW70"], 
1254      wiz_read_only = True, 
1255      can_be_none = True 
1256  ) 
1257  uf.add_keyarg( 
1258      name = "matrix", 
1259      default = None, 
1260      py_type = "str", 
1261      desc_short = "substitution matrix", 
1262      desc = "The substitution matrix to use in the pairwise sequence alignment algorithm.", 
1263      wiz_element_type = "combo", 
1264      wiz_combo_choices = ["BLOSUM62", "PAM250", "NUC 4.4"], 
1265      wiz_read_only = True, 
1266      can_be_none = True 
1267  ) 
1268  uf.add_keyarg( 
1269      name = "gap_open_penalty", 
1270      default = 10.0, 
1271      py_type = "float", 
1272      desc_short = "gap opening penalty", 
1273      desc = "The penalty for introducing gaps, as a positive number." 
1274  ) 
1275  uf.add_keyarg( 
1276      name = "gap_extend_penalty", 
1277      default = 1.0, 
1278      py_type = "float", 
1279      desc_short = "gap extension penalty", 
1280      desc = "The penalty for extending a gap, as a positive number." 
1281  ) 
1282  uf.add_keyarg( 
1283      name = "end_gap_open_penalty", 
1284      default = 0.0, 
1285      py_type = "float", 
1286      desc_short = "end gap opening penalty", 
1287      desc = "The optional penalty for opening a gap at the end of a sequence." 
1288  ) 
1289  uf.add_keyarg( 
1290      name = "end_gap_extend_penalty", 
1291      default = 0.0, 
1292      py_type = "float", 
1293      desc_short = "end gap extension penalty", 
1294      desc = "The optional penalty for extending a gap at the end of a sequence." 
1295  ) 
1296  # Description. 
1297  uf.desc.append(Desc_container()) 
1298  uf.desc[-1].add_paragraph("To find the atoms in common between different molecules, a MSA of the primary sequence of the molecules is required.  This sequence alignment will then subsequently be used by any other user function which operates on multiple molecules.  The following MSA algorithms can be selected:") 
1299  uf.desc[-1].add_item_list_element("'Central Star'", "This is a heuristic, progressive alignment method using pairwise alignments to construct a MSA.  It consists of four major steps - pairwise alignment between all sequence pairs, finding the central sequence, iteratively aligning the sequences to the gapped central sequence, and introducing gaps in previous alignments during the iterative alignment.") 
1300  uf.desc[-1].add_item_list_element("'residue number'", "This will simply align the molecules based on residue number.") 
1301  uf.desc[-1].add_paragraph("For the MSA algorithms which require pairwise alignments, the following subalgorithms can be used:") 
1302  uf.desc[-1].add_item_list_element("'NW70'", "The Needleman-Wunsch alignment algorithm.  This has been modified to use the logic of the EMBOSS software for handling gap opening and extension penalties, as well as end penalties.") 
1303  uf.desc[-1].add_paragraph("For the MSAs or pairwise alignments which require a substitution matrix, one of the following can be used:") 
1304  uf.desc[-1].add_item_list_element("'BLOSUM62'", "The BLOcks SUbstitution Matrix for proteins with a cluster percentage >= 62%.") 
1305  uf.desc[-1].add_item_list_element("'PAM250'", "The point accepted mutation matrix for proteins with n = 250 evolutionary distance.") 
1306  uf.desc[-1].add_item_list_element("'NUC 4.4'", "The nucleotide 4.4 matrix for DNA/RNA.") 
1307  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
1308  # Prompt examples. 
1309  uf.desc.append(Desc_container("Prompt examples")) 
1310  uf.desc[-1].add_paragraph("To superimpose the structures in the 'A' data pipe onto the structures of the 'B' data pipe using backbone heavy atoms, type:") 
1311  uf.desc[-1].add_prompt("relax> structure.sequence_alignment(pipes=['B', 'A'], atom_id='@N,C,CA,O')") 
1312  uf.backend = pipe_control.structure.main.sequence_alignment 
1313  uf.menu_text = "&sequence_alignment" 
1314  uf.wizard_apply_button = False 
1315  uf.wizard_height_desc = 320 
1316  uf.wizard_size = (1000, 750) 
1317  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1318   
1319   
1320  # The structure.superimpose user function. 
1321  uf = uf_info.add_uf('structure.superimpose') 
1322  uf.title = "Superimpose a set of structures." 
1323  uf.title_short = "Structural superimposition." 
1324  uf.add_keyarg( 
1325      name = "pipes", 
1326      py_type = "str_list", 
1327      desc_short = "data pipes", 
1328      desc = "The data pipes to use in the superimposition.", 
1329      wiz_combo_iter = pipe_names, 
1330      wiz_read_only = False, 
1331      can_be_none = True 
1332  ) 
1333  uf.add_keyarg( 
1334      name = "models", 
1335      py_type = "int_list_of_lists", 
1336      desc_short = "model list for each data pipe", 
1337      desc = "The list of models for each data pipe to use in the superimposition.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
1338      can_be_none = True 
1339  ) 
1340  uf.add_keyarg( 
1341      name = "molecules", 
1342      py_type = "str_list_of_lists", 
1343      desc_short = "molecule list for each data pipe", 
1344      desc = "The list of molecules for each data pipe to use in the superimposition.  This allows differently named molecules in the same or different data pipes to be superimposed.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
1345      can_be_none = True 
1346  ) 
1347  uf.add_keyarg( 
1348      name = "atom_id", 
1349      py_type = "str", 
1350      desc_short = "atom ID string", 
1351      desc = "The atom identification string of the coordinates of interest.  This allows a subset of all residues or atoms to be used in the superimposition.  For example for protein backbone heavy atoms, this can be set to '@N,C,CA,O'.", 
1352      can_be_none = True 
1353  ) 
1354  uf.add_keyarg( 
1355      name = "displace_id", 
1356      py_type = "str_or_str_list", 
1357      desc_short = "displacement ID string(s)", 
1358      desc = "The atom identification string for restricting the displacement to a subset of all atoms.  If not set, then all atoms will be translated and rotated.  If supplied as a list of IDs, then the number of items must match the number of structures.", 
1359      can_be_none = True 
1360  ) 
1361  uf.add_keyarg( 
1362      name = "method", 
1363      default = "fit to mean", 
1364      py_type = "str", 
1365      desc_short = "superimposition method", 
1366      desc = "The superimposition method.", 
1367      wiz_element_type = "combo", 
1368      wiz_combo_choices = ["fit to mean", "fit to first"], 
1369      wiz_read_only = True 
1370  ) 
1371  uf.add_keyarg( 
1372      name = "centre_type", 
1373      py_type = "str", 
1374      default = "centroid", 
1375      desc_short = "centre type", 
1376      desc = "The type of centre to user for the superimposition, i.e. either the standard centroid superimposition or a superimposition using the centre of mass (CoM).", 
1377      wiz_element_type = "combo", 
1378      wiz_combo_choices = ["The centroid", "The centre of mass (CoM)"], 
1379      wiz_combo_data = ["centroid", "CoM"] 
1380  ) 
1381  uf.add_keyarg( 
1382      name = "centroid", 
1383      py_type = "float_array", 
1384      desc_short = "centroid position", 
1385      desc = "The alternative position of the centroid.", 
1386      can_be_none = True 
1387  ) 
1388  # Description. 
1389  uf.desc.append(Desc_container()) 
1390  uf.desc[-1].add_paragraph("This allows a set of related structures to be superimposed to each other.  If a multiple sequence alignment (MSA) of the molecules has already been performed with the structure.sequence_alignment user function, this will allow residues with different numbering to be superimposed.  Otherwise only residues with the same numbering will be used in the superimposition.  Two superimposition methods are currently supported:") 
1391  uf.desc[-1].add_item_list_element("'fit to mean'", "All models are fit to the mean structure.  This is the default and most accurate method for an ensemble description.  It is an iterative method which first calculates a mean structure and then fits each model to the mean structure using the Kabsch algorithm.  This is repeated until convergence.") 
1392  uf.desc[-1].add_item_list_element("'fit to first'", "This is quicker but is not as accurate for an ensemble description.  The Kabsch algorithm is used to rotate and translate each model to be superimposed onto the first model of the first data pipe.") 
1393  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
1394  uf.desc[-1].add_paragraph(paragraph_atom_id) 
1395  uf.desc[-1].add_paragraph(paragraph_displace_id) 
1396  uf.desc[-1].add_paragraph("By supplying the position of the centroid, an alternative position than the standard rigid body centre is used as the focal point of the superimposition.  The allows, for example, the superimposition about a pivot point.") 
1397  # Prompt examples. 
1398  uf.desc.append(Desc_container("Prompt examples")) 
1399  uf.desc[-1].add_paragraph("To superimpose all sets of models, type one of:") 
1400  uf.desc[-1].add_prompt("relax> structure.superimpose()") 
1401  uf.desc[-1].add_prompt("relax> structure.superimpose(method='fit to mean')") 
1402  uf.desc[-1].add_paragraph("To superimpose the models 1, 2, 3, 5 onto model 4, type:") 
1403  uf.desc[-1].add_prompt("relax> structure.superimpose(models=[[4, 1, 2, 3, 5]], method='fit to first')") 
1404  uf.desc[-1].add_paragraph("To superimpose an ensemble of protein structures using only the backbone heavy atoms, type one of:") 
1405  uf.desc[-1].add_prompt("relax> structure.superimpose(atom_id='@N,C,CA,O')") 
1406  uf.desc[-1].add_prompt("relax> structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O')") 
1407  uf.desc[-1].add_paragraph("To superimpose the structures in the 'A' data pipe onto the structures of the 'B' data pipe using backbone heavy atoms, type one of:") 
1408  uf.desc[-1].add_prompt("relax> structure.superimpose(['B', 'A'], None, 'fit to first', '@N,C,CA,O')") 
1409  uf.desc[-1].add_prompt("relax> structure.superimpose(pipes=['B', 'A'], method='fit to first', atom_id='@N,C,CA,O')") 
1410  uf.backend = pipe_control.structure.main.superimpose 
1411  uf.menu_text = "&superimpose" 
1412  uf.wizard_apply_button = False 
1413  uf.wizard_height_desc = 370 
1414  uf.wizard_size = (1000, 750) 
1415  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1416   
1417   
1418  # The structure.translate user function. 
1419  uf = uf_info.add_uf('structure.translate') 
1420  uf.title = "Laterally displace the internal structural object by the translation vector." 
1421  uf.title_short = "Structure translation." 
1422  uf.add_keyarg( 
1423      name = "T", 
1424      py_type = "float_array", 
1425      dim = 3, 
1426      desc_short = "translation vector", 
1427      desc = "The translation vector." 
1428  ) 
1429  uf.add_keyarg( 
1430      name = "model", 
1431      py_type = "int", 
1432      desc_short = "model", 
1433      desc = "The model to translate (which if not set will cause all models to be translate).", 
1434      can_be_none = True 
1435  ) 
1436  uf.add_keyarg( 
1437      name = "atom_id", 
1438      py_type = "str", 
1439      desc_short = "atom ID string", 
1440      desc = "The atom identification string.", 
1441      can_be_none = True 
1442  ) 
1443  # Description. 
1444  uf.desc.append(Desc_container()) 
1445  uf.desc[-1].add_paragraph("This is used to translate the internal structural data by the given translation vector.  The translation can be restricted to one specific model.") 
1446  uf.backend = pipe_control.structure.main.translate 
1447  uf.menu_text = "&translate" 
1448  uf.wizard_size = (750, 500) 
1449  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1450   
1451   
1452  # The structure.web_of_motion user function. 
1453  uf = uf_info.add_uf('structure.web_of_motion') 
1454  uf.title = "Create a PDB representation of motion between structures using a web of interconnecting lines." 
1455  uf.title_short = "Web of motion between models." 
1456  uf.add_keyarg( 
1457      name = "pipes", 
1458      py_type = "str_list", 
1459      desc_short = "data pipes", 
1460      desc = "The data pipes to generate the web between.", 
1461      wiz_combo_iter = pipe_names, 
1462      wiz_read_only = False, 
1463      can_be_none = True 
1464  ) 
1465  uf.add_keyarg( 
1466      name = "models", 
1467      py_type = "int_list_of_lists", 
1468      desc_short = "model list for each data pipe", 
1469      desc = "The list of models for each data pipe to generate the web between.  The number of elements must match the pipes argument.  If no models are given, then all will be used.", 
1470      can_be_none = True 
1471  ) 
1472  uf.add_keyarg( 
1473      name = "molecules", 
1474      py_type = "str_list_of_lists", 
1475      desc_short = "molecule list for each data pipe", 
1476      desc = "The list of molecules for each data pipe to generate the web between.  This allows differently named molecules in the same or different data pipes to be superimposed.  The number of elements must match the pipes argument.  If no molecules are given, then all will be used.", 
1477      can_be_none = True 
1478  ) 
1479  uf.add_keyarg( 
1480      name = "atom_id", 
1481      py_type = "str", 
1482      desc_short = "atom identification string", 
1483      desc = "The atom identification string of the coordinates of interest.", 
1484      can_be_none = True 
1485  ) 
1486  uf.add_keyarg( 
1487      name = "file", 
1488      py_type = "str_or_inst", 
1489      arg_type = "file sel", 
1490      desc_short = "file name", 
1491      desc = "The name of the PDB file.", 
1492      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
1493      wiz_filesel_style = FD_SAVE 
1494  ) 
1495  uf.add_keyarg( 
1496      name = "dir", 
1497      py_type = "str", 
1498      arg_type = "dir", 
1499      desc_short = "directory name", 
1500      desc = "The directory to save the file to.", 
1501      can_be_none = True 
1502  ) 
1503  uf.add_keyarg( 
1504      name = "force", 
1505      default = False, 
1506      py_type = "bool", 
1507      desc_short = "force flag", 
1508      desc = "A flag which if set to True will cause any pre-existing files to be overwritten." 
1509  ) 
1510  # Description. 
1511  uf.desc.append(Desc_container()) 
1512  uf.desc[-1].add_paragraph("This will create a PDB representation of the motion between the atoms of a given set of structures.  Identical atoms of the structures are concatenated into one model, within a temporary internal structural object, linked together using PDB CONECT records, and then written to the PDB file.") 
1513  uf.desc[-1].add_paragraph(paragraph_multi_struct) 
1514  uf.desc[-1].add_paragraph(paragraph_atom_id) 
1515  # Prompt examples. 
1516  uf.desc.append(Desc_container("Prompt examples")) 
1517  uf.desc[-1].add_paragraph("To create a web of motion for the models 1, 3, and 5, type:") 
1518  uf.desc[-1].add_prompt("relax> structure.web_of_motion(models=[[1, 3, 5]], file='web.pdb')") 
1519  uf.desc[-1].add_paragraph("To create a web of motion for the molecules 'A', 'B', 'C', and 'D', type:") 
1520  uf.desc[-1].add_prompt("relax> structure.web_of_motion(molecules=[['A', 'B', 'C', 'D']], file='web.pdb')") 
1521  uf.backend = pipe_control.structure.main.web_of_motion 
1522  uf.menu_text = "&web_of_motion" 
1523  uf.wizard_height_desc = 450 
1524  uf.wizard_size = (1000, 750) 
1525  uf.wizard_apply_button = False 
1526  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' 
1527   
1528   
1529  # The structure.write_pdb user function. 
1530  uf = uf_info.add_uf('structure.write_pdb') 
1531  uf.title = "Writing structures to a PDB file." 
1532  uf.title_short = "PDB writing." 
1533  uf.add_keyarg( 
1534      name = "file", 
1535      py_type = "str_or_inst", 
1536      arg_type = "file sel", 
1537      desc_short = "file name", 
1538      desc = "The name of the PDB file.", 
1539      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
1540      wiz_filesel_style = FD_SAVE 
1541  ) 
1542  uf.add_keyarg( 
1543      name = "dir", 
1544      py_type = "str", 
1545      arg_type = "dir", 
1546      desc_short = "directory name", 
1547      desc = "The directory where the file is located.", 
1548      can_be_none = True 
1549  ) 
1550  uf.add_keyarg( 
1551      name = "model_num", 
1552      py_type = "int", 
1553      desc_short = "model number", 
1554      desc = "Restrict the writing of structural data to a single model in the PDB file.", 
1555      can_be_none = True 
1556  ) 
1557  uf.add_keyarg( 
1558      name = "compress_type", 
1559      default = 0, 
1560      py_type = "int", 
1561      desc_short = "compression type", 
1562      desc = "The type of compression to use when creating the file.", 
1563      wiz_element_type = "combo", 
1564      wiz_combo_choices = [ 
1565          "No compression", 
1566          "bzip2 compression", 
1567          "gzip compression" 
1568      ], 
1569      wiz_combo_data = [ 
1570          0, 
1571          1, 
1572          2 
1573      ], 
1574      wiz_read_only = True 
1575  ) 
1576  uf.add_keyarg( 
1577      name = "force", 
1578      default = False, 
1579      py_type = "bool", 
1580      desc_short = "force flag", 
1581      desc = "A flag which if set to True will cause any pre-existing files to be overwritten." 
1582  ) 
1583  # Description. 
1584  uf.desc.append(Desc_container()) 
1585  uf.desc[-1].add_paragraph("This will write all of the structural data loaded in the current data pipe to be converted to the PDB format and written to file.  Specifying the model number allows single models to be output.") 
1586  uf.desc[-1].add_paragraph("The default behaviour of this function is to not compress the file.  The compression can, however, be changed to either bzip2 or gzip compression.  If the '.bz2' or '.gz' extension is not included in the file name, it will be added.  This behaviour is controlled by the compression type which can be set to") 
1587  uf.desc[-1].add_item_list_element("0", "No compression (no file extension).") 
1588  uf.desc[-1].add_item_list_element("1", "bzip2 compression ('.bz2' file extension).") 
1589  uf.desc[-1].add_item_list_element("2", "gzip compression ('.gz' file extension).") 
1590  # Prompt examples. 
1591  uf.desc.append(Desc_container("Prompt examples")) 
1592  uf.desc[-1].add_paragraph("To write all models and molecules to the PDB file 'ensemble.pdb' within the directory '~/pdb', type one of:") 
1593  uf.desc[-1].add_prompt("relax> structure.write_pdb('ensemble.pdb', '~/pdb')") 
1594  uf.desc[-1].add_prompt("relax> structure.write_pdb(file='ensemble.pdb', dir='pdb')") 
1595  uf.desc[-1].add_paragraph("To write model number 3 into the new file 'test.pdb', use one of:") 
1596  uf.desc[-1].add_prompt("relax> structure.write_pdb('test.pdb', model_num=3)") 
1597  uf.desc[-1].add_prompt("relax> structure.write_pdb(file='test.pdb', model_num=3)") 
1598  uf.backend = pipe_control.structure.main.write_pdb 
1599  uf.menu_text = "&write_pdb" 
1600  uf.gui_icon = "oxygen.actions.document-save" 
1601  uf.wizard_height_desc = 400 
1602  uf.wizard_size = (900, 700) 
1603  uf.wizard_apply_button = False 
1604  uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'write_pdb.png' 
1605