Skip to content

Commit a89c1f7

Browse files
fix: AppBio QuantStudio Design & Analysis - Check for valid rq values before setting r_sample and r_target (#1138)
Co-authored-by: Nathan Stender <nathan.stender@benchling.com>
1 parent 00d41e7 commit a89c1f7

4 files changed

Lines changed: 18627 additions & 3 deletions

File tree

src/allotropy/parsers/appbio_quantstudio_designandanalysis/appbio_quantstudio_designandanalysis_calculated_documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def iter_standard_curve_calc_docs(
391391

392392
def iter_relative_standard_curve_calc_docs(
393393
well_items: list[WellItem],
394-
r_sample: str,
394+
r_sample: str | None,
395395
r_target: str | None,
396396
) -> Iterator[CalculatedDocument]:
397397
# Y-Intercept, Slope, Quantity, Amp score, Cq confidence,

src/allotropy/parsers/appbio_quantstudio_designandanalysis/structure/relative_standard_curve/creator.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222
)
2323

2424

25+
def _has_valid_rq_values(reader: DesignQuantstudioReader) -> bool:
26+
"""Return True if the RQ Replicate Group Result sheet contains at least one
27+
non-null Rq value.
28+
29+
When all Rq values are null or nan (e.g. the reference calibrator sample
30+
was not processed or all wells undetermined), the reference sample cannot be
31+
inferred and RQ-derived calculated data documents must be skipped.
32+
"""
33+
sheet = reader.get_non_empty_sheet_or_none("RQ Replicate Group Result")
34+
if sheet is None or "Rq" not in sheet.columns:
35+
return False
36+
return bool(sheet["Rq"].notna().any())
37+
38+
2539
class RelativeStandardCurveCreator(Creator):
2640
PLUGIN_REGEX: ClassVar[str] = r"Relative Quantification"
2741
EXPECTED_SHEETS: ClassVar[list[str]] = [
@@ -34,8 +48,12 @@ def create(cls, reader: DesignQuantstudioReader) -> Data:
3448
wells = RelativeStandardCurveWellList.create(reader, header)
3549
well_items = wells.get_well_items()
3650

37-
r_sample = Result.get_reference_sample(reader)
38-
r_target = Result.get_reference_target(reader)
51+
if not _has_valid_rq_values(reader):
52+
r_sample = None
53+
r_target = None
54+
else:
55+
r_sample = Result.get_reference_sample(reader)
56+
r_target = Result.get_reference_target(reader)
3957

4058
return Data(
4159
header,

0 commit comments

Comments
 (0)