Skip to content

Commit 56f0883

Browse files
fix unread warnings
1 parent b17ffc4 commit 56f0883

4 files changed

Lines changed: 427 additions & 315 deletions

File tree

src/allotropy/parsers/biorad_bioplex_manager/biorad_bioplex_manager_parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def create_data(self, named_file_contents: NamedFileContents) -> Data:
3535
# Only parse system-level metadata once, from the first well.
3636
wells = reader["Wells"].findall("Well")
3737
system_metadata = SystemMetadata.create(wells[0])
38+
plate_dimensions = reader["PlateDimensions"]
39+
plate_well_count = plate_dimensions.get_attr("TotalWells")
40+
plate_dimensions.get_unread()
3841

3942
return Data(
4043
create_metadata(
@@ -49,9 +52,7 @@ def create_data(self, named_file_contents: NamedFileContents) -> Data:
4952
"NativeDocumentLocation"
5053
].get_text_or_none(),
5154
experiment_type=reader["Description"].get_text_or_none(),
52-
plate_well_count=int(
53-
reader.get_attribute("PlateDimensions", "TotalWells")
54-
),
55+
plate_well_count=int(plate_well_count),
5556
)
5657
for well in [Well.create(well_xml) for well_xml in wells]
5758
],

src/allotropy/parsers/biorad_bioplex_manager/biorad_bioplex_manager_structure.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ def create(analyte_xml: StrictXmlElement) -> AnalyteMetadata:
4848
return AnalyteMetadata(
4949
name=analyte_xml.find("AnalyteName").get_text("AnalyteName"),
5050
region=try_int(analyte_xml.get_attr("RegionNumber"), "analyte_region"),
51-
error_msg=get_key_or_error(
52-
"error code", error_code, constants.ERROR_MAPPING
53-
)
54-
if error_code != "0"
55-
else None,
56-
custom_info=analyte_xml.get_unread(),
51+
error_msg=(
52+
get_key_or_error("error code", error_code, constants.ERROR_MAPPING)
53+
if error_code != "0"
54+
else None
55+
),
56+
custom_info={
57+
**analyte_xml.get_unread(),
58+
**reading_element.get_unread(),
59+
},
5760
)
5861

5962

@@ -90,9 +93,9 @@ def create(
9093
constants.SAMPLE_ROLE_TYPE_MAPPING,
9194
),
9295
sample_identifier=sample_metadata.find("Label").get_text("Label"),
93-
description=description_element.get_text_or_none()
94-
if description_element
95-
else None,
96+
description=(
97+
description_element.get_text_or_none() if description_element else None
98+
),
9699
errors=[analyte.error for analyte in analyte_metadata if analyte.error],
97100
sample_dilution=try_float_or_none(
98101
dilution_element.get_text_or_none() if dilution_element else None
@@ -102,7 +105,7 @@ def create(
102105
},
103106
custom_info={
104107
**sample_metadata.get_unread(),
105-
**member_well.get_unread(),
108+
**member_well.get_unread(skip={"WellNumber", "WellNo"}),
106109
},
107110
)
108111

@@ -134,22 +137,22 @@ class Well:
134137

135138
@staticmethod
136139
def create(well_xml: StrictXmlElement) -> Well:
140+
sample_volume_element = well_xml.recursive_find(["RunSettings", "SampleVolume"])
141+
stop_reading_criteria_element = well_xml.recursive_find(
142+
["RunSettings", "StopReadingCriteria"]
143+
)
137144

138145
return Well(
139146
name=get_well_name(well_xml.element.attrib),
140147
sample_volume_setting=try_float(
141-
well_xml.find("RunSettings")
142-
.find("SampleVolume")
143-
.get_text("SampleVolume"),
148+
sample_volume_element.get_text("SampleVolume"),
144149
"sample_volume",
145150
),
146151
detector_gain_setting=well_xml.find("RunConditions")
147152
.find("RP1Gain")
148153
.get_text("RP1Gain"),
149154
minimum_assay_bead_count_setting=try_int(
150-
well_xml.find("RunSettings")
151-
.find("StopReadingCriteria")
152-
.get_attr("BeadCount"),
155+
stop_reading_criteria_element.get_attr("BeadCount"),
153156
"minimum_assay_bead_count_settings",
154157
),
155158
acquisition_time=well_xml.find("AcquisitionTime").get_text(
@@ -161,7 +164,11 @@ def create(well_xml: StrictXmlElement) -> Well:
161164
),
162165
analyst=well_xml.find("User").get_text("User"),
163166
xml=well_xml.element,
164-
custom_info=well_xml.get_unread(),
167+
custom_info={
168+
**well_xml.get_unread(),
169+
**sample_volume_element.get_unread(),
170+
**stop_reading_criteria_element.get_unread(),
171+
},
165172
)
166173

