import * as React from 'react'; import { observer } from 'mobx-react'; import { makeObservable, observable } from 'mobx'; import _ from 'lodash'; import { CancerStudy, ClinicalData, GenePanelData, MolecularProfile, Mutation, } from 'cbioportal-ts-api-client'; import { IColumnVisibilityControlsProps } from 'shared/components/columnVisibilityControls/ColumnVisibilityControls'; import SampleManager from '../SampleManager'; import PubMedCache from 'shared/cache/PubMedCache'; import MrnaExprRankCache from 'shared/cache/MrnaExprRankCache'; import { GeneFilterOption } from '../mutation/GeneFilterMenu'; import { ICivicGeneIndex, ICivicVariantIndex, IHotspotIndex, IMyCancerGenomeData, IMyVariantInfoIndex, IOncoKbData, RemoteData, } from 'cbioportal-utils'; import { CancerGene } from 'oncokb-ts-api-client'; import { calculateOncoKbContentWidthWithInterval, DEFAULT_ONCOKB_CONTENT_WIDTH, } from 'shared/lib/AnnotationColumnUtils'; import { ILazyMobXTableApplicationDataStore } from 'shared/lib/ILazyMobXTableApplicationDataStore'; import PatientViewMutationTable from './PatientViewMutationTable'; import { getServerConfig, ServerConfigHelpers } from 'config/config'; import VariantCountCache from 'shared/cache/VariantCountCache'; import DiscreteCNACache from 'shared/cache/DiscreteCNACache'; import GenomeNexusCache from 'shared/cache/GenomeNexusCache'; import GenomeNexusMutationAssessorCache from 'shared/cache/GenomeNexusMutationAssessorCache'; import { MutationTableDownloadDataFetcher } from 'shared/lib/MutationTableDownloadDataFetcher'; import { IMutSigData } from 'shared/model/MutSig'; import { ICosmicData } from 'shared/model/Cosmic'; import MobxPromise from 'mobxpromise'; import FeatureInstruction from 'shared/FeatureInstruction/FeatureInstruction'; import { getSamplesProfiledStatus } from 'pages/patientView/PatientViewPageUtils'; import { MakeMobxView } from 'shared/components/MobxView'; import LoadingIndicator from 'shared/components/loadingIndicator/LoadingIndicator'; import ErrorMessage from 'shared/components/ErrorMessage'; import { PatientViewPageStore } from 'pages/patientView/clinicalInformation/PatientViewPageStore'; import SampleNotProfiledAlert from 'shared/components/SampleNotProfiledAlert'; import { NamespaceColumnConfig } from 'shared/components/namespaceColumns/NamespaceColumnConfig'; export const TABLE_FEATURE_INSTRUCTION = 'Click on an mutation to zoom in on the gene in the IGV browser above'; type IMutationTableWrapperProps = { patientViewPageStore: PatientViewPageStore; dataStore?: ILazyMobXTableApplicationDataStore; sampleManager: SampleManager | null; sampleIds: string[]; discreteCNACache?: DiscreteCNACache; mrnaExprRankCache?: MrnaExprRankCache; pubMedCache?: PubMedCache; genomeNexusCache?: GenomeNexusCache; genomeNexusMutationAssessorCache?: GenomeNexusMutationAssessorCache; mrnaExprRankMolecularProfileId?: string; discreteCNAMolecularProfileId?: string; mutSigData?: IMutSigData; hotspotData?: RemoteData; cosmicData?: ICosmicData; oncoKbData?: RemoteData; oncoKbCancerGenes?: RemoteData; mergeOncoKbIcons?: boolean; onOncoKbIconToggle: (mergeIcons: boolean) => void; civicGenes?: RemoteData; civicVariants?: RemoteData; userEmailAddress?: string | undefined; enableOncoKb?: boolean; enableCivic?: boolean; columnVisibility?: { [columnId: string]: boolean }; showGeneFilterMenu?: boolean; onFilterGenes?: (option: GeneFilterOption) => void; columnVisibilityProps?: IColumnVisibilityControlsProps; onSelectGenePanel?: (name: string) => void; disableTooltip?: boolean; onRowClick?: (d: Mutation[]) => void; onRowMouseEnter?: (d: Mutation[]) => void; onRowMouseLeave?: (d: Mutation[]) => void; sampleIdToClinicalDataMap?: MobxPromise<{ [x: string]: ClinicalData[] }>; namespaceColumns: NamespaceColumnConfig; columns: string[]; alleleFreqHeaderRender?: ((name: string) => JSX.Element) | undefined; pageMode?: 'sample' | 'patient'; }; const ANNOTATION_ELEMENT_ID = 'mutation-annotation'; @observer export default class MutationTableWrapper extends React.Component< IMutationTableWrapperProps, {} > { @observable oncokbWidth = DEFAULT_ONCOKB_CONTENT_WIDTH; private oncokbInterval: any; constructor(props: IMutationTableWrapperProps) { super(props); makeObservable(this); // here we wait for the oncokb icons to fully finish rendering // then update the oncokb width in order to align annotation column header icons with the cell content // this.oncokbInterval = calculateOncoKbContentWidthWithInterval( // ANNOTATION_ELEMENT_ID, // oncoKbContentWidth => { // (this.oncokbWidth = oncoKbContentWidth) // } // ); } public destroy() { clearInterval(this.oncokbInterval); } public static defaultProps = { enableOncoKb: true, enableCivic: false, showGeneFilterMenu: true, }; public get pageStore() { return this.props.patientViewPageStore; } tableUI = MakeMobxView({ await: () => [ this.pageStore.mutationData, this.pageStore.uncalledMutationData, this.pageStore.oncoKbAnnotatedGenes, this.pageStore.sampleToDiscreteGenePanelId, this.pageStore.mutationMolecularProfile, this.pageStore.mutationMolecularProfile, this.pageStore.genePanelDataByMolecularProfileIdAndSampleId, this.pageStore.sampleManager, this.pageStore.studyIdToStudy, this.pageStore.sampleToMutationGenePanelId, this.pageStore.genePanelIdToEntrezGeneIds, this.pageStore.molecularProfileIdToMolecularProfile, this.pageStore.mrnaRankMolecularProfileId, this.pageStore.molecularProfileIdDiscrete, this.pageStore.mutSigData, this.pageStore.cosmicData, this.pageStore.mutationTableShowGeneFilterMenu, ], render: () => { if (!this.pageStore.mutationMolecularProfile.result) { return (
Study is not profiled for mutations.
); } const { someProfiled } = getSamplesProfiledStatus( this.props.sampleIds, this.pageStore.genePanelDataByMolecularProfileIdAndSampleId .result, this.pageStore.mutationMolecularProfile.result .molecularProfileId ); return ( <> {someProfiled && ( )} ); }, renderPending: () => , renderError: () => , }); public render() { return this.tableUI.component; } }