|
28 | 28 | from allotropy.allotrope.models.shared.definitions.custom import ( |
29 | 29 | TQuantityValueDegreeCelsius, |
30 | 30 | TQuantityValueMicroliterPerMinute, |
| 31 | + TQuantityValueMolar, |
31 | 32 | TQuantityValueNanomolar, |
32 | 33 | TQuantityValuePercent, |
| 34 | + TQuantityValuePerMolarPerSecond, |
| 35 | + TQuantityValuePerSecond, |
33 | 36 | TQuantityValueResonanceUnits, |
34 | 37 | TQuantityValueSecondTime, |
35 | 38 | ) |
|
41 | 44 | from allotropy.parsers.utils.calculated_data_documents.definition import ( |
42 | 45 | CalculatedDocument, |
43 | 46 | ) |
44 | | -from allotropy.parsers.utils.values import assert_not_none, quantity_or_none |
| 47 | +from allotropy.parsers.utils.values import assert_not_none, has_value, quantity_or_none |
45 | 48 | from allotropy.types import DictType |
46 | 49 |
|
47 | 50 |
|
@@ -87,33 +90,49 @@ class ReportPoint: |
87 | 90 | custom_info: DictType | None = None |
88 | 91 |
|
89 | 92 |
|
| 93 | +@dataclass(frozen=True) |
| 94 | +class DeviceControlDocument: |
| 95 | + device_type: str |
| 96 | + flow_cell_identifier: str | None = None |
| 97 | + flow_path: str | None = None |
| 98 | + flow_rate: float | None = None |
| 99 | + contact_time: float | None = None |
| 100 | + dilution: float | None = None |
| 101 | + sample_temperature_setting: float | None = None |
| 102 | + device_control_custom_info: DictType | None = None |
| 103 | + |
| 104 | + |
90 | 105 | @dataclass(frozen=True) |
91 | 106 | class Measurement: |
92 | 107 | identifier: str |
93 | 108 | sample_identifier: str |
94 | | - device_type: str |
95 | 109 | type_: MeasurementType |
| 110 | + device_control_document: list[DeviceControlDocument] |
96 | 111 | location_identifier: str | None = None |
97 | 112 | batch_identifier: str | None = None |
98 | 113 | well_plate_identifier: str | None = None |
99 | 114 | sample_role_type: str | None = None |
100 | 115 | concentration: float | None = None |
101 | 116 | method_name: str | None = None |
102 | 117 | ligand_identifier: str | None = None |
103 | | - flow_cell_identifier: str | None = None |
104 | | - flow_path: str | None = None |
105 | | - flow_rate: float | None = None |
106 | | - contact_time: float | None = None |
107 | | - dilution: float | None = None |
108 | | - device_control_custom_info: DictType | None = None |
109 | 118 | sample_custom_info: DictType | None = None |
110 | 119 |
|
111 | 120 | # Sensorgram |
112 | 121 | sensorgram_data_cube: DataCube | None = None |
113 | 122 |
|
| 123 | + # Processed Data |
| 124 | + binding_on_rate_measurement_datum__kon_: float | None = None |
| 125 | + binding_off_rate_measurement_datum__koff_: float | None = None |
| 126 | + equilibrium_dissociation_constant__kd_: float | None = None |
| 127 | + maximum_binding_capacity__rmax_: float | None = None |
| 128 | + processed_data_custom_info: DictType | None = None |
| 129 | + |
114 | 130 | # Report point |
115 | 131 | report_point_data: list[ReportPoint] | None = None |
116 | 132 |
|
| 133 | + # Data processing |
| 134 | + data_processing_document: DictType | None = None |
| 135 | + |
117 | 136 |
|
118 | 137 | @dataclass(frozen=True) |
119 | 138 | class MeasurementGroup: |
@@ -153,6 +172,7 @@ def map_model(self, data: Data) -> Model: |
153 | 172 | model_number=data.metadata.model_number, |
154 | 173 | brand_name=data.metadata.brand_name, |
155 | 174 | product_manufacturer=data.metadata.product_manufacturer, |
| 175 | + equipment_serial_number=data.metadata.equipment_serial_number, |
156 | 176 | device_document=( |
157 | 177 | [ |
158 | 178 | DeviceDocumentItem( |
@@ -213,6 +233,60 @@ def _get_measurement_document_item( |
213 | 233 | def _get_surface_plasmon_resonance_measurement_document( |
214 | 234 | self, measurement: Measurement, metadata: Metadata |
215 | 235 | ) -> MeasurementDocument: |
| 236 | + processed_data_document = ProcessedDataDocumentItem( |
| 237 | + data_processing_document=( |
| 238 | + { |
| 239 | + key: value |
| 240 | + for key, value in measurement.data_processing_document.items() |
| 241 | + if value is not None |
| 242 | + } |
| 243 | + if measurement.data_processing_document |
| 244 | + else None |
| 245 | + ), |
| 246 | + binding_on_rate_measurement_datum__kon_=quantity_or_none( |
| 247 | + TQuantityValuePerMolarPerSecond, |
| 248 | + measurement.binding_on_rate_measurement_datum__kon_, |
| 249 | + ), |
| 250 | + binding_off_rate_measurement_datum__koff_=quantity_or_none( |
| 251 | + TQuantityValuePerSecond, |
| 252 | + measurement.binding_off_rate_measurement_datum__koff_, |
| 253 | + ), |
| 254 | + equilibrium_dissociation_constant__KD_=quantity_or_none( |
| 255 | + TQuantityValueMolar, |
| 256 | + measurement.equilibrium_dissociation_constant__kd_, |
| 257 | + ), |
| 258 | + maximum_binding_capacity__Rmax_=quantity_or_none( |
| 259 | + TQuantityValueResonanceUnits, |
| 260 | + measurement.maximum_binding_capacity__rmax_, |
| 261 | + ), |
| 262 | + report_point_aggregate_document=( |
| 263 | + ReportPointAggregateDocument( |
| 264 | + report_point_document=[ |
| 265 | + add_custom_information_document( |
| 266 | + ReportPointDocumentItem( |
| 267 | + report_point_identifier=report_point.identifier, |
| 268 | + identifier_role=report_point.identifier_role, |
| 269 | + absolute_resonance=TQuantityValueResonanceUnits( |
| 270 | + value=report_point.absolute_resonance |
| 271 | + ), |
| 272 | + relative_resonance=quantity_or_none( |
| 273 | + TQuantityValueResonanceUnits, |
| 274 | + report_point.relative_resonance, |
| 275 | + ), |
| 276 | + time_setting=TQuantityValueSecondTime( |
| 277 | + value=report_point.time_setting |
| 278 | + ), |
| 279 | + ), |
| 280 | + custom_info_doc=report_point.custom_info, |
| 281 | + ) |
| 282 | + for report_point in measurement.report_point_data |
| 283 | + ] |
| 284 | + ) |
| 285 | + if measurement.report_point_data |
| 286 | + else None |
| 287 | + ), |
| 288 | + ) |
| 289 | + |
216 | 290 | return MeasurementDocument( |
217 | 291 | measurement_identifier=measurement.identifier, |
218 | 292 | sample_document=add_custom_information_document( |
@@ -245,55 +319,39 @@ def _get_surface_plasmon_resonance_measurement_document( |
245 | 319 | device_control_document=[ |
246 | 320 | add_custom_information_document( |
247 | 321 | DeviceControlDocumentItem( |
248 | | - flow_cell_identifier=measurement.flow_cell_identifier, |
249 | | - flow_path=measurement.flow_path, |
| 322 | + sample_temperature_setting=quantity_or_none( |
| 323 | + TQuantityValueDegreeCelsius, |
| 324 | + device_control.sample_temperature_setting, |
| 325 | + ), |
| 326 | + flow_cell_identifier=device_control.flow_cell_identifier, |
| 327 | + flow_path=device_control.flow_path, |
250 | 328 | flow_rate=quantity_or_none( |
251 | 329 | TQuantityValueMicroliterPerMinute, |
252 | | - measurement.flow_rate, |
| 330 | + device_control.flow_rate, |
253 | 331 | ), |
254 | 332 | contact_time=quantity_or_none( |
255 | | - TQuantityValueSecondTime, measurement.contact_time |
| 333 | + TQuantityValueSecondTime, device_control.contact_time |
256 | 334 | ), |
257 | 335 | dilution_factor=quantity_or_none( |
258 | | - TQuantityValuePercent, measurement.dilution |
| 336 | + TQuantityValuePercent, device_control.dilution |
259 | 337 | ), |
260 | | - device_type=measurement.device_type, |
| 338 | + device_type=device_control.device_type, |
261 | 339 | ), |
262 | | - custom_info_doc=measurement.device_control_custom_info, |
| 340 | + custom_info_doc=device_control.device_control_custom_info, |
263 | 341 | ) |
| 342 | + for device_control in measurement.device_control_document |
264 | 343 | ] |
265 | 344 | ), |
266 | 345 | processed_data_aggregate_document=( |
267 | 346 | ProcessedDataAggregateDocument( |
268 | 347 | processed_data_document=[ |
269 | | - ProcessedDataDocumentItem( |
270 | | - report_point_aggregate_document=ReportPointAggregateDocument( |
271 | | - report_point_document=[ |
272 | | - add_custom_information_document( |
273 | | - ReportPointDocumentItem( |
274 | | - report_point_identifier=report_point.identifier, |
275 | | - identifier_role=report_point.identifier_role, |
276 | | - absolute_resonance=TQuantityValueResonanceUnits( |
277 | | - value=report_point.absolute_resonance |
278 | | - ), |
279 | | - relative_resonance=quantity_or_none( |
280 | | - TQuantityValueResonanceUnits, |
281 | | - report_point.relative_resonance, |
282 | | - ), |
283 | | - time_setting=TQuantityValueSecondTime( |
284 | | - value=report_point.time_setting |
285 | | - ), |
286 | | - ), |
287 | | - # TODO: probably this should be at the processed document level. |
288 | | - custom_info_doc=report_point.custom_info, |
289 | | - ) |
290 | | - for report_point in measurement.report_point_data |
291 | | - ] |
292 | | - ) |
293 | | - ), |
| 348 | + add_custom_information_document( |
| 349 | + processed_data_document, |
| 350 | + custom_info_doc=measurement.processed_data_custom_info, |
| 351 | + ) |
294 | 352 | ] |
295 | 353 | ) |
296 | | - if measurement.report_point_data |
| 354 | + if has_value(processed_data_document) |
297 | 355 | else None |
298 | 356 | ), |
299 | 357 | ) |
|
0 commit comments