"""Phase P2 acceptance on P0 data: raw X/Y and control intensities assembled from IDATs equal the arrays stored in oracle GTCs (TOC 1000/1001, 500/501). The same check on vendor GTCs runs in scripts/validate_p1_large.py --p2. """ from __future__ import annotations import numpy as np import pytest from tests.conftest import GSA_BPM, GSA_IDATS, ORACLE_GTCS, need from simurg.formats.bpm import read_bpm from simurg.formats.gtc import read_gtc from simurg.formats.idat import read_idat from simurg.signal.raw_xy import LocusMapCache, assemble_raw_xy, check_coverage pytestmark = pytest.mark.data def test_raw_xy_equals_oracle_gtcs() -> None: need(GSA_BPM, GSA_IDATS, ORACLE_GTCS) m = read_bpm(GSA_BPM) cache = LocusMapCache(m) gtcs = sorted(ORACLE_GTCS.glob("*.gtc")) assert gtcs for g in gtcs: sid = g.stem chip = sid.split("_")[0] grn = read_idat(GSA_IDATS / chip / f"{sid}_Grn.idat") red = read_idat(GSA_IDATS / chip / f"{sid}_Red.idat") assert check_coverage(grn, m)[0] == 1.0 raw = assemble_raw_xy(grn, red, m, cache=cache) ref = read_gtc(g) assert np.array_equal(raw.raw_x, ref.raw_x), sid assert np.array_equal(raw.raw_y, ref.raw_y), sid assert np.array_equal(raw.controls_x, ref.controls_x), sid assert np.array_equal(raw.controls_y, ref.controls_y), sid