Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ class MeasurementType(Enum):
EMISSION_LUMINESCENCE_CUBE_SPECTRUM = "EMISSION_LUMINESCENCE_CUBE_SPECTRUM"
EXCITATION_LUMINESCENCE_CUBE_SPECTRUM = "EXCITATION_LUMINESCENCE_CUBE_SPECTRUM"

@property
def is_spectrum(self) -> bool:
return self in (
MeasurementType.ULTRAVIOLET_ABSORBANCE_CUBE_SPECTRUM,
MeasurementType.EMISSION_FLUORESCENCE_CUBE_SPECTRUM,
MeasurementType.EXCITATION_FLUORESCENCE_CUBE_SPECTRUM,
MeasurementType.EMISSION_LUMINESCENCE_CUBE_SPECTRUM,
MeasurementType.EXCITATION_LUMINESCENCE_CUBE_SPECTRUM,
)


@dataclass(frozen=True)
class ErrorDocument:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,34 +170,27 @@ def _create_spectrum_measurement(


def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measurement]:

measurement_type = plate_block.measurement_type
data_elements = list(plate_block.iter_data_elements(position))

# Handle spectrum measurements - create single measurement with spectrum_data_cube
if measurement_type in (
MeasurementType.ULTRAVIOLET_ABSORBANCE_CUBE_SPECTRUM,
MeasurementType.EMISSION_FLUORESCENCE_CUBE_SPECTRUM,
MeasurementType.EXCITATION_FLUORESCENCE_CUBE_SPECTRUM,
MeasurementType.EMISSION_LUMINESCENCE_CUBE_SPECTRUM,
MeasurementType.EXCITATION_LUMINESCENCE_CUBE_SPECTRUM,
):
if plate_block.measurement_type.is_spectrum:
measurement = _create_spectrum_measurement(plate_block, data_elements)
if not measurement:
return []
return [measurement]

return [
Measurement(
type_=measurement_type,
type_=plate_block.measurement_type,
identifier=data_element.uuid,
absorbance=(
(
data_element.value
if data_element.value is not None
else NEGATIVE_ZERO
)
if measurement_type == MeasurementType.ULTRAVIOLET_ABSORBANCE
if plate_block.measurement_type
is MeasurementType.ULTRAVIOLET_ABSORBANCE
else None
),
fluorescence=(
Expand All @@ -206,7 +199,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
if data_element.value is not None
else NEGATIVE_ZERO
)
if measurement_type == MeasurementType.FLUORESCENCE
if plate_block.measurement_type is MeasurementType.FLUORESCENCE
else None
),
luminescence=(
Expand All @@ -215,7 +208,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
if data_element.value is not None
else NEGATIVE_ZERO
)
if measurement_type == MeasurementType.LUMINESCENCE
if plate_block.measurement_type is MeasurementType.LUMINESCENCE
else None
),
profile_data_cube=_get_data_cube(plate_block, data_element),
Expand Down Expand Up @@ -299,12 +292,22 @@ def create_calculated_data(data: StructureData) -> list[CalculatedDocument]:
def _get_calc_docs_data_sources(
plate_block: PlateBlock, position: str
) -> list[DataSource]:
data_elements = list(plate_block.iter_data_elements(position))

if plate_block.measurement_type.is_spectrum:
Comment thread
nathan-stender marked this conversation as resolved.
return [
DataSource(
reference=Referenceable(data_elements[0].uuid),
feature=plate_block.header.read_mode,
)
]

return [
DataSource(
reference=Referenceable(data_source.uuid),
feature=plate_block.header.read_mode,
)
for data_source in plate_block.iter_data_elements(position)
for data_source in data_elements
]


Expand Down
Loading
Loading