1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Module implementing the mathematical modelling step of model elimination."""
24
25
26 from lib.errors import RelaxError
27 from pipe_control import pipes
28 from specific_analyses.api import return_api
29
30
32 """Model elimination.
33
34 @keyword function: A user supplied function for model elimination. This function should accept
35 five arguments, a string defining a certain parameter, the value of the
36 parameter, the minimisation instance (ie the residue index if the model
37 is residue specific), and the function arguments. If the model is rejected,
38 the function should return True, otherwise it should return False. The
39 function will be executed multiple times, once for each parameter of the model.
40 @type function: function
41 @param args: The arguments to be passed to the user supplied function.
42 @type args: tuple
43 """
44
45
46 pipes.test()
47
48
49 api = return_api()
50
51
52 if hasattr(cdp, 'sim_state') and cdp.sim_state == True:
53 sim_state = True
54 else:
55 sim_state = False
56
57
58
59 for model_info in api.model_loop():
60
61
62
63 if not sim_state:
64
65 names = api.get_param_names(model_info)
66 values = api.get_param_values(model_info)
67
68
69 if names == None or values == None:
70 continue
71
72
73 if len(names) != len(values):
74 raise RelaxError("The names vector " + repr(names) + " is of a different length to the values vector " + repr(values) + ".")
75
76
77 flag = False
78 for j in range(len(names)):
79
80 if api.eliminate(names[j], values[j], model_info, args):
81 flag = True
82
83
84 if flag:
85 api.deselect(model_info)
86
87
88
89
90
91 else:
92
93 for j in range(cdp.sim_number):
94
95 names = api.get_param_names(model_info)
96 values = api.get_param_values(model_info, sim_index=j)
97
98
99 if names == None or values == None:
100 continue
101
102
103 if len(names) != len(values):
104 raise RelaxError("The names vector " + repr(names) + " is of a different length to the values vector " + repr(values) + ".")
105
106
107 flag = False
108 for k in range(len(names)):
109
110 if api.eliminate(names[k], values[k], model_info, args, sim=j):
111 flag = True
112
113
114 if flag:
115 api.deselect(model_info, sim_index=j)
116