Package specific_analyses :: Package frame_order :: Module checks
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.frame_order.checks

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2011,2013-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  """Module for checks for the frame order analysis.""" 
 24   
 25  # relax module imports. 
 26  from lib.checks import Check 
 27  from lib.errors import RelaxError 
 28  from pipe_control.pipes import cdp_name, get_pipe 
 29   
 30   
31 -def check_domain_func(domain=None):
32 """Check if the domain has been defined. 33 34 @keyword domain: The domain to check for. If None, then the check will be for any domain being defined. 35 @type domain: None or str 36 @return: The initialised RelaxError object if the domain is not defined, or nothing. 37 @rtype: None or RelaxError instance 38 """ 39 40 # Check that the domain is defined. 41 if not hasattr(cdp, 'domain'): 42 return RelaxError("No domains have been defined. Please use the domain user function.") 43 if domain != None and domain not in cdp.domain: 44 return RelaxError("The domain '%s' has not been defined. Please use the domain user function." % domain)
45 46 # Create the checking object. 47 check_domain = Check(check_domain_func) 48 49
50 -def check_model_func(pipe_name=None):
51 """Check if the frame order model has been set up. 52 53 @keyword pipe_name: The data pipe to check for, if not the current pipe. 54 @type pipe_name: None or str 55 @return: The initialised RelaxError object if the model is not set up, or nothing. 56 @rtype: None or RelaxError instance 57 """ 58 59 # The data pipe. 60 if pipe_name == None: 61 pipe_name = cdp_name() 62 63 # Get the data pipe. 64 dp = get_pipe(pipe_name) 65 66 # Check that the model is set up. 67 if not hasattr(dp, 'model'): 68 return RelaxError("The frame order model has not been set up, please use the frame_order.select_model user function.")
69 70 # Create the checking object. 71 check_model = Check(check_model_func) 72 73
74 -def check_parameters_func():
75 """Check if the frame order parameters exist. 76 77 @return: The initialised RelaxError object if the model parameters have not been setup, or nothing. 78 @rtype: None or RelaxError instance 79 """ 80 81 # The model has not been set up. 82 if not hasattr(cdp, 'params'): 83 return RelaxError("The frame order model has not been set up, no parameters have been defined.") 84 85 # The model has been set up. 86 else: 87 # Find missing parameters. 88 missing = [] 89 for param in cdp.params: 90 # Check that the parameters exists. 91 if not hasattr(cdp, param): 92 missing.append(param) 93 94 # Check that it has a value. 95 else: 96 obj = getattr(cdp, param) 97 if obj == None: 98 missing.append(param) 99 100 # Failure. 101 if len(missing): 102 return RelaxError("The frame order parameters %s have not been set up." % missing)
103 104 # Create the checking object. 105 check_parameters = Check(check_parameters_func) 106 107
108 -def check_pivot_func(pipe_name=None):
109 """Check that the pivot point has been set. 110 111 @keyword pipe_name: The data pipe to check the pivot for. This defaults to the current data pipe if not set. 112 @type pipe_name: str 113 @return: The initialised RelaxError object if the pivot point has not been set, or nothing. 114 @rtype: None or RelaxError instance 115 """ 116 117 # The data pipe. 118 if pipe_name == None: 119 pipe_name = cdp_name() 120 121 # Get the data pipe. 122 dp = get_pipe(pipe_name) 123 124 # Check for the pivot_x parameter. 125 if not hasattr(dp, 'pivot_x'): 126 return RelaxError("The pivot point has not been set, please use the frame_order.pivot user function to define the point.")
127 128 # Create the checking object. 129 check_pivot = Check(check_pivot_func) 130