Files
SimurgArray/tests/oracle/test_p2_raw_xy.py
T
kemal 17bd0e8f78 P2 validation: oracle test and large-scale raw X/Y check
- tests/oracle/test_p2_raw_xy.py: IDAT-assembled raw X/Y and controls
  equal the arrays in oracle GTCs
- validate_p1_large.py: phase-P2 comparison against vendor GTCs with
  diagnostics (channel swap, bead-count disagreements)
- cloud trial: also runs `simurg ingest` on all samples (time/memory),
  disk 250 GB
2026-09-27 20:57:42 +01:00

37 lines
1.3 KiB
Python

"""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 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
from tests.conftest import GSA_BPM, GSA_IDATS, ORACLE_GTCS, need
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