diff --git a/sensospot_data/__init__.py b/sensospot_data/__init__.py index 3b19349..52637d8 100644 --- a/sensospot_data/__init__.py +++ b/sensospot_data/__init__.py @@ -3,17 +3,14 @@ Parsing the numerical output from Sensovations Sensospot image analysis. """ -__version__ = "0.5.2" +__version__ = "0.5.3" from pathlib import Path import click -from .utils import ( # noqa: F401 - split, - apply_exposure_map, -) +from .utils import split, apply_exposure_map # noqa: F401 from .parser import parse_file, parse_folder # noqa: F401 from .parameters import ExposureInfo # noqa: F401 from .dynamic_range import blend, create_xdr, normalize_values # noqa: F401 diff --git a/sensospot_data/columns.py b/sensospot_data/columns.py index 412c65d..b41d608 100644 --- a/sensospot_data/columns.py +++ b/sensospot_data/columns.py @@ -31,6 +31,7 @@ RAW_DATA_COLUMNS_RENAME_MAP = { } # meta data extracted from filename +META_DATA_WELL_NAME = "Well.Name" META_DATA_WELL_ROW = "Well.Row" META_DATA_WELL_COLUMN = "Well.Column" META_DATA_EXPOSURE_ID = "Exposure.Id" @@ -58,6 +59,7 @@ RAW_DATA_COLUMN_SET = { RAW_DATA_POS_ID, RAW_DATA_SPOT_FOUND, RAW_DATA_SPOT_DIAMETER, + META_DATA_WELL_NAME, META_DATA_WELL_ROW, META_DATA_WELL_COLUMN, META_DATA_EXPOSURE_ID, diff --git a/sensospot_data/dynamic_range.py b/sensospot_data/dynamic_range.py index 653c545..0f1b1db 100644 --- a/sensospot_data/dynamic_range.py +++ b/sensospot_data/dynamic_range.py @@ -3,9 +3,9 @@ from pandas.api.types import is_numeric_dtype from .utils import split from .columns import ( RAW_DATA_POS_ID, + RAW_DATA_SPOT_SAT, CALC_SPOT_OVERFLOW, META_DATA_WELL_ROW, - RAW_DATA_SPOT_SAT, META_DATA_WELL_COLUMN, SETTINGS_EXPOSURE_TIME, SETTINGS_EXPOSURE_CHANNEL, @@ -58,7 +58,9 @@ def _reduce_overflow(data_frame): diff = rf_index - nf_index | nf_index - rf_index if diff: num = len(diff) - raise ValueError(f"XDR: Scan Data is incomplete, differs on {num} probes") + raise ValueError( + f"XDR: Scan Data is incomplete, differs on {num} probes" + ) result_frame.loc[mask] = next_frame.loc[mask] return result_frame.reset_index() diff --git a/sensospot_data/parser.py b/sensospot_data/parser.py index 3581b74..d7773d7 100755 --- a/sensospot_data/parser.py +++ b/sensospot_data/parser.py @@ -12,11 +12,12 @@ import pandas from .columns import ( RAW_DATA_POS_ID, META_DATA_WELL_ROW, + META_DATA_WELL_NAME, RAW_DATA_COLUMN_SET, META_DATA_EXPOSURE_ID, META_DATA_WELL_COLUMN, - RAW_DATA_COLUMNS_RENAME_MAP, RAW_DATA_NORMALIZATION_MAP, + RAW_DATA_COLUMNS_RENAME_MAP, ) from .parameters import add_optional_measurement_parameters @@ -76,6 +77,10 @@ def parse_file(data_file): """ measurement_info = _extract_measurement_info(Path(data_file)) data_frame = _parse_csv(data_file) + # normalized well name + data_frame[ + META_DATA_WELL_NAME + ] = f"{measurement_info.row}{measurement_info.column:02d}" data_frame[META_DATA_WELL_ROW] = measurement_info.row data_frame[META_DATA_WELL_COLUMN] = measurement_info.column data_frame[META_DATA_EXPOSURE_ID] = measurement_info.exposure @@ -129,7 +134,7 @@ def _sanity_check(data_frame): ) # set the right data type for measurement columns for raw_column in RAW_DATA_NORMALIZATION_MAP: - data_frame[raw_column] = pandas.to_numeric(data_frame[raw_column]) + data_frame[raw_column] = pandas.to_numeric(data_frame[raw_column]) return data_frame diff --git a/tests/test_dynamic_range.py b/tests/test_dynamic_range.py index c1dc7ca..34fe23b 100644 --- a/tests/test_dynamic_range.py +++ b/tests/test_dynamic_range.py @@ -79,7 +79,7 @@ def test_check_if_xdr_ready_raises_error_on_nan(exposure_df): def test_check_overflow_limit_defaults(): - from sensospot_data.columns import CALC_SPOT_OVERFLOW, RAW_DATA_SPOT_SAT + from sensospot_data.columns import RAW_DATA_SPOT_SAT, CALC_SPOT_OVERFLOW from sensospot_data.dynamic_range import _calc_overflow_info data_frame = pandas.DataFrame(data={RAW_DATA_SPOT_SAT: [1, 2, 3]}) diff --git a/tests/test_parser.py b/tests/test_parser.py index 3c97fe9..93fbced 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -168,12 +168,14 @@ def test_parse_file(example_file): "Pos.Nom.X", "Pos.Nom.Y", "Spot.Diameter", + "Well.Name", "Well.Row", "Well.Column", "Exposure.Id", } assert set(result.columns) == columns + assert result["Well.Name"][0] == "A01" assert result["Well.Row"][0] == "A" assert result["Well.Column"][0] == 1 assert result["Exposure.Id"][0] == 1 diff --git a/tests/test_utils.py b/tests/test_utils.py index e4e1a4f..bcd5399 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -177,4 +177,3 @@ def test_apply_exposure_map_from_parameters_raises_error( apply_exposure_map(data_frame_without_params, None) assert str(excinfo.value).startswith("Exposure Map: measurement") -