167174

@@ -207,6 +214,7 @@ def create_analytes(
207214
analyte_region_dict: dict[str, str],
208215
regions_of_interest: list[str],
209216
) -> list[Analyte]:
217+
well_xml.get_unread() # already being captured by the Well class
210218
return [
211219
create_analyte(bead, analyte_region_dict)
212220
for child in well_xml.findall("BeadRegions")

tests/parsers/biorad_bioplex_manager/biorad_bioplex_manager_structure_test.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def test_create_analyte_metadata() -> None:
3030
analyte_xml = StrictXmlElement.create_from_bytes(analyte_xml_string.encode("utf-8"))
3131
analyte_metadata = AnalyteMetadata.create(analyte_xml)
3232
assert analyte_metadata == AnalyteMetadata(
33-
name="Pn4", region=18, error_msg=None, custom_info={}
33+
name="Pn4",
34+
region=18,
35+
error_msg=None,
36+
custom_info={"OutlierType": "None", "Valid": "true"},
3437
)
3538
assert analyte_metadata.error is None
3639

@@ -66,13 +69,15 @@ def test_create_well() -> None:
6669
analyst="baz",
6770
xml=well_xml.element,
6871
custom_info={
72+
"BeadCountIn": "0",
6973
"ColNo": "1",
7074
"PlateID": "555",
7175
"RowNo": "1",
7276
"RunProtocolDocumentLocation": "Z:\\corge\\quux_qux Luminex\\Protocols\\qux_15PLEX_ASSAY.spbx",
7377
"RunProtocolDocumentName": "qux_15PLEX_ASSAY",
7478
"TotalGatedEvents": "637",
7579
"TotalRegionEventCount": "609",
80+
"Unit": "µl",
7681
"WellNo": "1",
7782
},
7883
)
@@ -195,7 +200,7 @@ def test_create_sample() -> None:
195200
"12": "alpha",
196201
"15": "bravo",
197202
},
198-
custom_info={"ColNo": "12", "RowNo": "1", "WellNumber": "12"},
203+
custom_info={"ColNo": "12", "RowNo": "1"},
199204
)
200205

201206

@@ -218,7 +223,7 @@ def test_create_samples() -> None:
218223
analyte_region_dict={
219224
"12": "alpha",
220225
},
221-
custom_info={"ColNo": "12", "RowNo": "1", "WellNumber": "12"},
226+
custom_info={"ColNo": "12", "RowNo": "1"},
222227
),
223228
"B12": SampleMetadata(
224229
sample_type=SampleRoleType.blank_role,
@@ -229,7 +234,7 @@ def test_create_samples() -> None:
229234
analyte_region_dict={
230235
"12": "alpha",
231236
},
232-
custom_info={"ColNo": "12", "RowNo": "2", "WellNumber": "24"},
237+
custom_info={"ColNo": "12", "RowNo": "2"},
233238
),
234239
"C1": SampleMetadata(
235240
sample_type=SampleRoleType.control_sample_role,
@@ -241,7 +246,7 @@ def test_create_samples() -> None:
241246
"12": "alpha",
242247
"15": "bravo",
243248
},
244-
custom_info={"ColNo": "1", "RowNo": "3", "WellNumber": "25"},
249+
custom_info={"ColNo": "1", "RowNo": "3"},
245250
),
246251
"C2": SampleMetadata(
247252
sample_type=SampleRoleType.control_sample_role,
@@ -252,7 +257,7 @@ def test_create_samples() -> None:
252257
analyte_region_dict={
253258
"12": "alpha",
254259
},
255-
custom_info={"ColNo": "2", "RowNo": "3", "WellNumber": "26"},
260+
custom_info={"ColNo": "2", "RowNo": "3"},
256261
),
257262
"D2": SampleMetadata(
258263
sample_type=SampleRoleType.control_sample_role,
@@ -263,7 +268,7 @@ def test_create_samples() -> None:
263268
analyte_region_dict={
264269
"12": "alpha",
265270
},
266-
custom_info={"ColNo": "2", "RowNo": "4", "WellNumber": "38"},
271+
custom_info={"ColNo": "2", "RowNo": "4"},
267272
),
268273
}
269274

0 commit comments

Comments
 (0)