Browse Source

bumped version

xmlparsing
Holger Frey 3 years ago
parent
commit
71ad6c7977
  1. 7
      sensospot_data/__init__.py
  2. 2
      sensospot_data/columns.py
  3. 6
      sensospot_data/dynamic_range.py
  4. 9
      sensospot_data/parser.py
  5. 2
      tests/test_dynamic_range.py
  6. 2
      tests/test_parser.py
  7. 1
      tests/test_utils.py

7
sensospot_data/__init__.py

@ -3,17 +3,14 @@
Parsing the numerical output from Sensovations Sensospot image analysis. Parsing the numerical output from Sensovations Sensospot image analysis.
""" """
__version__ = "0.5.2" __version__ = "0.5.3"
from pathlib import Path from pathlib import Path
import click import click
from .utils import ( # noqa: F401 from .utils import split, apply_exposure_map # noqa: F401
split,
apply_exposure_map,
)
from .parser import parse_file, parse_folder # noqa: F401 from .parser import parse_file, parse_folder # noqa: F401
from .parameters import ExposureInfo # noqa: F401 from .parameters import ExposureInfo # noqa: F401
from .dynamic_range import blend, create_xdr, normalize_values # noqa: F401 from .dynamic_range import blend, create_xdr, normalize_values # noqa: F401

2
sensospot_data/columns.py

@ -31,6 +31,7 @@ RAW_DATA_COLUMNS_RENAME_MAP = {
} }
# meta data extracted from filename # meta data extracted from filename
META_DATA_WELL_NAME = "Well.Name"
META_DATA_WELL_ROW = "Well.Row" META_DATA_WELL_ROW = "Well.Row"
META_DATA_WELL_COLUMN = "Well.Column" META_DATA_WELL_COLUMN = "Well.Column"
META_DATA_EXPOSURE_ID = "Exposure.Id" META_DATA_EXPOSURE_ID = "Exposure.Id"
@ -58,6 +59,7 @@ RAW_DATA_COLUMN_SET = {
RAW_DATA_POS_ID, RAW_DATA_POS_ID,
RAW_DATA_SPOT_FOUND, RAW_DATA_SPOT_FOUND,
RAW_DATA_SPOT_DIAMETER, RAW_DATA_SPOT_DIAMETER,
META_DATA_WELL_NAME,
META_DATA_WELL_ROW, META_DATA_WELL_ROW,
META_DATA_WELL_COLUMN, META_DATA_WELL_COLUMN,
META_DATA_EXPOSURE_ID, META_DATA_EXPOSURE_ID,

6
sensospot_data/dynamic_range.py

@ -3,9 +3,9 @@ from pandas.api.types import is_numeric_dtype
from .utils import split from .utils import split
from .columns import ( from .columns import (
RAW_DATA_POS_ID, RAW_DATA_POS_ID,
RAW_DATA_SPOT_SAT,
CALC_SPOT_OVERFLOW, CALC_SPOT_OVERFLOW,
META_DATA_WELL_ROW, META_DATA_WELL_ROW,
RAW_DATA_SPOT_SAT,
META_DATA_WELL_COLUMN, META_DATA_WELL_COLUMN,
SETTINGS_EXPOSURE_TIME, SETTINGS_EXPOSURE_TIME,
SETTINGS_EXPOSURE_CHANNEL, SETTINGS_EXPOSURE_CHANNEL,
@ -58,7 +58,9 @@ def _reduce_overflow(data_frame):
diff = rf_index - nf_index | nf_index - rf_index diff = rf_index - nf_index | nf_index - rf_index
if diff: if diff:
num = len(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] result_frame.loc[mask] = next_frame.loc[mask]
return result_frame.reset_index() return result_frame.reset_index()

9
sensospot_data/parser.py

@ -12,11 +12,12 @@ import pandas
from .columns import ( from .columns import (
RAW_DATA_POS_ID, RAW_DATA_POS_ID,
META_DATA_WELL_ROW, META_DATA_WELL_ROW,
META_DATA_WELL_NAME,
RAW_DATA_COLUMN_SET, RAW_DATA_COLUMN_SET,
META_DATA_EXPOSURE_ID, META_DATA_EXPOSURE_ID,
META_DATA_WELL_COLUMN, META_DATA_WELL_COLUMN,
RAW_DATA_COLUMNS_RENAME_MAP,
RAW_DATA_NORMALIZATION_MAP, RAW_DATA_NORMALIZATION_MAP,
RAW_DATA_COLUMNS_RENAME_MAP,
) )
from .parameters import add_optional_measurement_parameters from .parameters import add_optional_measurement_parameters
@ -76,6 +77,10 @@ def parse_file(data_file):
""" """
measurement_info = _extract_measurement_info(Path(data_file)) measurement_info = _extract_measurement_info(Path(data_file))
data_frame = _parse_csv(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_ROW] = measurement_info.row
data_frame[META_DATA_WELL_COLUMN] = measurement_info.column data_frame[META_DATA_WELL_COLUMN] = measurement_info.column
data_frame[META_DATA_EXPOSURE_ID] = measurement_info.exposure 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 # set the right data type for measurement columns
for raw_column in RAW_DATA_NORMALIZATION_MAP: 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 return data_frame

2
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(): 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 from sensospot_data.dynamic_range import _calc_overflow_info
data_frame = pandas.DataFrame(data={RAW_DATA_SPOT_SAT: [1, 2, 3]}) data_frame = pandas.DataFrame(data={RAW_DATA_SPOT_SAT: [1, 2, 3]})

2
tests/test_parser.py

@ -168,12 +168,14 @@ def test_parse_file(example_file):
"Pos.Nom.X", "Pos.Nom.X",
"Pos.Nom.Y", "Pos.Nom.Y",
"Spot.Diameter", "Spot.Diameter",
"Well.Name",
"Well.Row", "Well.Row",
"Well.Column", "Well.Column",
"Exposure.Id", "Exposure.Id",
} }
assert set(result.columns) == columns assert set(result.columns) == columns
assert result["Well.Name"][0] == "A01"
assert result["Well.Row"][0] == "A" assert result["Well.Row"][0] == "A"
assert result["Well.Column"][0] == 1 assert result["Well.Column"][0] == 1
assert result["Exposure.Id"][0] == 1 assert result["Exposure.Id"][0] == 1

1
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) apply_exposure_map(data_frame_without_params, None)
assert str(excinfo.value).startswith("Exposure Map: measurement") assert str(excinfo.value).startswith("Exposure Map: measurement")

Loading…
Cancel
Save