Skip to content

Commit bddb022

Browse files
fix: Luminex xponent - handle case for missing calibration report field (#1039)
1 parent fa963de commit bddb022

4 files changed

Lines changed: 34 additions & 23 deletions

File tree

src/allotropy/allotrope/schema_mappers/adm/multi_analyte_profiling/benchling/_2024/_09/multi_analyte_profiling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class MeasurementGroup:
117117
@dataclass(frozen=True)
118118
class Calibration:
119119
name: str
120-
report: str
121120
time: str
121+
report: str | None = None
122122

123123

124124
@dataclass(frozen=True)

src/allotropy/parsers/luminex_xponent/luminex_xponent_structure.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,39 @@ def _get_plate_well_count(cls, header_data: pd.DataFrame) -> float:
129129
def create_calibration(calibration_data: SeriesData) -> Calibration:
130130
"""Create a CalibrationItem from a calibration line.
131131
132-
Each line should follow the pattern "Last <calibration_name>,<calibration_report> <calibration_time><,,,,"
133-
example: "Last F3DeCAL1 Calibration,Passed 05/17/2023 09:25:11,,,,,,"
132+
Each line should follow one of these patterns:
133+
- "Last <calibration_name>,<calibration_report> <calibration_time><,,,,"
134+
- "Last <calibration_name>,<calibration_time><,,,,"
134135
"""
135136
if len(calibration_data.series.index) < MINIMUM_CALIBRATION_LINE_COLS:
136137
msg = f"Expected at least two columns on the calibration line, got:\n{calibration_data.series}."
137138
raise AllotropeConversionError(msg)
138139

139-
calibration_result = calibration_data.series.iloc[1].split(maxsplit=1)
140-
if len(calibration_result) != EXPECTED_CALIBRATION_RESULT_LEN:
141-
msg = f"Invalid calibration result format, expected to split into two values, got: {calibration_result}."
140+
calibration_info = calibration_data.series.iloc[1].strip()
141+
142+
# Check if the calibration info starts with a known status value
143+
status_values = ["Passed", "Failed", "Calibrated", "Verified"]
144+
first_word = calibration_info.split()[0] if calibration_info.split() else ""
145+
146+
report = None
147+
time = None
148+
149+
if first_word in status_values:
150+
calibration_result = calibration_info.split(maxsplit=1)
151+
if len(calibration_result) == EXPECTED_CALIBRATION_RESULT_LEN:
152+
report = calibration_result[0]
153+
time = calibration_result[1]
154+
elif calibration_info and any(char.isdigit() for char in calibration_info):
155+
time = calibration_info
156+
157+
if not time:
158+
msg = f"Invalid calibration result format, got: ['{calibration_info}']."
142159
raise AllotropeConversionError(msg)
143160

144161
return Calibration(
145162
name=calibration_data.series.iloc[0].replace("Last", "").strip(),
146-
report=calibration_result[0],
147-
time=calibration_result[1],
163+
time=time,
164+
report=report,
148165
)
149166

150167

tests/parsers/luminex_xponent/luminex_xponent_structure_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_create_calibration_item() -> None:
138138

139139
assert create_calibration(
140140
SeriesData(pd.Series([name, f"{report} {time}"]))
141-
) == Calibration(name, report, time)
141+
) == Calibration(name, time, report)
142142

143143

144144
def test_create_calibration_item_invalid_line_format() -> None:
@@ -153,7 +153,7 @@ def test_create_calibration_item_invalid_line_format() -> None:
153153

154154
def test_create_calibration_item_invalid_calibration_result() -> None:
155155
bad_result = "bad_result"
156-
error = f"Invalid calibration result format, expected to split into two values, got: ['{bad_result}']"
156+
error = f"Invalid calibration result format, got: ['{bad_result}']"
157157
with pytest.raises(AllotropeConversionError, match=re.escape(error)):
158158
create_calibration(SeriesData(pd.Series(["Last CalReport", bad_result])))
159159

tests/parsers/luminex_xponent/testdata/luminex_xPONENT_NaN_and_not_reported_values.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20553,7 +20553,7 @@
2055320553
"file name": "luminex_xPONENT_NaN_and_not_reported_values.csv",
2055420554
"UNC path": "tests/parsers/luminex_xponent/testdata/luminex_xPONENT_NaN_and_not_reported_values.csv",
2055520555
"ASM converter name": "allotropy_luminex_xponent",
20556-
"ASM converter version": "0.1.98",
20556+
"ASM converter version": "0.1.99",
2055720557
"software name": "xPONENT",
2055820558
"software version": "4.3.309.1"
2055920559
},
@@ -20564,33 +20564,27 @@
2056420564
"calibration document": [
2056520565
{
2056620566
"calibration name": "F3DeCAL1 Calibration",
20567-
"calibration time": "2025-07-17T01:00:00+00:00",
20568-
"calibration report": "1/1/2025"
20567+
"calibration time": "2025-01-01T01:00:00+00:00"
2056920568
},
2057020569
{
2057120570
"calibration name": "F3DCAL2 Calibration",
20572-
"calibration time": "2025-07-17T01:00:00+00:00",
20573-
"calibration report": "1/1/2025"
20571+
"calibration time": "2025-01-01T01:00:00+00:00"
2057420572
},
2057520573
{
2057620574
"calibration name": "F3DCAL3 Calibration",
20577-
"calibration time": "2025-07-17T01:00:00+00:00",
20578-
"calibration report": "1/1/2025"
20575+
"calibration time": "2025-01-01T01:00:00+00:00"
2057920576
},
2058020577
{
2058120578
"calibration name": "F3DeVER1 Verification",
20582-
"calibration time": "2025-07-17T01:00:00+00:00",
20583-
"calibration report": "1/1/2025"
20579+
"calibration time": "2025-01-01T01:00:00+00:00"
2058420580
},
2058520581
{
2058620582
"calibration name": "F3DVER2 Verification",
20587-
"calibration time": "2025-07-17T01:00:00+00:00",
20588-
"calibration report": "1/1/2025"
20583+
"calibration time": "2025-01-01T01:00:00+00:00"
2058920584
},
2059020585
{
2059120586
"calibration name": "Fluidics Test",
20592-
"calibration time": "2025-07-17T01:00:00+00:00",
20593-
"calibration report": "1/1/2025"
20587+
"calibration time": "2025-01-01T01:00:00+00:00"
2059420588
}
2059520589
]
2059620590
}

0 commit comments

Comments
 (0)