forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractDataAnalysis.py
212 lines (172 loc) · 6.19 KB
/
AbstractDataAnalysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import abc
class AbstractDataAnalysis(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def characterise(self, edna_input):
"""
:returns: The EDNA Characterisation result XML.
:str:
"""
return None
@abc.abstractmethod
def get_html_report(self, edna_output):
"""
:returns: The path to the html result report generated by EDNA.
:rtype: str
"""
return None
@abc.abstractmethod
def from_params(self, ref_parameters, char_params, path_str):
"""Return xml input file for EDNA
:param ref_parameters: A named tuple or object with following fields:
'id',
'prefix',
'run_number',
'template',
'first_image',
'num_images',
'osc_start',
'osc_range',
'overlap',
'exp_time',
'num_passes',
'comments',
'path',
'centred_positions',
'energy',
'resolution',
'transmission',
'shutterless',
'inverse_beam',
'screening_id'
:param char_params: A named tuple or object with following fields:
# Optimisation parameters
'aimed_resolution'
'aimed_multiplicity'
'aimed_i_sigma'
'aimed_completness'
'strategy_complexity'
'induce_burn'
'use_permitted_rotation'
'permitted_phi_start'
'permitted_phi_end'
# Crystal
'max_crystal_vdim'
'min_crystal_vdim'
'max_crystal_vphi'
'min_crystal_vphi'
'space_group'
# Characterisation type
'use_min_dose'
'use_min_time'
'min_dose'
'min_time'
'account_rad_damage'
'not_use_low_res'
'auto_res'
'opt_sad'
'sad_res'
'determine_rad_params'
# Radiation damage model
'rad_suscept'
'beta'
'sigma'
:param path_str: Template string representing path to each image
"""
pass
"""
The resulting EDNA XML can be handled with a function similair to this.
It has to be adapted to the specific representation of a collection that
you have.
"""
def dc_from_edna_output(edna_output, sample, dcg, session,
char_params = None):
data_collections = []
edna_result = XSDataResultMXCuBE.parseString(edna_output)
try:
char_results = edna_result.getCharacterisationResult()
edna_strategy = char_results.getStrategyResult()
collection_plan = edna_strategy.getCollectionPlan()[0]
wedges = collection_plan.getCollectionStrategy().getSubWedge()
except:
pass
else:
try:
run_number = collection_plan.getCollectionPlanNumber().getValue()
except AttributeError:
run_number = None
try:
resolution = collection_plan.getStrategySummary().\
getResolution().getValue()
except AttributeError:
resolution = None
try:
transmission = collection_plan.getStrategySummary().\
getAttenuation().getValue()
except AttributeError:
transmission = None
try:
screening_id = edna_result.getScreeningId().getValue()
except AttributeError:
screening_id = None
for wedge in wedges:
exp_condition = wedge.getExperimentalCondition()
goniostat = exp_condition.getGoniostat()
beam = exp_condition.getBeam()
dc = DataCollection()
data_collections.append(dc)
dc.parameters.prefix = session.get_prefix(dc.parameters)
if run_number:
dc.parameters.run_number = run_number
if resolution:
dc.parameters.resolution = resolution
if transmission:
dc.parameters.transmission = transmission
if screening_id:
dc.parameters.screening_id = screening_id
try:
dc.parameters.osc_start = goniostat.\
getRotationAxisStart().getValue()
except AttributeError:
pass
try:
dc.parameters.osc_end = goniostat.\
getRotationAxisEnd().getValue()
except AttributeError:
pass
try:
dc.parameters.osc_width = goniostat.\
getOscillationWidth().getValue()
except AttributeError:
pass
try:
dc.parameters.num_images = \
int(abs(dc.parameters.osc_end - \
dc.parameters.osc_start) / dc.parameters.range)
except AttributeError:
pass
try:
dc.parameters.transmission = beam.getTransmission().getValue()
except AttributeError:
pass
try:
dc.parameters.energy = \
int(123984.0/beam.getWavelength().getValue())/10000.0
except AttributeError:
pass
try:
dc.parameters.exp_time = beam.getExposureTime().getValue()
except AttributeError:
pass
# dc.parameters.comments = enda_result.comments
# dc.parametets.path = enda_result.directory
# dc.parameters.centred_positions = enda_result.centred_positions
# dc.parameters.energy = enda_result.energy
# dc.parameters.esolution = enda_result.resolution
# dc.parameters.transmission = enda_result.transmission
# dc.parameters.screening_id = edna_resul.screening_id
dc.sample = sample
dc.parameters.directory = session.get_image_directory(sub_dir = dcg.name.lower().replace(' ',''))
if char_params:
dc.char_params = char_params
return data_collections