oncodsl / web /lib /referenceSets.ts
govindbalki's picture
Upload folder using huggingface_hub
0fff343 verified
Raw
History Blame Contribute Delete
1.73 kB
/**
* 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[];
}