Skip to content

Commit c2a800d

Browse files
change level of custom info fields, skip fields already mapped
1 parent 5ab69df commit c2a800d

3 files changed

Lines changed: 57 additions & 24 deletions

File tree

src/allotropy/parsers/cytiva_biacore_t200_evaluation/cytiva_biacore_t200_evaluation_data_creator.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
from allotropy.parsers.utils.pandas import map_rows, SeriesData
4848
from allotropy.parsers.utils.uuids import random_uuid_str
4949
from allotropy.parsers.utils.values import quantity_or_none, try_float_or_none
50-
from allotropy.types import DictType
5150

5251

5352
def _get_sensorgram_datacube(
@@ -109,7 +108,6 @@ def create_metadata(data: Data, named_file_contents: NamedFileContents) -> Metad
109108
"account identifier": sys.user_name,
110109
"operating system type": sys.os_type,
111110
"operating system version": sys.os_version,
112-
**sys.unread_system_data,
113111
**sys.unread_application_properties,
114112
},
115113
)
@@ -471,8 +469,8 @@ def create_measurement_groups(data: Data) -> list[MeasurementGroup]:
471469
os_type=sys.os_type,
472470
os_version=sys.os_version,
473471
measurement_time=data.run_metadata.timestamp,
474-
unread_system_data=sys.unread_system_data,
475472
unread_application_properties=sys.unread_application_properties,
473+
measurement_aggregate_fields=sys.measurement_aggregate_fields,
476474
)
477475
# As a final fallback, look directly in application_template_details.properties
478476
if not sys.measurement_time and data.application_template_details:
@@ -487,8 +485,8 @@ def create_measurement_groups(data: Data) -> list[MeasurementGroup]:
487485
os_type=sys.os_type,
488486
os_version=sys.os_version,
489487
measurement_time=ts,
490-
unread_system_data=sys.unread_system_data,
491488
unread_application_properties=sys.unread_application_properties,
489+
measurement_aggregate_fields=sys.measurement_aggregate_fields,
492490
)
493491
if not sys.measurement_time:
494492
msg = "Missing measurement time. Expected application_template_details.properties.Timestamp."
@@ -497,10 +495,11 @@ def create_measurement_groups(data: Data) -> list[MeasurementGroup]:
497495
# Process all cycles to create one measurement document per cycle
498496
for cycle in data.cycle_data:
499497
measurements = _create_measurements_for_cycle(data, cycle)
500-
custom_info: DictType = {
498+
custom_info: dict[str, Any] = {
501499
"data collection rate": quantity_or_none(
502500
TQuantityValueHertz, data.run_metadata.data_collection_rate
503501
),
502+
**sys.measurement_aggregate_fields,
504503
}
505504
# Add aggregate-level experimental data identifier for convenience (first measurement's FC)
506505
if measurements:

src/allotropy/parsers/cytiva_biacore_t200_evaluation/cytiva_biacore_t200_evaluation_structure.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,16 @@ def create(chip_data: DictType) -> ChipData:
172172

173173
@dataclass(frozen=True)
174174
class DetectionConfig:
175+
unread_detection_data: dict[str, Any]
175176
detection: str | None = None
176177
detection_dual: str | None = None
177178
detection_multi: str | None = None
178179
flow_cell_single: str | None = None
179180
flow_cell_dual: str | None = None
180181
flow_cell_multi: str | None = None
181-
unread_detection_data: dict[str, Any] = field(default_factory=dict)
182182

183183
@staticmethod
184-
def create(detection: DictType | None) -> DetectionConfig:
185-
if detection is None:
186-
return DetectionConfig()
187-
184+
def create(detection: DictType) -> DetectionConfig:
188185
json_data = JsonData(dict(detection))
189186

190187
return DetectionConfig(
@@ -240,7 +237,7 @@ def create(application_template_details: DictType | None) -> RunMetadata:
240237
application_template_details.get("MoleculeWeightUnit", {})
241238
),
242239
detection_config=DetectionConfig.create(
243-
application_template_details.get("detection")
240+
application_template_details.get("detection", {})
244241
),
245242
buffer_volume=try_float_or_none(
246243
(application_template_details.get("prepare_run", {}) or {}).get(
@@ -283,8 +280,8 @@ class SystemInformation:
283280
os_type: str | None
284281
os_version: str | None
285282
measurement_time: str | None
286-
unread_system_data: dict[str, Any] = field(default_factory=dict)
287-
unread_application_properties: dict[str, Any] = field(default_factory=dict)
283+
unread_application_properties: dict[str, Any]
284+
measurement_aggregate_fields: dict[str, Any]
288285

289286
@staticmethod
290287
def create(
@@ -298,6 +295,35 @@ def create(
298295
str, "Timestamp"
299296
)
300297

298+
# Extract specific fields for measurement aggregate custom info before skipping them
299+
measurement_aggregate_fields = {}
300+
target_fields = [
301+
"TemplateExtension",
302+
"EvaluationMethodIsOptional",
303+
"TypeName",
304+
"AllowPublish",
305+
]
306+
307+
for _field in target_fields:
308+
# Check both sources, preferring application properties
309+
value = app_props_data.get(str, _field) or system_info_data.get(str, _field)
310+
if value is not None:
311+
measurement_aggregate_fields[_field] = value
312+
313+
# Read other fields that we want to skip to avoid JsonData warnings
314+
system_info_data.get(str, "SoftwareVersion")
315+
system_info_data.get(str, "Software")
316+
system_info_data.get(str, "User")
317+
system_info_data.get(
318+
str, "Timestamp"
319+
) # Already read above but ensure both sources are marked
320+
app_props_data.get(str, "SoftwareVersion")
321+
app_props_data.get(str, "Software")
322+
app_props_data.get(str, "User")
323+
app_props_data.get(
324+
str, "Timestamp"
325+
) # Already read above but ensure both sources are marked
326+
301327
return SystemInformation(
302328
application_name=system_info_data.get(str, "Application"),
303329
application_version=system_info_data.get(str, "Version"),
@@ -308,10 +334,10 @@ def create(
308334
os_type=system_info_data.get(str, "OSType"),
309335
os_version=system_info_data.get(str, "OSVersion"),
310336
measurement_time=measurement_time,
311-
unread_system_data=system_info_data.get_unread(skip={"HtmlPreview"}),
312337
unread_application_properties=app_props_data.get_unread(
313-
skip={"HtmlPreview"}
338+
skip={"HtmlPreview", "Timestamp"}
314339
),
340+
measurement_aggregate_fields=measurement_aggregate_fields,
315341
)
316342

317343

tests/parsers/cytiva_biacore_t200_evaluation/testdata/biacore_evaluation_module_example.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,10 @@
741741
"value": 10.0,
742742
"unit": "Hz"
743743
},
744+
"TemplateExtension": "Method",
745+
"EvaluationMethodIsOptional": "false",
746+
"TypeName": "Method Builder",
747+
"AllowPublish": "true",
744748
"experimental data identifier": "MASKED_EXPERIMENTAL_DATA_ID"
745749
}
746750
},
@@ -1485,6 +1489,10 @@
14851489
"value": 10.0,
14861490
"unit": "Hz"
14871491
},
1492+
"TemplateExtension": "Method",
1493+
"EvaluationMethodIsOptional": "false",
1494+
"TypeName": "Method Builder",
1495+
"AllowPublish": "true",
14881496
"experimental data identifier": "MASKED_EXPERIMENTAL_DATA_ID"
14891497
}
14901498
},
@@ -2229,6 +2237,10 @@
22292237
"value": 10.0,
22302238
"unit": "Hz"
22312239
},
2240+
"TemplateExtension": "Method",
2241+
"EvaluationMethodIsOptional": "false",
2242+
"TypeName": "Method Builder",
2243+
"AllowPublish": "true",
22322244
"experimental data identifier": "MASKED_EXPERIMENTAL_DATA_ID"
22332245
}
22342246
},
@@ -2973,6 +2985,10 @@
29732985
"value": 10.0,
29742986
"unit": "Hz"
29752987
},
2988+
"TemplateExtension": "Method",
2989+
"EvaluationMethodIsOptional": "false",
2990+
"TypeName": "Method Builder",
2991+
"AllowPublish": "true",
29762992
"experimental data identifier": "MASKED_EXPERIMENTAL_DATA_ID"
29772993
}
29782994
},
@@ -2991,15 +3007,7 @@
29913007
"custom information document": {
29923008
"account identifier": "BiacoreT200",
29933009
"operating system type": "Win32NT",
2994-
"operating system version": "6.2.9200.0",
2995-
"Timestamp": "06/11/2025 12:38:26",
2996-
"TemplateExtension": "Method",
2997-
"SoftwareVersion": "3.2.1",
2998-
"Software": "Biacore T200 Control Software",
2999-
"EvaluationMethodIsOptional": "false",
3000-
"TypeName": "Method Builder",
3001-
"User": "BiacoreT200",
3002-
"AllowPublish": "true"
3010+
"operating system version": "6.2.9200.0"
30033011
}
30043012
},
30053013
"device system document": {

0 commit comments

Comments
 (0)