Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class Measurement:
@dataclass(frozen=True)
class MeasurementGroup:
measurements: list[Measurement]
analyst: str | None = None
submitter: str | None = None
fractions: list[Fraction] | None = None
logs: list[Log] | None = None
measurement_aggregate_custom_info: dict[str, Any] | None = None
Expand Down Expand Up @@ -317,7 +319,8 @@ def _get_technique_document(
self, group: MeasurementGroup, metadata: Metadata
) -> LiquidChromatographyDocumentItem:
return LiquidChromatographyDocumentItem(
analyst=metadata.analyst,
analyst=group.analyst or metadata.analyst,
submitter=group.submitter,
measurement_aggregate_document=add_custom_information_document(
MeasurementAggregateDocument(
measurement_document=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class BenchlingChromeleonReader:
def __init__(self, named_file_contents: NamedFileContents) -> None:
contents: dict[str, Any] = json.load(named_file_contents.contents)
self.sequence: dict[str, Any] = contents.get("sequence", {})
self.device_information: dict[str, Any] = contents.get("device information", {})
self.device_information: dict[str, Any] = (
contents.get("device information") or {}
)
self.injections: list[dict[str, Any]] = assert_not_none(
contents.get("injections"), "injections"
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@


def _create_device_documents(
device_information: dict[str, Any]
device_information: dict[str, Any] | None,
) -> list[DeviceDocument] | None:
if not device_information:
return None
return [
DeviceDocument(
device_type="pump",
Expand All @@ -51,12 +53,15 @@ def create_metadata(
first_injection: dict[str, Any],
sequence: dict[str, Any],
file_path: str,
device_information: dict[str, Any],
device_information: dict[str, Any] | None,
) -> Metadata:
asset_management_identifier = (
(device_information.get("sampler model number") if device_information else None)
or first_injection.get("precondition system instrument name")
or NOT_APPLICABLE
)
return Metadata(
asset_management_identifier=first_injection.get(
"precondition system instrument name", NOT_APPLICABLE
),
asset_management_identifier=asset_management_identifier,
software_name=constants.SOFTWARE_NAME,
file_name=Path(file_path).name,
unc_path=file_path,
Expand Down Expand Up @@ -223,6 +228,7 @@ def _create_measurements(injection: dict[str, Any]) -> list[Measurement] | None:
measurement_identifier=random_uuid_str(),
description=injection.get("description"),
sample_identifier=injection["sample identifier"],
written_name=injection.get("injection name"),
location_identifier=injection.get("location identifier"),
well_location_identifier=injection.get("custom variables", {}).get("Well"),
observation=injection.get("custom variables", {}).get("Observation"),
Expand All @@ -239,7 +245,7 @@ def _create_measurements(injection: dict[str, Any]) -> list[Measurement] | None:
},
device_control_docs=[
DeviceControlDoc(
device_type=constants.DEVICE_TYPE,
device_type=signal.get("signal name", constants.DEVICE_TYPE),
detection_type=signal.get("detection type"),
detector_offset_setting=val
if (val := signal.get("detector offset setting")) != "unknown"
Expand Down Expand Up @@ -271,6 +277,11 @@ def _create_measurements(injection: dict[str, Any]) -> list[Measurement] | None:
"creation user name": injection.get("creation user name"),
"injection program": injection.get("injection program"),
"injection method": injection.get("injection method"),
**{
k: v
for k, v in injection.get("custom variables", {}).items()
if v is not None
},
},
chromatography_serial_num=NOT_APPLICABLE,
chromatogram_data_cube=_get_chromatogram(signal) if signal else None,
Expand All @@ -284,7 +295,11 @@ def create_measurement_groups(
injections: list[dict[str, Any]]
) -> list[MeasurementGroup]:
return [
MeasurementGroup(measurements=measurements)
for sample_injections in injections
if (measurements := _create_measurements(sample_injections)) is not None
MeasurementGroup(
measurements=measurements,
analyst=injection.get("last update user name"),
submitter=injection.get("creation user name"),
)
for injection in injections
if (measurements := _create_measurements(injection)) is not None
]
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_create_metadata(mock_data: dict[str, Any]) -> None:
)

assert isinstance(metadata, Metadata)
assert metadata.asset_management_identifier == "Instrument123"
assert metadata.asset_management_identifier == "WPS-3000RS"
assert metadata.software_name == constants.SOFTWARE_NAME
assert metadata.file_name == "test_file.json"
assert metadata.unc_path == "/data/test_file.json"
Expand Down Expand Up @@ -173,7 +173,7 @@ def test_create_measurement_groups(mock_data: dict[str, Any]) -> None:

device_control_doc = measurement.device_control_docs[0]
assert device_control_doc is not None
assert device_control_doc.device_type == constants.DEVICE_TYPE
assert device_control_doc.device_type == "UV_VIS_1"
assert device_control_doc.detection_type == "single channel"
assert device_control_doc.electronic_absorbance_reference_bandwidth_setting == 1.0
assert device_control_doc.electronic_absorbance_reference_wavelength_setting == 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"device information": {
"pump model number": "VF-P10-A",
"uv model number": "VF-D40-A",
"sampler model number": "VF-A10-A"
},
"sequence": {
"sequence creation time": "2026-02-13T10:00:00+01:00",
"sequence directory": "ChromeleonLocal",
"sequence name": "Test_MultiSignal",
"sequence update operator": "operator1",
"sequence update time": "2026-02-14T15:00:00+01:00",
"custom formulas": []
},
"injections": [
{
"injection number": 1,
"injection name": "MQW",
"injection identifier": "99999999-8888-7777-6666-555555555555",
"injection time": "2026-02-14T21:52:50+01:00",
"injection position": "B:A1",
"injection status": "Finished",
"injection type": "Unknown",
"description": "",
"sample identifier": "",
"location identifier": "B:A1",
"last update user name": "Instrument Controller",
"creation user name": "PD01",
"detection type": "single channel",
"injection volume setting": 4.0,
"injection volume setting unit": "uL",
"custom variables": {
"ColumnValvePosition": 1.0
},
"signals": [
{
"signal name": "UV_VIS_1",
"detection type": "single channel",
"detector sampling rate setting": "unknown",
"detector offset setting": "unknown",
"bandwidth setting": 4.0,
"wavelength setting": 220.0,
"reference bandwidth setting": null,
"reference wavelength setting": null,
"chromatogram": {
"x": [
0.0,
0.5,
1.0,
1.5,
2.0
],
"y": [
0.0,
0.5,
1.0,
0.5,
0.0
]
},
"peaks": []
},
{
"signal name": "UV_VIS_2",
"detection type": "single channel",
"detector sampling rate setting": "unknown",
"detector offset setting": "unknown",
"bandwidth setting": 4.0,
"wavelength setting": 280.0,
"reference bandwidth setting": null,
"reference wavelength setting": null,
"chromatogram": {
"x": [
0.0,
0.5,
1.0,
1.5,
2.0
],
"y": [
0.0,
0.3,
0.8,
0.3,
0.0
]
},
"peaks": [
{
"identifier": "1",
"name": "Peak1",
"start time": 0.4,
"end time": 1.6,
"retention time": 1.0,
"area": 8000.0,
"height": 800.0,
"relative peak area": 100.0,
"relative peak height": 100.0,
"peak width at half height": 0.6,
"peak width at 5 % of height": null,
"peak width at 10 % of height": null,
"peak width at baseline": null,
"amount": null,
"relative retention time": null,
"capacity factor": null,
"chromatographic peak resolution": null,
"number of theoretical plates by peak width at half height": null,
"asymmetry factor measured at 5 % height": null,
"start value baseline": null,
"stop value baseline": null,
"peak right width at 10 % of height": null,
"peak left width at 10 % of height": null,
"group area": null,
"rel ce area total": null,
"chromatographic peak resolution (USP)": null,
"asymmetry aia": null
}
]
}
]
}
]
}
Loading
Loading