Skip to content

Commit d3b12e1

Browse files
add calculated data descriptions, rename adapter files
1 parent 75a9499 commit d3b12e1

7 files changed

Lines changed: 66 additions & 74 deletions

File tree

src/allotropy/calcdocs/config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class CalculatedDataConfig:
3030
source_configs: tuple[CalculatedDataConfig | MeasurementConfig, ...]
3131
unit: str | None = None
3232
description: str | None = None
33+
# Optional key to pull a dynamic description from the element data
34+
description_value_key: str | None = None
3335
required: bool = False
3436

3537
def iter_data_sources(
@@ -71,13 +73,23 @@ def _get_calc_doc_inner(
7173
if not data_sources:
7274
return None
7375

76+
if self.name == "B22 goodness of fit":
77+
pass
7478
return CalculatedDocument(
7579
uuid=random_uuid_str(),
7680
name=self.name,
7781
value=value,
7882
data_sources=data_sources,
7983
unit=self.unit,
80-
description=self.description,
84+
description=(
85+
self.description
86+
if self.description is not None
87+
else (
88+
elements[0].get_str_or_none(self.description_value_key)
89+
if self.description_value_key
90+
else None
91+
)
92+
),
8193
)
8294

8395
def get_cache_key(self, keys: Keys) -> str:

src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_calcdocs.py renamed to src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_stunner_calcdocs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,15 @@ def create_calculated_data(
224224
unit=UNITLESS,
225225
view_data=detection_type_view,
226226
source_configs=(dynamic_light_scattering_conf,),
227+
description_value_key="kd linear fit",
227228
),
228229
CalculatedDataConfig(
229230
name="B22 goodness of fit",
230231
value="b22 goodness of fit",
231232
unit=UNITLESS,
232233
view_data=detection_type_view,
233234
source_configs=(dynamic_light_scattering_conf,),
235+
description_value_key="b22 linear fit",
234236
),
235237
CalculatedDataConfig(
236238
name="Viscosity at T (cP)",

src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_stunner_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
)
1010
from allotropy.named_file_contents import NamedFileContents
1111
from allotropy.parsers.release_state import ReleaseState
12-
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_reader import (
12+
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_stunner_reader import (
1313
UnchainedLabsLunaticReader,
1414
)
15-
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_structure import (
15+
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_stunner_structure import (
1616
create_measurement_groups,
1717
create_metadata,
1818
)

src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_reader.py renamed to src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_stunner_reader.py

File renamed without changes.

src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_structure.py renamed to src/allotropy/parsers/unchained_labs_lunatic_stunner/unchained_labs_lunatic_stunner_structure.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
SOFTWARE_NAME,
3232
WAVELENGTH_COLUMNS_RE,
3333
)
34-
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_calcdocs import (
34+
from allotropy.parsers.unchained_labs_lunatic_stunner.unchained_labs_lunatic_stunner_calcdocs import (
3535
create_calculated_data,
3636
)
3737
from allotropy.parsers.utils.calculated_data_documents.definition import (
@@ -175,6 +175,25 @@ def _create_measurement(
175175
),
176176
"Acquisition filtering": well_plate_data.get(str, "acquisition filtering"),
177177
},
178+
error_document=error_documents,
179+
processed_data_document=ProcessedDataDocument(
180+
identifier=random_uuid_str(),
181+
concentration_factor=concentration_factor,
182+
peak_list_custom_info=peak_data,
183+
)
184+
if concentration_factor is not None or peak_data
185+
else None,
186+
wavelength_identifier=wavelength_column,
187+
calc_docs_custom_info={
188+
**{
189+
item["column"]: well_plate_data.get(float, item["column"])
190+
for item in CALCULATED_DATA_LOOKUP.get(wavelength_column, [])
191+
},
192+
**{
193+
"b22 linear fit": well_plate_data.get(str, "b22 linear fit"),
194+
"kd linear fit": well_plate_data.get(str, "kd linear fit"),
195+
},
196+
},
178197
measurement_custom_info={
179198
"electronic_absorbance_reference_absorbance": background_absorbance,
180199
**well_plate_data.get_unread(
@@ -201,19 +220,6 @@ def _create_measurement(
201220
},
202221
),
203222
},
204-
error_document=error_documents,
205-
processed_data_document=ProcessedDataDocument(
206-
identifier=random_uuid_str(),
207-
concentration_factor=concentration_factor,
208-
peak_list_custom_info=peak_data,
209-
)
210-
if concentration_factor is not None or peak_data
211-
else None,
212-
wavelength_identifier=wavelength_column,
213-
calc_docs_custom_info={
214-
item["column"]: well_plate_data.get(float, item["column"])
215-
for item in CALCULATED_DATA_LOOKUP.get(wavelength_column, [])
216-
},
217223
)
218224

219225

0 commit comments

Comments
 (0)