Skip to content

Commit

Permalink
Merge branch 'main' into jnegri-additional-parser-requirements
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Negri <[email protected]>
  • Loading branch information
LimulusPolyphemus authored Jun 21, 2024
2 parents 4bfd71b + 76167d6 commit 671be33
Show file tree
Hide file tree
Showing 11 changed files with 31,843 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added github enforcement that CHANGELOG.md is updated
- Added test files Agilent TapeStation Analysis
- Added requirements for remaining parsers to /docs
- Add Alphalisa assay support to Gen5 adapter
- Add fluorescence point detection measurement extension to Spectrophotometry BENCHLING/2023/12 schema

### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: spectrophotometry.schema.json
# timestamp: 2024-06-04T03:30:29+00:00
# timestamp: 2024-06-20T15:46:58+00:00

from __future__ import annotations

Expand All @@ -20,6 +20,7 @@
TQuantityValueNanogramPerMilliliter,
TQuantityValueNanometer,
TQuantityValuePicogramPerMilliliter,
TQuantityValueRelativeFluorescenceUnit,
TQuantityValueSecondTime,
TQuantityValueSquareCentimetersPerGram,
)
Expand Down Expand Up @@ -421,11 +422,47 @@ class UltravioletAbsorbancePointDetectionMeasurementDocumentItems:
compartment_temperature: TQuantityValueDegreeCelsius | None = None


@dataclass(kw_only=True)
class FluorescencePointDetectionDeviceControlDocumentItem(DeviceControlDocument):
detector_wavelength_setting: TQuantityValueNanometer | None = None
detector_bandwidth_setting: TQuantityValueNanometer | None = None
wavelength_filter_cutoff_setting: TQuantityValueNanometer | None = None
excitation_bandwidth_setting: TQuantityValueNanometer | None = None
excitation_wavelength_setting: TQuantityValueNanometer | None = None
field_index: int | None = None


FluorescencePointDetectionDeviceControlDocument = list[
FluorescencePointDetectionDeviceControlDocumentItem
]


@dataclass(kw_only=True)
class FluorescencePointDetectionDeviceControlAggregateDocument:
device_control_document: FluorescencePointDetectionDeviceControlDocument


@dataclass(kw_only=True)
class FluorescencePointDetectionMeasurementDocumentItems:
measurement_identifier: TStringValue
device_control_aggregate_document: FluorescencePointDetectionDeviceControlAggregateDocument
sample_document: SampleDocument
fluorescence: TQuantityValueRelativeFluorescenceUnit
measurement_time: TDateTimeStampValue | None = None
detection_type: TStringValue | None = None
processed_data_aggregate_document: ProcessedDataAggregateDocument | None = None
calculated_data_aggregate_document: CalculatedDataAggregateDocument | None = None
statistics_aggregate_document: StatisticsAggregateDocument | None = None
compartment_temperature: TQuantityValueDegreeCelsius | None = None
mass_concentration: TQuantityValuePicogramPerMilliliter | None = None


