import pytest @pytest.fixture() def example_data(): import pandas as pd data = [ ("A", "a", 1, 1, 100, 5), ("A", "a", 1, 2, 100, 2), ("A", "a", 1, 3, 100, 0), ("A", "b", 1, 1, 200, 0), ("A", "b", 1, 2, 200, 3), ("A", "b", 1, 3, 200, 0), ("B", "a", 1, 1, 300, 0), ("B", "a", 1, 2, 300, 2), ("B", "a", 1, 3, 300, 0), ] columns = [ "Analysis.Name", "Well.Name", "Pos.Id", "Exposure.Id", "Spot.Mean", "Spot.Saturation", ] return pd.DataFrame(data, columns=columns) @pytest.mark.parametrize( ("analysis", "expected_cy3"), [("dry1", 100), ("hyb", 200)] ) def test_add_exposure_info(example_data, analysis, expected_cy3): from conda_helpers.mbp import add_exposure_info result = add_exposure_info(example_data, analysis=analysis) assert "Exposure.Channel" in result.columns assert "Exposure.Time" in result.columns assert "Exposure.Time.Normalized" in result.columns for i, channel, time in [ (1, "Cy3", expected_cy3), (2, "Cy5", 150), (3, "Cy5", 15), ]: selection = result["Exposure.Id"] == i selected = result[selection].copy() assert list(selected["Exposure.Channel"].unique()) == [channel] assert list(selected["Exposure.Time"].unique()) == [time] def test_test_overflow(example_data): from conda_helpers.mbp import TEST_OVERFLOW, test_overflow result = test_overflow(example_data) assert list(result[TEST_OVERFLOW]) == [ True, False, False, False, True, False, False, False, False, ] def test_normalize(example_data): from conda_helpers.mbp import normalize result = normalize(example_data) assert "Spot.Mean.Normalized" in result.columns assert list(result["Spot.Mean.Normalized"]) == [ 100, 200, 300, 100 * 25 / 150, 300 * 25 / 150, 200 * 25 / 15, ]