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

Source Code for Module prompt.eliminate

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 Edward d'Auvergne                                  # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  import sys 
 24   
 25  from specific_fns.model_free import Model_free 
 26   
 27   
28 -class Eliminate:
29 - def __init__(self, relax):
30 """Class containing the function for model elimination.""" 31 32 self.relax = relax
33 34
35 - def eliminate(self, run=None, function=None, args=None):
36 """Function for model elimination. 37 38 Keyword arguments 39 ~~~~~~~~~~~~~~~~~ 40 41 run: The name of the run(s). By supplying a single string, array of strings, or None, a 42 single run, multiple runs, or all runs will be selected respectively. 43 44 function: A user supplied function for model elimination. 45 46 args: A tuple of arguments for model elimination. 47 48 49 Description 50 ~~~~~~~~~~~ 51 52 This function is used for model validation to eliminate or reject models prior to model 53 selection. Model validation is a part of mathematical modelling whereby models are either 54 accepted or rejected. 55 56 Empirical rules are used for model rejection and are listed below. However these can be 57 overridden by supplying a function. The function should accept five arguments, a string 58 defining a certain parameter, the value of the parameter, the run name, the minimisation 59 instance (ie the residue index if the model is residue specific), and the function 60 arguments. If the model is rejected, the function should return 1, otherwise it should 61 return 0. The function will be executed multiple times, once for each parameter of the 62 model. 63 64 The 'args' keyword argument should be a tuple, a list enclosed in round brackets, and will 65 be passed to the user supplied function or the inbuilt function. For a description of the 66 arguments accepted by the inbuilt functions, see below. 67 68 Once a model is rejected, the select flag corresponding to that model will be set to 0 so 69 that model selection, or any other function, will then skip the model. 70 """ 71 72 # Function intro text. 73 if self.relax.interpreter.intro: 74 text = sys.ps3 + "eliminate(" 75 text = text + "run=" + `run` 76 text = text + ", function=" + `function` 77 text = text + ", args=" + `args` + ")" 78 print text 79 80 # The run argument. 81 if run != None and type(run) != str and type(run) != list: 82 raise RelaxNoneStrListError, ('run', run) 83 if type(run) == list: 84 for i in xrange(len(run)): 85 if type(run[i]) != str: 86 raise RelaxListStrError, ('run', run) 87 88 # User supplied function. 89 if function != None and type(function) != FunctionType: 90 raise RelaxFunctionError, ('function', function) 91 92 # Function arguments. 93 if args != None and type(args) != tuple: 94 raise RelaxNoneTupleError, ('args', args) 95 96 # Execute the functional code. 97 self.relax.generic.eliminate.eliminate(run=run, function=function, args=args)
98 99 100 # Docstring modification. 101 ######################### 102 103 eliminate.__doc__ = eliminate.__doc__ + "\n\n" + Model_free.eliminate.__doc__ + "\n"
104