@dataclass(kw_only=True)
class MeasurementAggregateDocument:
measurement_time: TDateTimeStampValue
measurement_document: list[
UltravioletAbsorbancePointDetectionMeasurementDocumentItems
FluorescencePointDetectionMeasurementDocumentItems
| UltravioletAbsorbancePointDetectionMeasurementDocumentItems
]
experiment_type: TStringValue | None = None
container_type: ContainerType | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"properties": {
"spectrophotometry aggregate document": {
"type": "object",
"$asm.property-class": "TO DO",
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002937",
"$asm.pattern": "aggregate datum",
"properties": {
"device system document": {
Expand Down Expand Up @@ -316,9 +316,12 @@
"$asm.array-mixed": false,
"$asm.pattern": "indexed datum",
"items": {
"anyOf": [
"oneOf": [
{
"$ref": "#/$defs/ultravioletAbsorbancePointDetectionMeasurementDocumentItems"
},
{
"$ref": "#/$defs/fluorescencePointDetectionMeasurementDocumentItems"
}
]
},
Expand Down Expand Up @@ -1130,6 +1133,135 @@
}
}
},
"fluorescencePointDetectionDeviceControlDocument": {
"type": "array",
"$asm.array-ordered": true,
"$asm.array-mixed": false,
"$asm.pattern": "indexed datum",
"items": {
"allOf": [
{
"type": "object",
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002723",
"$asm.pattern": "aggregate datum",
"properties": {
"detector wavelength setting": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002456",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueNanometer"
},
"detector bandwidth setting": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002477",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueNanometer"
},
"wavelength filter cutoff setting": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002478",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueNanometer"
},
"excitation bandwidth setting": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002548",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueNanometer"
},
"excitation wavelength setting": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002479",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueNanometer"
}
}
},
{
"$ref": "#/$defs/deviceControlDocument"
},
{
"properties": {
"@index": {
"type": "integer",
"minimum": 1,
"maximum": 2147483647
}
}
}
]
},
"minItems": 1
},
"fluorescencePointDetectionDeviceControlAggregateDocument": {
"type": "object",
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002722",
"$asm.pattern": "aggregate datum",
"required": [
"device control document"
],
"properties": {
"device control document": {
"$ref": "#/$defs/fluorescencePointDetectionDeviceControlDocument"
}
}
},
"fluorescencePointDetectionMeasurementDocumentItems": {
"type": "object",
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002375",
"$asm.pattern": "aggregate datum",
"required": [
"fluorescence",
"sample document",
"device control aggregate document",
"measurement identifier"
],
"properties": {
"measurement time": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0000952",
"$asm.pattern": "value datum",
"$asm.type": "http://www.w3.org/2001/XMLSchema#dateTimeStamp",
"$ref": "#/$defs/tDateTimeStampValue"
},
"measurement identifier": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0001121",
"$asm.pattern": "value datum",
"$asm.type": "http://www.w3.org/2001/XMLSchema#string",
"$ref": "#/$defs/tStringValue"
},
"device control aggregate document": {
"$ref": "#/$defs/fluorescencePointDetectionDeviceControlAggregateDocument"
},
"sample document": {
"$ref": "#/$defs/sampleDocument"
},
"detection type": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002534",
"$asm.pattern": "value datum",
"$asm.type": "http://www.w3.org/2001/XMLSchema#string",
"$ref": "#/$defs/tStringValue"
},
"processed data aggregate document": {
"$ref": "#/$defs/processedDataAggregateDocument"
},
"calculated data aggregate document": {
"$ref": "#/$defs/calculatedDataAggregateDocument"
},
"statistics aggregate document": {
"$ref": "#/$defs/statisticsAggregateDocument"
},
"compartment temperature": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002549",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueDegreeCelsius"
},
"fluorescence": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0002408",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValueRelativeFluorescenceUnit"
},
"mass concentration": {
"$asm.property-class": "http://purl.allotrope.org/ontologies/result#AFR_0001661",
"$asm.pattern": "quantity datum",
"$ref": "#/$custom/tQuantityValuePicogramPerMilliliter"
}
}
},
"asm": {
"properties": {
"$asm.manifest": {
Expand Down
15 changes: 10 additions & 5 deletions src/allotropy/parsers/agilent_gen5/agilent_gen5_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def _get_identifier_from_filename_or_none(cls, file_name: str) -> str | None:

@dataclass(frozen=True)
class FilterSet:
emission: str
gain: str
emission: str | None = None
excitation: str | None = None
mirror: str | None = None
optics: str | None = None

@property
def detector_wavelength_setting(self) -> float | None:
if self.emission == "Full light":
if self.emission == "Full light" or not self.emission:
return None
return try_float(self.emission.split("/")[0], "Detector wavelength")

Expand Down Expand Up @@ -218,7 +218,10 @@ def create(cls, reader: LinesReader) -> ReadData:
def get_read_mode(procedure_details: str) -> ReadMode:
if ReadMode.ABSORBANCE.value in procedure_details:
return ReadMode.ABSORBANCE
elif ReadMode.FLUORESCENCE.value in procedure_details:
elif (
ReadMode.FLUORESCENCE.value in procedure_details
or ReadMode.ALPHALISA.value in procedure_details
):
return ReadMode.FLUORESCENCE
elif ReadMode.LUMINESCENCE.value in procedure_details:
return ReadMode.LUMINESCENCE
Expand Down Expand Up @@ -259,6 +262,8 @@ def _get_measurement_labels(cls, device_control_data: dict, read_mode: str) -> l
f"{label_prefix}{excitation},{emission}"
for excitation, emission in zip(excitations, emissions)
]
if not measurement_labels:
measurement_labels = ["Alpha"]

if read_mode == ReadMode.LUMINESCENCE:
emissions = device_control_data.get(EMISSION_KEY)
Expand Down Expand Up @@ -362,9 +367,8 @@ def _get_filter_sets(
mirror = None
if mirrors and read_mode == ReadMode.FLUORESCENCE:
mirror = mirrors[idx]

filter_data[label] = FilterSet(
emission=emissions[idx],
emission=emissions[idx] if emissions else None,
gain=gains[idx],
excitation=excitations[idx] if excitations else None,
mirror=mirror,
Expand Down Expand Up @@ -484,6 +488,7 @@ def parse_results(
if well_pos not in self.wells:
self.wells.append(well_pos)
well_value = try_float_or_nan(values[col_num])

if label in read_data.measurement_labels:
self.measurements[well_pos].append(
Measurement(random_uuid_str(), well_value, label)
Expand Down
1 change: 1 addition & 0 deletions src/allotropy/parsers/agilent_gen5/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ReadMode(str, Enum):
ABSORBANCE = "Absorbance"
FLUORESCENCE = "Fluorescence"
LUMINESCENCE = "Luminescence"
ALPHALISA = "Alpha"


class ReadType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DataSourceDocumentItem,
DataSystemDocument,
DeviceSystemDocument,
FluorescencePointDetectionMeasurementDocumentItems,
MeasurementAggregateDocument,
Model,
ProcessedDataAggregateDocument,
Expand Down Expand Up @@ -242,7 +243,14 @@ def _get_spectrophotometry_document_item(

def _get_measurement_document(
self, data: pd.DataFrame, row: int
) -> list[UltravioletAbsorbancePointDetectionMeasurementDocumentItems]:
) -> list[
FluorescencePointDetectionMeasurementDocumentItems
| UltravioletAbsorbancePointDetectionMeasurementDocumentItems
]:
measurement_docs: list[
FluorescencePointDetectionMeasurementDocumentItems
| UltravioletAbsorbancePointDetectionMeasurementDocumentItems
]
measurement_docs = []
na_type = _get_str_or_none(data, row, "na type")
concentration_col = self._get_concentration_col(data)
Expand Down
Loading

0 comments on commit 671be33

Please sign in to comment.