import { action, computed, makeObservable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { Row } from 'react-bootstrap'; import HeaderAnnotation from '../headerAnnotation/HeaderAnnotation'; import FeatureTable from '../featureTable/FeatureTable'; import { VariantStore } from '../../store/VariantStore'; import { variantToMutation } from '../../util/VariantUtil'; import styles from './Variant.module.scss'; import { GenomeNexusAPI } from 'genome-nexus-ts-api-client'; import { OncoKbAPI } from 'oncokb-ts-api-client'; import { MutationMapperDataFetcher } from 'react-mutation-mapper/dist/model/MutationMapperDataFetcher'; interface IVariantProps { variant: string; store?: VariantStore; mainLoadingIndicator?: JSX.Element; genomeNexusClient?: GenomeNexusAPI; oncoKbClient?: OncoKbAPI; mutationMapperDataFetcher?: MutationMapperDataFetcher; } export function initDefaultVariantStore(props: IVariantProps) { return new VariantStore( props.variant, '', props.genomeNexusClient, props.oncoKbClient, props.mutationMapperDataFetcher ); } @observer class Variant extends React.Component { constructor(props: IVariantProps) { super(props); makeObservable< Variant, | 'variantStore' | 'myVariantInfo' | 'oncokb' | 'variantAnnotation' | 'setActiveTranscript' | 'onTranscriptSelect' >(this); } public render(): React.ReactNode { return this.isLoading ? ( this.loadingIndicator ) : (
{!this.isCanonicalTranscriptSelected && (
* This resource uses a transcript different from the displayed one, but the genomic change is the same.
)}
); } @computed protected get variantStore(): VariantStore { return this.props.store ? this.props.store! : initDefaultVariantStore(this.props); } @computed private get myVariantInfo() { return this.variantStore.annotation.result && this.variantStore.annotation.result.my_variant_info ? this.variantStore.annotation.result.my_variant_info.annotation : undefined; } @computed private get clinvar() { return this.variantAnnotation?.clinvar.annotation; } @computed private get signalAnnotation() { return this.variantAnnotation?.signalAnnotation; } @computed private get oncokb() { return this.variantStore.oncokbData.result; } @computed private get variantAnnotation() { return this.variantStore.annotation.result ? this.variantStore.annotation.result : undefined; } @computed get isCanonicalTranscriptSelected() { if (this.variantStore.annotationSummary) { // no selection, canonical transcript will be selected as default return ( this.variantStore.selectedTranscript === '' || this.variantStore.selectedTranscript === this.variantStore.annotationSummary.canonicalTranscriptId ); } else { return undefined; } } protected get isLoading() { return ( this.variantStore.annotation.isPending || this.variantStore.oncokbGenesMap.isPending || this.variantStore.isAnnotatedSuccessfully.isPending ); } protected get loadingIndicator() { return ( this.props.mainLoadingIndicator || (
) ); } @computed get allValidTranscripts() { if ( this.variantStore.isAnnotatedSuccessfully.isComplete && this.variantStore.isAnnotatedSuccessfully.result === true && this.variantStore.mutationMapperStore && this.variantStore.mutationMapperStore.transcriptsWithAnnotations .result && this.variantStore.mutationMapperStore.transcriptsWithAnnotations .result.length > 0 ) { return this.variantStore.mutationMapperStore .transcriptsWithAnnotations.result; } return []; } @action.bound private setActiveTranscript(transcriptId: string) { this.variantStore.mutationMapperStore!.setSelectedTranscript( transcriptId ); this.variantStore.selectedTranscript = transcriptId; } @action.bound private onTranscriptSelect(transcriptId: string) { this.setActiveTranscript(transcriptId); } } export default Variant;