Skip to content

Commit ef95d83

Browse files
committed
Added well count and removed errors from missing assay bed ids
1 parent 2e0f0d1 commit ef95d83

3 files changed

Lines changed: 432 additions & 1883 deletions

File tree

src/allotropy/parsers/luminex_xponent/luminex_xponent_reader.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
1010
from allotropy.named_file_contents import NamedFileContents
11+
from allotropy.parsers.constants import round_to_nearest_well_count
1112
from allotropy.parsers.lines_reader import CsvReader, read_to_lines
1213
from allotropy.parsers.luminex_xponent import constants
1314
from allotropy.parsers.utils.pandas import read_csv
@@ -222,6 +223,17 @@ def add_mandatory_columns(
222223
)
223224
results["Units"] = units_df
224225

226+
@staticmethod
227+
def _get_well_count(df: pd.DataFrame) -> int:
228+
# Count unique values in WELL LOCATION matching Excel-like cell ids: Letter(s) + Number(s)
229+
# Example matches: A1, B12, AA3
230+
pattern = r"^[A-Za-z]+\d+$"
231+
values = df["WELL LOCATION"].astype(str).str.strip()
232+
matching = values[values.str.match(pattern)]
233+
unique_count = int(matching.str.upper().nunique())
234+
nearest = round_to_nearest_well_count(unique_count)
235+
return int(nearest or 0)
236+
225237
@classmethod
226238
def parse(
227239
cls, lines: list[str]
@@ -295,7 +307,7 @@ def parse(
295307
],
296308
2: ["", "", "", "", "", "", ""],
297309
3: ["", "", "", "", "", "", ""],
298-
4: ["", "", "", "", "", "", ""],
310+
4: ["", "", "", "", cls._get_well_count(df), "", ""],
299311
5: ["", "", "", "", "", "", ""],
300312
}
301313
)

src/allotropy/parsers/luminex_xponent/luminex_xponent_structure.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ def _get_plate_well_count(cls, header_data: pd.DataFrame) -> float:
138138
msg = "Unable to find plate well count in ProtocolPlate row, expected value at index 3."
139139
raise AllotropeConversionError(msg) from e
140140

141-
plate_well_count = try_non_nan_float_or_none(str(plate_well_count))
142-
return plate_well_count or -0.0
141+
return try_float(str(plate_well_count), "plate well count")
143142

144143

145144
def create_calibration(calibration_data: SeriesData) -> Calibration:
@@ -274,13 +273,7 @@ def get_statistic_dimensions(analyte: str) -> list[StatisticDimension]:
274273
key for key in count_data.series.index if key not in metadata_keys
275274
]
276275
for analyte in analyte_keys:
277-
assay_bead_identifier = bead_ids_data.get(str, analyte, "")
278-
if not assay_bead_identifier:
279-
errors.append(
280-
Error(
281-
error="Not reported", feature=f"{analyte} assay bead identifier"
282-
)
283-
)
276+
assay_bead_identifier = bead_ids_data.get(str, analyte, "N/A")
284277
analytes.append(
285278
Analyte(
286279
identifier=(analyte_identifier := random_uuid_str()),

0 commit comments

Comments
 (0)