/** * Precision Medicine and Genomic Interpretation Module * * ╔═══════════════════════════════════════════════════════════════════════════════╗ * ║ PRECISION ONCOLOGY - BIOMARKER-DRIVEN TREATMENT SELECTION ║ * ╠═══════════════════════════════════════════════════════════════════════════════╣ * ║ This module provides: ║ * ║ - Comprehensive genomic interpretation ║ * ║ - Actionable mutation databases ║ * ║ - Pharmacogenomics for toxicity prediction ║ * ║ - Tumor microenvironment analysis ║ * ║ - ctDNA/liquid biopsy interpretation ║ * ║ - Variant actionability scoring ║ * ╚═══════════════════════════════════════════════════════════════════════════════╝ */ // ═══════════════════════════════════════════════════════════════════════════════ // GENOMIC ALTERATION DEFINITIONS // ═══════════════════════════════════════════════════════════════════════════════ export interface GenomicAlteration { gene: string; alteration: string; alterationType: AlterationType; frequency: string; cancerTypes: string[]; actionability: ActionabilityLevel; therapies: TargetedTherapy[]; clinicalTrials: string[]; resistance: ResistanceMutation[]; prognosticValue: PrognosticValue; } export type AlterationType = | 'Missense Mutation' | 'Nonsense Mutation' | 'Frameshift' | 'In-frame Deletion' | 'In-frame Insertion' | 'Splice Site' | 'Amplification' | 'Deletion' | 'Fusion' | 'Rearrangement' | 'Copy Number Gain' | 'Copy Number Loss'; export interface ActionabilityLevel { level: 'Level 1' | 'Level 2' | 'Level 3A' | 'Level 3B' | 'Level 4' | 'Not Actionable'; description: string; source: string; } export interface TargetedTherapy { drug: string; class: string; approvalStatus: 'FDA-Approved' | 'EMA-Approved' | 'Off-Label' | 'Clinical Trial'; indication: string; responseRate: string; medianPFS: string; keyTrial: string; } export interface ResistanceMutation { mutation: string; frequency: string; overcomingStrategy: string[]; } export interface PrognosticValue { impact: 'Favorable' | 'Unfavorable' | 'Neutral' | 'Context-Dependent'; description: string; } // ═══════════════════════════════════════════════════════════════════════════════ // ACTIONABLE GENOMIC DATABASE // ═══════════════════════════════════════════════════════════════════════════════ export const ACTIONABLE_GENOMIC_DATABASE: GenomicAlteration[] = [ // EGFR Mutations { gene: 'EGFR', alteration: 'Exon 19 deletion', alterationType: 'In-frame Deletion', frequency: '45% of EGFR mutations', cancerTypes: ['NSCLC Adenocarcinoma'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB, NCCN' }, therapies: [ { drug: 'Osimertinib', class: 'Third-generation EGFR TKI', approvalStatus: 'FDA-Approved', indication: 'First-line metastatic NSCLC', responseRate: '80%', medianPFS: '18.9 months', keyTrial: 'FLAURA' }, { drug: 'Erlotinib', class: 'First-generation EGFR TKI', approvalStatus: 'FDA-Approved', indication: 'First-line (less preferred)', responseRate: '65%', medianPFS: '10.4 months', keyTrial: 'EURTAC' } ], clinicalTrials: ['Amivantamab combinations', 'EGFR-MET bispecifics'], resistance: [ { mutation: 'T790M', frequency: '50-60%', overcomingStrategy: ['Osimertinib'] }, { mutation: 'C797S', frequency: '10-25%', overcomingStrategy: ['Amivantamab', 'BLU-945 (investigational)'] }, { mutation: 'MET amplification', frequency: '5-20%', overcomingStrategy: ['EGFR TKI + MET inhibitor'] } ], prognosticValue: { impact: 'Favorable', description: 'Better outcomes with TKI therapy' } }, { gene: 'EGFR', alteration: 'L858R', alterationType: 'Missense Mutation', frequency: '40% of EGFR mutations', cancerTypes: ['NSCLC Adenocarcinoma'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB, NCCN' }, therapies: [ { drug: 'Osimertinib', class: 'Third-generation EGFR TKI', approvalStatus: 'FDA-Approved', indication: 'First-line metastatic NSCLC', responseRate: '77%', medianPFS: '18.9 months', keyTrial: 'FLAURA' } ], clinicalTrials: ['Same as exon 19 del'], resistance: [ { mutation: 'T790M', frequency: '50-60%', overcomingStrategy: ['Osimertinib'] }, { mutation: 'C797S', frequency: '10-25%', overcomingStrategy: ['Amivantamab'] } ], prognosticValue: { impact: 'Favorable', description: 'Response to EGFR TKI, slightly less favorable than exon 19 del' } }, { gene: 'EGFR', alteration: 'Exon 20 insertion', alterationType: 'In-frame Insertion', frequency: '10% of EGFR mutations', cancerTypes: ['NSCLC Adenocarcinoma'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Amivantamab', class: 'EGFR-MET bispecific antibody', approvalStatus: 'FDA-Approved', indication: 'After platinum-based chemo', responseRate: '40%', medianPFS: '8.3 months', keyTrial: 'CHRYSALIS' }, { drug: 'Mobocertinib', class: 'EGFR exon 20-specific TKI', approvalStatus: 'FDA-Approved', indication: 'After platinum-based chemo', responseRate: '28%', medianPFS: '7.3 months', keyTrial: 'EXCLAIM' } ], clinicalTrials: ['First-line amivantamab + lazertinib'], resistance: [], prognosticValue: { impact: 'Unfavorable', description: 'Resistant to standard EGFR TKIs, less favorable outcomes' } }, // ALK Fusions { gene: 'ALK', alteration: 'EML4-ALK fusion', alterationType: 'Fusion', frequency: '3-5% of NSCLC', cancerTypes: ['NSCLC Adenocarcinoma'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB, NCCN' }, therapies: [ { drug: 'Lorlatinib', class: 'Third-generation ALK TKI', approvalStatus: 'FDA-Approved', indication: 'First-line', responseRate: '76%', medianPFS: 'NR (60% at 3 years)', keyTrial: 'CROWN' }, { drug: 'Alectinib', class: 'Second-generation ALK TKI', approvalStatus: 'FDA-Approved', indication: 'First-line', responseRate: '83%', medianPFS: '34.8 months', keyTrial: 'ALEX' }, { drug: 'Brigatinib', class: 'Second-generation ALK TKI', approvalStatus: 'FDA-Approved', indication: 'First-line', responseRate: '74%', medianPFS: '24 months', keyTrial: 'ALTA-1L' } ], clinicalTrials: ['Next-gen ALK inhibitors'], resistance: [ { mutation: 'G1202R', frequency: '20-30%', overcomingStrategy: ['Lorlatinib'] }, { mutation: 'L1196M', frequency: '10%', overcomingStrategy: ['Lorlatinib', 'Brigatinib'] }, { mutation: 'Compound mutations', frequency: '10-15%', overcomingStrategy: ['Lorlatinib (partial)', 'Clinical trial'] } ], prognosticValue: { impact: 'Favorable', description: 'Excellent response to ALK TKIs, long-term survival possible' } }, // KRAS G12C { gene: 'KRAS', alteration: 'G12C', alterationType: 'Missense Mutation', frequency: '13% of NSCLC, 3% of CRC', cancerTypes: ['NSCLC Adenocarcinoma', 'Colorectal Cancer'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Sotorasib', class: 'KRAS G12C inhibitor', approvalStatus: 'FDA-Approved', indication: 'NSCLC after prior therapy', responseRate: '37%', medianPFS: '6.8 months', keyTrial: 'CodeBreaK 100' }, { drug: 'Adagrasib', class: 'KRAS G12C inhibitor', approvalStatus: 'FDA-Approved', indication: 'NSCLC after prior therapy', responseRate: '43%', medianPFS: '6.5 months', keyTrial: 'KRYSTAL-1' } ], clinicalTrials: ['Combinations with SHP2 inhibitors', 'First-line combinations'], resistance: [ { mutation: 'Multiple mechanisms', frequency: '50%+ at progression', overcomingStrategy: ['Combination strategies', 'SHP2 inhibitors'] } ], prognosticValue: { impact: 'Unfavorable', description: 'Historically poor prognosis, now improving with targeted therapy' } }, // BRAF V600E { gene: 'BRAF', alteration: 'V600E', alterationType: 'Missense Mutation', frequency: '50% melanoma, 8% CRC, 2% NSCLC', cancerTypes: ['Melanoma', 'Colorectal Cancer', 'NSCLC', 'Thyroid Cancer'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Dabrafenib + Trametinib', class: 'BRAF + MEK inhibitor', approvalStatus: 'FDA-Approved', indication: 'Melanoma, NSCLC, Anaplastic thyroid', responseRate: '64-68%', medianPFS: '11-14 months', keyTrial: 'COMBI-d/v, BRF113928' }, { drug: 'Encorafenib + Binimetinib', class: 'BRAF + MEK inhibitor', approvalStatus: 'FDA-Approved', indication: 'Melanoma', responseRate: '63%', medianPFS: '14.9 months', keyTrial: 'COLUMBUS' }, { drug: 'Encorafenib + Cetuximab', class: 'BRAF + EGFR inhibitor', approvalStatus: 'FDA-Approved', indication: 'CRC after prior therapy', responseRate: '20%', medianPFS: '4.3 months', keyTrial: 'BEACON' } ], clinicalTrials: ['Triplet combinations', 'Immunotherapy combinations'], resistance: [ { mutation: 'MAPK reactivation', frequency: 'Common', overcomingStrategy: ['Add MEK inhibitor', 'Immunotherapy switch'] } ], prognosticValue: { impact: 'Unfavorable', description: 'Poor prognosis especially in CRC; targetable' } }, // HER2 Amplification/Mutation { gene: 'HER2/ERBB2', alteration: 'Amplification', alterationType: 'Amplification', frequency: '15-20% breast, 10-15% gastric', cancerTypes: ['Breast Cancer', 'Gastric Cancer', 'Esophageal Cancer'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Trastuzumab + Pertuzumab', class: 'Anti-HER2 antibodies', approvalStatus: 'FDA-Approved', indication: 'HER2+ breast (first-line)', responseRate: '80%', medianPFS: '18.7 months', keyTrial: 'CLEOPATRA' }, { drug: 'Trastuzumab Deruxtecan (T-DXd)', class: 'HER2-directed ADC', approvalStatus: 'FDA-Approved', indication: 'HER2+ breast (second-line), HER2-low, gastric', responseRate: '52-79%', medianPFS: '10-29 months', keyTrial: 'DESTINY-Breast01/03/04' } ], clinicalTrials: ['T-DXd combinations', 'Novel ADCs'], resistance: [ { mutation: 'Bypass pathways', frequency: 'Variable', overcomingStrategy: ['ADC therapy', 'TKI combinations'] } ], prognosticValue: { impact: 'Context-Dependent', description: 'Historically poor prognosis, now favorable with anti-HER2 therapy' } }, // PIK3CA Mutations { gene: 'PIK3CA', alteration: 'H1047R/E545K/E542K', alterationType: 'Missense Mutation', frequency: '40% HR+ breast cancer', cancerTypes: ['Breast Cancer'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Alpelisib', class: 'PI3K alpha inhibitor', approvalStatus: 'FDA-Approved', indication: 'HR+/HER2- with PIK3CA mutation after prior ET', responseRate: '26%', medianPFS: '11 months', keyTrial: 'SOLAR-1' } ], clinicalTrials: ['Next-gen PI3K inhibitors'], resistance: [], prognosticValue: { impact: 'Neutral', description: 'Predictive of response to PI3K inhibitor' } }, // ROS1 Fusion { gene: 'ROS1', alteration: 'Various fusions', alterationType: 'Fusion', frequency: '1-2% of NSCLC', cancerTypes: ['NSCLC Adenocarcinoma'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Entrectinib', class: 'ROS1/TRK inhibitor', approvalStatus: 'FDA-Approved', indication: 'First-line ROS1+ NSCLC', responseRate: '77%', medianPFS: '19 months', keyTrial: 'STARTRK-2, ALKA-372-001' }, { drug: 'Crizotinib', class: 'ROS1/ALK/MET inhibitor', approvalStatus: 'FDA-Approved', indication: 'First-line ROS1+ NSCLC', responseRate: '72%', medianPFS: '19.3 months', keyTrial: 'PROFILE 1001' } ], clinicalTrials: ['Repotrectinib', 'Next-gen ROS1 TKIs'], resistance: [ { mutation: 'G2032R', frequency: '30-40%', overcomingStrategy: ['Repotrectinib (investigational)', 'Lorlatinib'] } ], prognosticValue: { impact: 'Favorable', description: 'Excellent response to ROS1 inhibitors' } }, // NTRK Fusions (Tissue-agnostic) { gene: 'NTRK1/2/3', alteration: 'Various fusions', alterationType: 'Fusion', frequency: '<1% of common cancers, higher in rare cancers', cancerTypes: ['Tissue-agnostic', 'Infantile Fibrosarcoma', 'Secretory Breast', 'Thyroid'], actionability: { level: 'Level 1', description: 'FDA tissue-agnostic approval', source: 'OncoKB' }, therapies: [ { drug: 'Larotrectinib', class: 'TRK inhibitor', approvalStatus: 'FDA-Approved', indication: 'NTRK fusion-positive solid tumors', responseRate: '75%', medianPFS: '28.3 months', keyTrial: 'NAVIGATE, SCOUT, LOXO-TRK-14001' }, { drug: 'Entrectinib', class: 'TRK/ROS1 inhibitor', approvalStatus: 'FDA-Approved', indication: 'NTRK fusion-positive solid tumors', responseRate: '57%', medianPFS: '11.2 months', keyTrial: 'STARTRK-1/2, ALKA-372-001' } ], clinicalTrials: ['Next-gen TRK inhibitors for resistance'], resistance: [ { mutation: 'Solvent front mutations', frequency: '10-20%', overcomingStrategy: ['Selitrectinib', 'Repotrectinib'] } ], prognosticValue: { impact: 'Favorable', description: 'Excellent durable responses across tumor types' } }, // RET Alterations { gene: 'RET', alteration: 'Fusion or Mutation', alterationType: 'Fusion', frequency: '1-2% NSCLC, 10-20% thyroid', cancerTypes: ['NSCLC', 'Thyroid Cancer (MTC, PTC)'], actionability: { level: 'Level 1', description: 'FDA-approved therapy exists', source: 'OncoKB' }, therapies: [ { drug: 'Selpercatinib', class: 'Selective RET inhibitor', approvalStatus: 'FDA-Approved', indication: 'RET-altered NSCLC and thyroid', responseRate: '64-85%', medianPFS: '16.5-24.9 months', keyTrial: 'LIBRETTO-001' }, { drug: 'Pralsetinib', class: 'Selective RET inhibitor', approvalStatus: 'FDA-Approved', indication: 'RET-altered NSCLC and thyroid', responseRate: '57-72%', medianPFS: '13-17 months', keyTrial: 'ARROW' } ], clinicalTrials: ['Resistance mutation-targeting agents'], resistance: [ { mutation: 'G810X solvent front', frequency: '10-20%', overcomingStrategy: ['Investigational agents'] } ], prognosticValue: { impact: 'Favorable', description: 'Excellent response to selective RET inhibitors' } }, // MSI-H/dMMR (Tissue-agnostic) { gene: 'MSI-H/dMMR', alteration: 'Microsatellite Instability High', alterationType: 'Frameshift', frequency: '15% CRC, 20-30% endometrial, variable others', cancerTypes: ['Tissue-agnostic'], actionability: { level: 'Level 1', description: 'FDA tissue-agnostic approval', source: 'OncoKB' }, therapies: [ { drug: 'Pembrolizumab', class: 'Anti-PD-1', approvalStatus: 'FDA-Approved', indication: 'MSI-H/dMMR solid tumors', responseRate: '39-45%', medianPFS: '16.5 months (CRC)', keyTrial: 'KEYNOTE-158, KEYNOTE-177' }, { drug: 'Dostarlimab', class: 'Anti-PD-1', approvalStatus: 'FDA-Approved', indication: 'dMMR solid tumors', responseRate: '42%', medianPFS: 'Not reached', keyTrial: 'GARNET' } ], clinicalTrials: ['Neoadjuvant immunotherapy'], resistance: [ { mutation: 'Beta-2-microglobulin loss', frequency: '5-10%', overcomingStrategy: ['Combination immunotherapy'] } ], prognosticValue: { impact: 'Favorable', description: 'Excellent response to immunotherapy' } }, // TMB-High { gene: 'TMB-High', alteration: 'Tumor Mutational Burden ≥10 mut/Mb', alterationType: 'Missense Mutation', frequency: 'Variable by cancer type', cancerTypes: ['Tissue-agnostic'], actionability: { level: 'Level 1', description: 'FDA tissue-agnostic approval', source: 'OncoKB' }, therapies: [ { drug: 'Pembrolizumab', class: 'Anti-PD-1', approvalStatus: 'FDA-Approved', indication: 'TMB-H (≥10 mut/Mb) solid tumors', responseRate: '29%', medianPFS: 'Variable', keyTrial: 'KEYNOTE-158' } ], clinicalTrials: ['Combination strategies'], resistance: [], prognosticValue: { impact: 'Context-Dependent', description: 'Predictive of immunotherapy response' } } ]; // ═══════════════════════════════════════════════════════════════════════════════ // PHARMACOGENOMICS FOR ONCOLOGY // ═══════════════════════════════════════════════════════════════════════════════ export interface PharmacogenomicMarker { gene: string; variant: string; affectedDrugs: DrugPGx[]; testingRecommendation: 'Required' | 'Strongly Recommended' | 'Consider' | 'Optional'; guidelineSource: string; } export interface DrugPGx { drug: string; effect: string; recommendation: string; doseAdjustment?: string; } export const PHARMACOGENOMIC_MARKERS: PharmacogenomicMarker[] = [ { gene: 'DPYD', variant: 'DPYD*2A, *13, c.2846A>T, HapB3', affectedDrugs: [ { drug: '5-Fluorouracil (5-FU)', effect: 'Reduced DPD enzyme activity, increased toxicity risk', recommendation: 'Test before initiating fluoropyrimidines', doseAdjustment: '*2A/*2A: Avoid; Heterozygous: 50% dose reduction' }, { drug: 'Capecitabine', effect: 'Same as 5-FU', recommendation: 'Same as 5-FU', doseAdjustment: 'Same as 5-FU' } ], testingRecommendation: 'Strongly Recommended', guidelineSource: 'CPIC, EMA' }, { gene: 'UGT1A1', variant: 'UGT1A1*28, *6', affectedDrugs: [ { drug: 'Irinotecan', effect: 'Reduced glucuronidation, increased SN-38 toxicity', recommendation: 'Consider testing for high-dose irinotecan', doseAdjustment: '*28/*28: Reduce dose 30%; *28/*6 or *6/*6: Reduce dose' }, { drug: 'Sacituzumab govitecan', effect: 'Contains SN-38, similar toxicity risk', recommendation: 'Consider testing', doseAdjustment: '*28/*28: Monitor closely, consider dose reduction' } ], testingRecommendation: 'Consider', guidelineSource: 'CPIC, FDA label' }, { gene: 'TPMT/NUDT15', variant: 'TPMT*2, *3A, *3B, *3C; NUDT15*3', affectedDrugs: [ { drug: '6-Mercaptopurine', effect: 'Reduced thiopurine metabolism, severe myelosuppression', recommendation: 'Test before initiating thiopurines', doseAdjustment: 'Poor metabolizer: 10% of normal dose' }, { drug: 'Azathioprine', effect: 'Same as 6-MP', recommendation: 'Same', doseAdjustment: 'Same' } ], testingRecommendation: 'Required', guidelineSource: 'CPIC, FDA label' }, { gene: 'G6PD', variant: 'G6PD deficiency', affectedDrugs: [ { drug: 'Rasburicase', effect: 'Hemolytic anemia, methemoglobinemia', recommendation: 'Screen before use', doseAdjustment: 'Contraindicated in G6PD deficiency' } ], testingRecommendation: 'Required', guidelineSource: 'FDA label' }, { gene: 'CYP2D6', variant: 'Poor metabolizer', affectedDrugs: [ { drug: 'Tamoxifen', effect: 'Reduced conversion to active metabolite endoxifen', recommendation: 'Consider testing, especially if concurrent CYP2D6 inhibitors', doseAdjustment: 'PM: Consider alternative (aromatase inhibitor if postmenopausal)' } ], testingRecommendation: 'Consider', guidelineSource: 'CPIC' }, { gene: 'HLA-B*57:01', variant: 'Presence of allele', affectedDrugs: [ { drug: 'Abacavir', effect: 'Hypersensitivity reaction', recommendation: 'Test before initiating', doseAdjustment: 'Do not use if positive' } ], testingRecommendation: 'Required', guidelineSource: 'FDA label, CPIC' } ]; // ═══════════════════════════════════════════════════════════════════════════════ // TUMOR MICROENVIRONMENT ANALYSIS // ═══════════════════════════════════════════════════════════════════════════════ export interface TumorMicroenvironment { immuneInfiltration: ImmuneInfiltration; stromalPhenotype: StromalPhenotype; vascularization: VascularStatus; immunePhenotype: 'Inflamed' | 'Excluded' | 'Desert'; therapeuticImplications: TherapeuticImplication[]; } export interface ImmuneInfiltration { cd8TILs: 'High' | 'Intermediate' | 'Low' | 'Absent'; cd4TILs: 'High' | 'Intermediate' | 'Low'; tregs: 'High' | 'Low'; myeloidCells: MDSCStatus; nkCells: 'Present' | 'Absent'; bCells: 'Present' | 'Absent' | 'TLS Present'; } export interface MDSCStatus { mdscLevel: 'High' | 'Low'; m1m2Ratio: 'M1-predominant' | 'M2-predominant' | 'Mixed'; } export interface StromalPhenotype { cafPresence: 'High' | 'Low'; ecmDensity: 'Dense' | 'Moderate' | 'Loose'; fibrosis: boolean; } export interface VascularStatus { vascularDensity: 'High' | 'Moderate' | 'Low'; vascularNormalization: boolean; hypoxia: boolean; } export interface TherapeuticImplication { finding: string; implication: string; recommendation: string; } export const TME_THERAPEUTIC_IMPLICATIONS: Record = { 'Inflamed': [ { finding: 'High CD8+ TIL infiltration with PD-L1 expression', implication: 'Likely responsive to PD-1/PD-L1 blockade', recommendation: 'First-line immunotherapy appropriate' }, { finding: 'Tertiary lymphoid structures (TLS) present', implication: 'Associated with improved immunotherapy response', recommendation: 'Immunotherapy highly recommended' } ], 'Excluded': [ { finding: 'T cells present at tumor margin but not infiltrating', implication: 'Physical or immunological barrier to T cell entry', recommendation: 'Consider anti-TGF-beta, CAF-targeting, or combination approaches' }, { finding: 'Dense fibrotic stroma', implication: 'Stromal barrier limiting drug penetration', recommendation: 'Consider stromal-targeting agents or chemotherapy to disrupt' } ], 'Desert': [ { finding: 'Absence of immune infiltrate', implication: 'Poor immunogenicity or immune evasion', recommendation: 'Consider chemotherapy to induce immunogenic cell death, oncolytic viruses, or vaccines' }, { finding: 'Low TMB, no neoantigens', implication: 'Limited targets for immune recognition', recommendation: 'Chemotherapy or targeted therapy may be more appropriate than immunotherapy' } ] }; // ═══════════════════════════════════════════════════════════════════════════════ // LIQUID BIOPSY / ctDNA INTERPRETATION // ═══════════════════════════════════════════════════════════════════════════════ export interface LiquidBiopsyResult { sampleDate: string; ctdnaFraction: number; alterationsDetected: CtDNAAlteration[]; clinicalInterpretation: CtDNAInterpretation; } export interface CtDNAAlteration { gene: string; alteration: string; vaf: number; // Variant allele frequency clinicalSignificance: 'Actionable' | 'Resistance' | 'Prognostic' | 'VUS' | 'Benign'; } export interface CtDNAInterpretation { summary: string; actionableFindings: string[]; resistanceMutations: string[]; monitoringRecommendation: string; tissueConfirmationNeeded: boolean; } export function interpretCtDNA(result: LiquidBiopsyResult): CtDNAInterpretation { const actionableFindings: string[] = []; const resistanceMutations: string[] = []; for (const alt of result.alterationsDetected) { if (alt.clinicalSignificance === 'Actionable') { actionableFindings.push(`${alt.gene} ${alt.alteration} (VAF: ${alt.vaf}%)`); } if (alt.clinicalSignificance === 'Resistance') { resistanceMutations.push(`${alt.gene} ${alt.alteration}`); } } let summary = ''; if (result.ctdnaFraction < 0.5) { summary = 'Low ctDNA fraction - may indicate low tumor burden or shedding; consider repeat testing or tissue biopsy'; } else if (result.ctdnaFraction > 10) { summary = 'High ctDNA fraction - indicates significant tumor burden'; } else { summary = 'Detectable ctDNA with interpretable results'; } const tissueConfirmationNeeded = result.ctdnaFraction < 1 && actionableFindings.length > 0; let monitoringRecommendation = 'Repeat ctDNA in 8-12 weeks or at clinical/radiographic progression'; if (resistanceMutations.length > 0) { monitoringRecommendation = 'Resistance mutations detected - consider treatment change; repeat ctDNA after new therapy started'; } return { summary, actionableFindings, resistanceMutations, monitoringRecommendation, tissueConfirmationNeeded }; } // ═══════════════════════════════════════════════════════════════════════════════ // PRECISION MEDICINE ENGINE // ═══════════════════════════════════════════════════════════════════════════════ export class PrecisionMedicineEngine { getActionableAlterations(gene: string): GenomicAlteration[] { return ACTIONABLE_GENOMIC_DATABASE.filter(a => a.gene.toLowerCase() === gene.toLowerCase() ); } getAlterationByType(alteration: string): GenomicAlteration | undefined { return ACTIONABLE_GENOMIC_DATABASE.find(a => a.alteration.toLowerCase().includes(alteration.toLowerCase()) || alteration.toLowerCase().includes(a.alteration.toLowerCase()) ); } getTherapiesForAlteration(gene: string, alteration: string): TargetedTherapy[] { const genomicAlt = ACTIONABLE_GENOMIC_DATABASE.find(a => a.gene.toLowerCase() === gene.toLowerCase() && a.alteration.toLowerCase().includes(alteration.toLowerCase()) ); return genomicAlt?.therapies || []; } getPharmacogenomicRecommendation(drug: string): PharmacogenomicMarker | undefined { return PHARMACOGENOMIC_MARKERS.find(p => p.affectedDrugs.some(d => d.drug.toLowerCase().includes(drug.toLowerCase())) ); } assessActionability(alterations: { gene: string; alteration: string }[]): { level1: GenomicAlteration[]; level2: GenomicAlteration[]; level3: GenomicAlteration[]; notActionable: string[]; } { const result = { level1: [] as GenomicAlteration[], level2: [] as GenomicAlteration[], level3: [] as GenomicAlteration[], notActionable: [] as string[] }; for (const alt of alterations) { const match = ACTIONABLE_GENOMIC_DATABASE.find(a => a.gene.toLowerCase() === alt.gene.toLowerCase() ); if (match) { if (match.actionability.level === 'Level 1') { result.level1.push(match); } else if (match.actionability.level === 'Level 2') { result.level2.push(match); } else if (match.actionability.level.includes('3')) { result.level3.push(match); } } else { result.notActionable.push(`${alt.gene} ${alt.alteration}`); } } return result; } getTMEImplications(phenotype: TumorMicroenvironment['immunePhenotype']): TherapeuticImplication[] { return TME_THERAPEUTIC_IMPLICATIONS[phenotype] || []; } interpretLiquidBiopsy(result: LiquidBiopsyResult): CtDNAInterpretation { return interpretCtDNA(result); } generatePrecisionReport( patientId: string, genomicProfile: { gene: string; alteration: string; type: string }[], pharmacogenomics: string[], tmeIfAvailable?: TumorMicroenvironment ): { actionableTargets: GenomicAlteration[]; pgxRecommendations: PharmacogenomicMarker[]; tmeImplications: TherapeuticImplication[]; clinicalTrialTargets: string[]; summary: string; } { const actionability = this.assessActionability(genomicProfile); const pgxRecommendations: PharmacogenomicMarker[] = []; for (const gene of pharmacogenomics) { const pgx = PHARMACOGENOMIC_MARKERS.find(p => p.gene === gene); if (pgx) pgxRecommendations.push(pgx); } const tmeImplications = tmeIfAvailable ? this.getTMEImplications(tmeIfAvailable.immunePhenotype) : []; const clinicalTrialTargets = [ ...actionability.level1.flatMap(a => a.clinicalTrials), ...actionability.level2.flatMap(a => a.clinicalTrials), ...actionability.level3.flatMap(a => a.clinicalTrials) ]; const summary = `Found ${actionability.level1.length} Level 1, ${actionability.level2.length} Level 2, and ${actionability.level3.length} Level 3 actionable alterations. ${pgxRecommendations.length} pharmacogenomic considerations identified.`; return { actionableTargets: [...actionability.level1, ...actionability.level2], pgxRecommendations, tmeImplications, clinicalTrialTargets: [...new Set(clinicalTrialTargets)], summary }; } } // Export singleton export const precisionMedicineEngine = new PrecisionMedicineEngine();