Skip to content

Commit e1228c2

Browse files
fix: Molecular Devices SoftMax Pro - fix duplicate data source documents in spectrum measurements (#1033)
1 parent f8a4aa4 commit e1228c2

8 files changed

Lines changed: 12439 additions & 192360 deletions

File tree

src/allotropy/allotrope/schema_mappers/adm/plate_reader/rec/_2025/_03/plate_reader.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ class MeasurementType(Enum):
9999
EMISSION_LUMINESCENCE_CUBE_SPECTRUM = "EMISSION_LUMINESCENCE_CUBE_SPECTRUM"
100100
EXCITATION_LUMINESCENCE_CUBE_SPECTRUM = "EXCITATION_LUMINESCENCE_CUBE_SPECTRUM"
101101

102+
@property
103+
def is_spectrum(self) -> bool:
104+
return self in (
105+
MeasurementType.ULTRAVIOLET_ABSORBANCE_CUBE_SPECTRUM,
106+
MeasurementType.EMISSION_FLUORESCENCE_CUBE_SPECTRUM,
107+
MeasurementType.EXCITATION_FLUORESCENCE_CUBE_SPECTRUM,
108+
MeasurementType.EMISSION_LUMINESCENCE_CUBE_SPECTRUM,
109+
MeasurementType.EXCITATION_LUMINESCENCE_CUBE_SPECTRUM,
110+
)
111+
102112

103113
@dataclass(frozen=True)
104114
class ErrorDocument:

src/allotropy/parsers/moldev_softmax_pro/softmax_pro_data_creator.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,34 +170,27 @@ def _create_spectrum_measurement(
170170

171171

172172
def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measurement]:
173-
174-
measurement_type = plate_block.measurement_type
175173
data_elements = list(plate_block.iter_data_elements(position))
176174

177175
# Handle spectrum measurements - create single measurement with spectrum_data_cube
178-
if measurement_type in (
179-
MeasurementType.ULTRAVIOLET_ABSORBANCE_CUBE_SPECTRUM,
180-
MeasurementType.EMISSION_FLUORESCENCE_CUBE_SPECTRUM,
181-
MeasurementType.EXCITATION_FLUORESCENCE_CUBE_SPECTRUM,
182-
MeasurementType.EMISSION_LUMINESCENCE_CUBE_SPECTRUM,
183-
MeasurementType.EXCITATION_LUMINESCENCE_CUBE_SPECTRUM,
184-
):
176+
if plate_block.measurement_type.is_spectrum:
185177
measurement = _create_spectrum_measurement(plate_block, data_elements)
186178
if not measurement:
187179
return []
188180
return [measurement]
189181

190182
return [
191183
Measurement(
192-
type_=measurement_type,
184+
type_=plate_block.measurement_type,
193185
identifier=data_element.uuid,
194186
absorbance=(
195187
(
196188
data_element.value
197189
if data_element.value is not None
198190
else NEGATIVE_ZERO
199191
)
200-
if measurement_type == MeasurementType.ULTRAVIOLET_ABSORBANCE
192+
if plate_block.measurement_type
193+
is MeasurementType.ULTRAVIOLET_ABSORBANCE
201194
else None
202195
),
203196
fluorescence=(
@@ -206,7 +199,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
206199
if data_element.value is not None
207200
else NEGATIVE_ZERO
208201
)
209-
if measurement_type == MeasurementType.FLUORESCENCE
202+
if plate_block.measurement_type is MeasurementType.FLUORESCENCE
210203
else None
211204
),
212205
luminescence=(
@@ -215,7 +208,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
215208
if data_element.value is not None
216209
else NEGATIVE_ZERO
217210
)
218-
if measurement_type == MeasurementType.LUMINESCENCE
211+
if plate_block.measurement_type is MeasurementType.LUMINESCENCE
219212
else None
220213
),
221214
profile_data_cube=_get_data_cube(plate_block, data_element),
@@ -299,12 +292,22 @@ def create_calculated_data(data: StructureData) -> list[CalculatedDocument]:
299292
def _get_calc_docs_data_sources(
300293
plate_block: PlateBlock, position: str
301294
) -> list[DataSource]:
295+
data_elements = list(plate_block.iter_data_elements(position))
296+
297+
if plate_block.measurement_type.is_spectrum:
298+
return [
299+
DataSource(
300+
reference=Referenceable(data_elements[0].uuid),
301+
feature=plate_block.header.read_mode,
302+
)
303+
]
304+
302305
return [
303306
DataSource(
304307
reference=Referenceable(data_source.uuid),
305308
feature=plate_block.header.read_mode,
306309
)
307-
for data_source in plate_block.iter_data_elements(position)
310+
for data_source in data_elements
308311
]
309312

310313

0 commit comments

Comments
 (0)