1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from copy import deepcopy
24
25
28 """Class containing the function for creating a run."""
29
30 self.relax = relax
31
32
33 - def create(self, run=None, run_type=None):
34 """Function for creating a run."""
35
36
37 if run in self.relax.data.run_names:
38 raise RelaxRunError, run
39
40
41 valid = ['jw', 'mf', 'noe', 'relax_fit', 'srls']
42
43
44 if not run_type in valid:
45 raise RelaxError, "The run type name " + `run_type` + " is invalid and must be one of the strings in the list " + `valid` + "."
46
47
48 self.relax.data.run_names.append(run)
49 self.relax.data.run_types.append(run_type)
50
51
53 """Function for deleting a run."""
54
55
56 if run != None and not run in self.relax.data.run_names:
57 raise RelaxNoRunError, run
58
59
60 for name in dir(self.relax.data):
61
62 object = getattr(self.relax.data, name)
63
64
65 if not hasattr(object, 'keys'):
66 continue
67
68
69 if object.has_key(run):
70 del(object[run])
71
72
73 self.eliminate_unused_runs()
74
75
77 """Function for eliminating any runs for which there is no data."""
78
79
80 keep_runs = []
81
82
83 for name in dir(self.relax.data):
84
85 object = getattr(self.relax.data, name)
86 if not hasattr(object, 'keys'):
87 continue
88
89
90 for key in object.keys():
91 if not key in keep_runs:
92 keep_runs.append(key)
93
94
95 for run in self.relax.data.run_names:
96 if not run in keep_runs:
97
98 index = self.relax.data.run_names.index(run)
99
100
101 self.relax.data.run_names.remove(run)
102
103
104 temp = self.relax.data.run_types.pop(index)
105
106
108 """Function for creating a list of runs."""
109
110
111 if run == None:
112 runs = deepcopy(self.relax.data.run_names)
113
114
115 elif type(run) == str:
116 runs = [run]
117
118
119 else:
120 runs = run
121
122
123 return runs
124