|
5 | 5 | import xml.etree.ElementTree as Et |
6 | 6 |
|
7 | 7 | from allotropy.allotrope.models.shared.components.plate_reader import SampleRoleType |
8 | | -from allotropy.allotrope.models.shared.definitions.definitions import ( |
9 | | - TStatisticDatumRole, |
10 | | -) |
11 | | -from allotropy.allotrope.schema_mappers.adm.multi_analyte_profiling.benchling._2024._01.multi_analyte_profiling import ( |
| 8 | +from allotropy.allotrope.schema_mappers.adm.multi_analyte_profiling.benchling._2024._09.multi_analyte_profiling import ( |
12 | 9 | Analyte, |
13 | 10 | Error, |
14 | 11 | Measurement, |
15 | 12 | MeasurementGroup, |
16 | 13 | Metadata, |
| 14 | + StatisticDimension, |
| 15 | + StatisticsDocument, |
17 | 16 | ) |
18 | 17 | from allotropy.exceptions import get_key_or_error |
19 | 18 | from allotropy.parsers.biorad_bioplex_manager import constants |
| 19 | +from allotropy.parsers.constants import NOT_APPLICABLE |
20 | 20 | from allotropy.parsers.utils.uuids import random_uuid_str |
21 | 21 | from allotropy.parsers.utils.values import ( |
22 | 22 | num_to_chars, |
@@ -153,15 +153,32 @@ def create_analyte( |
153 | 153 | ) -> Analyte: |
154 | 154 | # Look up analyte name from sample |
155 | 155 | assay_bead_identifier = bead_region_xml.attrib["RegionNumber"] |
| 156 | + |
| 157 | + # Create statistics dimensions from available statistics in the XML |
| 158 | + statistic_dimensions = [] |
| 159 | + for statistic_name, statistic_config in constants.STATISTIC_SECTIONS_CONF.items(): |
| 160 | + statistic_value = get_val_from_xml(bead_region_xml, statistic_name) |
| 161 | + statistic_dimensions.append( |
| 162 | + StatisticDimension( |
| 163 | + value=try_float(statistic_value, f"{statistic_name} statistic"), |
| 164 | + unit=statistic_config.unit, |
| 165 | + statistic_datum_role=statistic_config.role, |
| 166 | + ) |
| 167 | + ) |
| 168 | + |
156 | 169 | return Analyte( |
157 | 170 | identifier=random_uuid_str(), |
158 | 171 | name=analyte_region_dict[assay_bead_identifier], |
159 | | - value=try_float(get_val_from_xml(bead_region_xml, "Median"), "fluorescence"), |
160 | 172 | assay_bead_identifier=assay_bead_identifier, |
161 | 173 | assay_bead_count=try_int( |
162 | 174 | get_val_from_xml(bead_region_xml, "RegionCount"), "assay_bead_count" |
163 | 175 | ), |
164 | | - statistic_datum_role=TStatisticDatumRole.median_role, |
| 176 | + statistics=[ |
| 177 | + StatisticsDocument( |
| 178 | + statistical_feature="fluorescence", |
| 179 | + statistic_dimensions=statistic_dimensions, |
| 180 | + ) |
| 181 | + ], |
165 | 182 | ) |
166 | 183 |
|
167 | 184 |
|
@@ -213,15 +230,18 @@ def get_well_name(well_attrib: dict[str, str]) -> str: |
213 | 230 | def create_metadata( |
214 | 231 | root_xml: Et.Element, system_metadata: SystemMetadata, file_path: str |
215 | 232 | ) -> Metadata: |
| 233 | + path = Path(file_path) |
216 | 234 | return Metadata( |
217 | | - file_name=Path(file_path).name, |
| 235 | + file_name=path.name, |
218 | 236 | unc_path=file_path, |
219 | 237 | software_name=constants.SOFTWARE_NAME, |
220 | 238 | software_version=root_xml.attrib["BioPlexManagerVersion"], |
221 | 239 | equipment_serial_number=system_metadata.serial_number, |
222 | 240 | firmware_version=system_metadata.controller_version, |
223 | 241 | product_manufacturer=constants.PRODUCT_MANUFACTURER, |
224 | 242 | device_type=constants.DEVICE_TYPE, |
| 243 | + asm_file_identifier=path.with_suffix(".json").name, |
| 244 | + data_system_instance_identifier=NOT_APPLICABLE, |
225 | 245 | ) |
226 | 246 |
|
227 | 247 |
|
|
0 commit comments