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

Source Code for Module user_functions.n_state_model

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2014 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 n_state_model user function definitions.""" 
 24   
 25  # Python module imports. 
 26  import dep_check 
 27  if dep_check.wx_module: 
 28      from wx import FD_SAVE 
 29  else: 
 30      FD_SAVE = -1 
 31   
 32  # relax module imports. 
 33  from graphics import WIZARD_IMAGE_PATH 
 34  from specific_analyses.n_state_model import uf as n_state_model_uf 
 35  from specific_analyses.n_state_model.parameters import elim_no_prob, number_of_states, ref_domain, select_model 
 36  from user_functions.data import Uf_info; uf_info = Uf_info() 
 37  from user_functions.objects import Desc_container 
 38  from user_functions.wildcards import WILDCARD_STRUCT_PDB_ALL 
 39   
 40   
 41  # The user function class. 
 42  uf_class = uf_info.add_class('n_state_model') 
 43  uf_class.title = "Class for the N-state models." 
 44  uf_class.menu_text = "&n_state_model" 
 45  uf_class.gui_icon = "relax.n_state_model" 
 46   
 47   
 48  # The n_state_model.CoM user function. 
 49  uf = uf_info.add_uf('n_state_model.CoM') 
 50  uf.title = "The defunct centre of mass (CoM) analysis." 
 51  uf.title_short = "CoM analysis." 
 52  uf.add_keyarg( 
 53      name = "pivot_point", 
 54      default = [0.0, 0.0, 0.0], 
 55      py_type = "num_list", 
 56      dim = 3, 
 57      desc_short = "pivot point", 
 58      desc = "The pivot point of the motions between the two domains.", 
 59      list_titles = ['X coordinate', 'Y coordinate', 'Z coordinate'] 
 60  ) 
 61  uf.add_keyarg( 
 62      name = "centre", 
 63      py_type = "num_list", 
 64      dim = 3, 
 65      desc_short = "centre of mass", 
 66      desc = "Manually specify the CoM of the initial position prior to the N rotations to the positions of the N states.  This is optional.", 
 67      list_titles = ['X coordinate', 'Y coordinate', 'Z coordinate'], 
 68      can_be_none = True 
 69  ) 
 70  # Description. 
 71  uf.desc.append(Desc_container()) 
 72  uf.desc[-1].add_paragraph("WARNING:  This analysis is now defunct!") 
 73  uf.desc[-1].add_paragraph("This is used for analysing the domain motion information content of the N states from the N-state model.  The states do not correspond to physical states, hence nothing can be extracted from the individual states.  This analysis involves the calculation of the pivot to centre of mass (pivot-CoM) order parameter and subsequent cone of motions.") 
 74  uf.desc[-1].add_paragraph("For the analysis, both the pivot point and centre of mass must be specified.  The supplied pivot point must be a vector of floating point numbers of length 3.  If the centre of mass is supplied, it must also be a vector of floating point numbers (of length 3).  If the centre of mass is not supplied, then the CoM will be calculated from the selected parts of a previously loaded structure.") 
 75  # Prompt examples. 
 76  uf.desc.append(Desc_container("Prompt examples")) 
 77  uf.desc[-1].add_paragraph("To perform an analysis where the pivot is at the origin and the CoM is set to the N-terminal domain of a previously loaded PDB file (the C-terminal domain has been deselected), type:") 
 78  uf.desc[-1].add_prompt("relax> n_state_model.CoM()") 
 79  uf.desc[-1].add_paragraph("To perform an analysis where the pivot is at the origin (because the real pivot has been shifted to this position) and the CoM is at the position [0, 0, 1], type one of:") 
 80  uf.desc[-1].add_prompt("relax> n_state_model.CoM(centre=[0, 0, 1])") 
 81  uf.desc[-1].add_prompt("relax> n_state_model.CoM(centre=[0.0, 0.0, 1.0])") 
 82  uf.desc[-1].add_prompt("relax> n_state_model.CoM(pivot_point=[0.0, 0.0, 0.0], centre=[0.0, 0.0, 1.0])") 
 83  uf.backend = n_state_model_uf.CoM 
 84  uf.menu_text = "Co&M" 
 85  uf.wizard_height_desc = 350 
 86  uf.wizard_size = (800, 600) 
 87  uf.wizard_apply_button = False 
 88  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
 89   
 90   
 91  # The n_state_model.cone_pdb user function. 
 92  uf = uf_info.add_uf('n_state_model.cone_pdb') 
 93  uf.title = "Create a PDB file representing the cone models from the centre of mass (CoM) analysis." 
 94  uf.title_short = "Cone PDB creation." 
 95  uf.add_keyarg( 
 96      name = "cone_type", 
 97      py_type = "str", 
 98      desc_short = "cone type", 
 99      desc = "The type of cone model to represent.", 
100      wiz_element_type = "combo", 
101      wiz_combo_choices = [ 
102          'diff in cone', 
103          'diff on cone' 
104      ], 
105      wiz_read_only = True 
106  ) 
107   
108  uf.add_keyarg( 
109      name = "scale", 
110      default = 1.0, 
111      py_type = "num", 
112      desc_short = "scaling factor", 
113      desc = "Value for scaling the pivot-CoM distance which the size of the cone defaults to." 
114  ) 
115   
116  uf.add_keyarg( 
117      name = "file", 
118      default = "cone.pdb", 
119      py_type = "str", 
120      arg_type = "file sel", 
121      desc_short = "file name", 
122      desc = "The name of the PDB file.", 
123      wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, 
124      wiz_filesel_style = FD_SAVE 
125  ) 
126   
127  uf.add_keyarg( 
128      name = "dir", 
129      py_type = "str", 
130      arg_type = "dir", 
131      desc_short = "directory name", 
132      desc = "The directory where the file is located.", 
133      can_be_none = True 
134  ) 
135   
136  uf.add_keyarg( 
137      name = "force", 
138      default = False, 
139      py_type = "bool", 
140      desc_short = "force flag", 
141      desc = "A flag which, if set to True, will overwrite the any pre-existing file." 
142  ) 
143  # Description. 
144  uf.desc.append(Desc_container()) 
145  uf.desc[-1].add_paragraph("WARNING:  This analysis is now defunct!") 
146  uf.desc[-1].add_paragraph("This creates a PDB file containing an artificial geometric structure to represent the various cone models.  These models include:") 
147  uf.desc[-1].add_list_element("'diff in cone'") 
148  uf.desc[-1].add_list_element("'diff on cone'") 
149  uf.desc[-1].add_paragraph("The model can be selected by setting the cone type to one of these values.  The cone is represented as an isotropic cone with its axis parallel to the average pivot-CoM vector, the vertex placed at the pivot point of the domain motions, and the length of the edge of the cone equal to the pivot-CoM distance multiplied by the scaling factor.  The resultant PDB file can subsequently read into any molecular viewer.") 
150  uf.desc[-1].add_paragraph("There are four different types of residue within the PDB.  The pivot point is represented as as a single carbon atom of the residue 'PIV'.  The cone consists of numerous H atoms of the residue 'CON'.  The average pivot-CoM vector is presented as the residue 'AVE' with one carbon atom positioned at the pivot and the other at the head of the vector (after scaling by the scaling factor).  Finally, if Monte Carlo have been performed, there will be multiple 'MCC' residues representing the cone for each simulation, and multiple 'MCA' residues representing the varying average pivot-CoM vector for each simulation.") 
151  uf.desc[-1].add_paragraph("To create the diffusion in a cone PDB representation, a uniform distribution of vectors on a sphere is generated using spherical coordinates with the polar angle defined from the average pivot-CoM vector.  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 are all placed into the PDB file as 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 representing the filled cone.") 
152  uf.backend = n_state_model_uf.cone_pdb 
153  uf.menu_text = "&cone_pdb" 
154  uf.wizard_height_desc = 480 
155  uf.wizard_size = (1000, 750) 
156  uf.wizard_apply_button = False 
157  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
158   
159   
160  # The n_state_model.elim_no_prob user function. 
161  uf = uf_info.add_uf('n_state_model.elim_no_prob') 
162  uf.title = "Eliminate the structures or states with no probability." 
163  uf.title_short = "Insignificant state elimination." 
164  # Description. 
165  uf.desc.append(Desc_container()) 
166  uf.desc[-1].add_paragraph("This will simply remove the structures from the N-state analysis which have an optimised probability of zero.") 
167  # Prompt examples. 
168  uf.desc.append(Desc_container("Prompt examples")) 
169  uf.desc[-1].add_paragraph("Simply type:") 
170  uf.desc[-1].add_prompt("relax> n_state_model.elim_no_prob(N=8)") 
171  uf.backend = elim_no_prob 
172  uf.menu_text = "&elim_no_prob" 
173  uf.gui_icon = "oxygen.actions.list-remove" 
174  uf.wizard_size = (700, 400) 
175  uf.wizard_apply_button = False 
176  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
177   
178   
179  # The n_state_model.number_of_states user function. 
180  uf = uf_info.add_uf('n_state_model.number_of_states') 
181  uf.title = "Set the number of states in the N-state model." 
182  uf.title_short = "Number of states." 
183  uf.add_keyarg( 
184      name = "N", 
185      default = 1, 
186      py_type = "int", 
187      desc_short = "number of states N", 
188      desc = "The number of states." 
189  ) 
190  # Description. 
191  uf.desc.append(Desc_container()) 
192  uf.desc[-1].add_paragraph("Prior to optimisation, the number of states in the N-state model can be specified.  If the number of states is not set, then this parameter will be equal to the number of loaded structures - the ensemble size.") 
193  # Prompt examples. 
194  uf.desc.append(Desc_container("Prompt examples")) 
195  uf.desc[-1].add_paragraph("To set up an 8-state model, type:") 
196  uf.desc[-1].add_prompt("relax> n_state_model.number_of_states(N=8)") 
197  uf.backend = number_of_states 
198  uf.menu_text = "&number_of_states" 
199  uf.gui_icon = "oxygen.actions.edit-rename" 
200  uf.wizard_apply_button = False 
201  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
202   
203   
204  # The n_state_model.ref_domain user function. 
205  uf = uf_info.add_uf('n_state_model.ref_domain') 
206  uf.title = "Set the reference domain for the '2-domain' N-state model." 
207  uf.title_short = "Reference domain identification." 
208  uf.add_keyarg( 
209      name = "ref", 
210      py_type = "str", 
211      desc_short = "reference frame", 
212      desc = "The domain which will act as the frame of reference.  This is only valid for the '2-domain' N-state model." 
213  ) 
214  # Description. 
215  uf.desc.append(Desc_container()) 
216  uf.desc[-1].add_paragraph("Prior to optimisation of the '2-domain' N-state model, which of the two domains will act as the frame of reference must be specified.  The N-states will be rotations of the other domain, so to switch the frame of reference to the other domain simply transpose the rotation matrices.") 
217  # Prompt examples. 
218  uf.desc.append(Desc_container("Prompt examples")) 
219  uf.desc[-1].add_paragraph("To set up a 5-state model with 'C' domain being the frame of reference, type:") 
220  uf.desc[-1].add_prompt("relax> n_state_model.ref_domain(ref='C')") 
221  uf.backend = ref_domain 
222  uf.menu_text = "&ref_domain" 
223  uf.gui_icon = "oxygen.actions.edit-rename" 
224  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
225   
226   
227  # The n_state_model.select_model user function. 
228  uf = uf_info.add_uf('n_state_model.select_model') 
229  uf.title = "Select the N-state model type and set up the model." 
230  uf.title_short = "N-state model choice." 
231  uf.add_keyarg( 
232      name = "model", 
233      default = "population", 
234      py_type = "str", 
235      desc_short = "model", 
236      desc = "The name of the preset N-state model.", 
237      wiz_element_type = "combo", 
238      wiz_combo_choices = ["population", "fixed", "2-domain"], 
239      wiz_read_only = True 
240  ) 
241  # Description. 
242  uf.desc.append(Desc_container()) 
243  uf.desc[-1].add_paragraph("Prior to optimisation, the N-state model type should be selected.  The preset models are:") 
244  uf.desc[-1].add_item_list_element("'population'", "The N-state model whereby only populations are optimised.  The structures loaded into relax are assumed to be fixed, i.e. the orientations are not optimised, or if two domains are present the Euler angles for each state are fixed.  The parameters of the model include the weight or probability for each state and the alignment tensors - {p0, p1, ..., pN, Axx, Ayy, Axy, Axz, Ayz, ...}.") 
245  uf.desc[-1].add_item_list_element("'fixed'", "The N-state model whereby all motions are fixed and all populations are fixed to the set probabilities.  The parameters of the model are simply the parameters of each alignment tensor {Axx, Ayy, Axy, Axz, Ayz, ...}.") 
246  uf.desc[-1].add_item_list_element("'2-domain'", "The N-state model for a system of two domains, where one domain experiences a reduced tensor.") 
247  # Prompt examples. 
248  uf.desc.append(Desc_container("Prompt examples")) 
249  uf.desc[-1].add_paragraph("To analyse populations of states, type:") 
250  uf.desc[-1].add_prompt("relax> n_state_model.select_model(model='populations')") 
251  uf.backend = select_model 
252  uf.menu_text = "&select_model" 
253  uf.gui_icon = "oxygen.actions.list-add" 
254  uf.wizard_height_desc = 400 
255  uf.wizard_size = (800, 600) 
256  uf.wizard_image = WIZARD_IMAGE_PATH + 'n_state_model.png' 
257