File size: 1,727 Bytes
0fff343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * Frontend mirror of the reference-set definitions served by the API.
 *
 * MUST stay in sync with:
 *   - api/app.py::REFERENCE_SETS_BY_DATASET
 *   - validate/h1.py::MMR_GENES, IMMUNE_GENES
 *   - api/app.py::HPV_P16_GENES, HPV_CELL_CYCLE_GENES
 *
 * When the toggle changes we re-derive overlap locally against these
 * lists (instant feedback, no extra /evaluate round-trip). If any list
 * grows on the server, update this constant too.
 */
export const REFERENCE_SETS_BY_DATASET = {
  coadread: {
    MMR: ["MLH1", "MSH2", "MSH6", "PMS2"],
    immune: ["CD8A", "GZMA", "PRF1"],
  },
  hnsc: {
    p16: ["CDKN2A"],
    cell_cycle: [
      "MCM2", "MCM3", "MCM4", "MCM5", "MCM6", "MCM7",
      "PCNA", "CDK1", "CCNE1", "CCNB1", "CDC6", "CDC20",
      "MKI67", "TOP2A", "RRM2", "TYMS", "FOXM1", "E2F1",
      "BUB1", "AURKB",
    ],
  },
} as const;

export type DatasetId = keyof typeof REFERENCE_SETS_BY_DATASET;
export type CoadreadRefKey = keyof typeof REFERENCE_SETS_BY_DATASET.coadread;
export type HnscRefKey = keyof typeof REFERENCE_SETS_BY_DATASET.hnsc;
export type ReferenceSetKey = CoadreadRefKey | HnscRefKey;

// Coadread-only flat alias used by older callers; kept so the legacy
// import surface still works.
export const REFERENCE_SETS = REFERENCE_SETS_BY_DATASET.coadread;

export function isInReferenceSet(
  symbol: string, dataset: DatasetId, key: ReferenceSetKey,
): boolean {
  const sets = REFERENCE_SETS_BY_DATASET[dataset] as Record<string, readonly string[]>;
  const list = sets[key];
  return Array.isArray(list) && list.includes(symbol);
}

export function refSetsFor(dataset: DatasetId): ReferenceSetKey[] {
  return Object.keys(REFERENCE_SETS_BY_DATASET[dataset]) as ReferenceSetKey[];
}