"""What may leave the Space: identifiers only (ADR-0001 ยง6). Refusals are data.""" from __future__ import annotations import pytest from src.identifiers import MAX_IDENTIFIERS, parse_disease, parse_gene_list, parse_nct # Real HGNC symbols chosen to exercise the edges of the pattern and of the sample-id prefixes. VALID_SYMBOLS = [ "KRAS", "TP53", "ELAVL1", "C1orf112", "HLA-DRB1", "NKX2-1", "IGHV1-69-2", "CPT1A", "ERRFI1", "DOK1", "SAA1", "SORD2P", ] @pytest.mark.parametrize("symbol", VALID_SYMBOLS) def test_real_symbols_pass(symbol): parsed = parse_gene_list(symbol) assert parsed.ok, parsed.message assert parsed.identifiers[0].kind == "symbol" def test_a_list_splits_on_commas_spaces_and_semicolons_and_keeps_order(): parsed = parse_gene_list("JAK1, JAK2;STAT1 jak1") assert parsed.ok assert [i.value for i in parsed.identifiers] == ["JAK1", "JAK2", "STAT1"] assert parsed.duplicates_dropped == 1 def test_ensembl_ids_are_genes_and_uniprot_only_when_allowed(): assert parse_gene_list("ENSG00000133703").identifiers[0].kind == "ensembl" assert parse_gene_list("P05161", allow_uniprot=True).identifiers[0].kind == "uniprot" assert parse_gene_list("P05161").identifiers[0].kind == "symbol" @pytest.mark.parametrize( "raw", [ "what drugs target KRAS?", "TCGA-2J-AAB1-01A", "GSM1234567", "C3L-00017", "12.5", "KRAS 3.2 1.1", "