import React, { useState } from 'react'; import { Tab, Tabs } from 'react-bootstrap'; import classnames from 'classnames'; import { IndicatorQueryResp, MutationEffectResp } from 'oncokb-ts-api-client'; import Tooltip from 'rc-tooltip'; import { OncoKbCardDataType } from 'cbioportal-utils'; import { annotationIconClassNames, calcHighestIndicatorLevel, normalizeLevel, } from '../util/OncoKbUtils'; import { OncoKbCardLevelsOfEvidenceDropdown } from './OncoKbCardLevelsOfEvidenceDropdown'; import OncoKBSuggestAnnotationLinkout from './OncoKBSuggestAnnotationLinkout'; import OncoKbHelper from './OncoKbHelper'; import { OncoKbTreatmentTable } from './OncoKbTreatmentTable'; import { BiologicalContent } from './oncokbCard/BiologicalContent'; import { ImplicationContent } from './oncokbCard/ImplicationContent'; import tabsStyles from './tabs.module.scss'; import mainStyles from './main.module.scss'; import OncogenicIcon from './icon/OncogenicIcon'; import LevelIcon from './icon/LevelIcon'; const OncoKbMedicalDisclaimer = (

The information above is intended for research purposes only and should not be used as a substitute for professional diagnosis and treatment.

); const ONCOKB_DATA_ACCESS_PAGE_LINK = 'https://docs.cbioportal.org/2.4-integration-with-other-webservices/oncokb-data-access'; const publicInstanceDisclaimerOverLay = (

This cBioPortal instance is not linked to an OncoKB™ license, and therefore some OncoKB content is not available including therapeutic, diagnostic and prognostic implications. To obtain a license, please follow{' '} these instructions .

{OncoKbMedicalDisclaimer}
); const DATA_TYPE_TO_TITLE = { [OncoKbCardDataType.BIOLOGICAL]: 'Biological Effect', [OncoKbCardDataType.TXS]: 'Therapeutic Implications', [OncoKbCardDataType.TXR]: 'Therapeutic Implications', [OncoKbCardDataType.DX]: 'Diagnostic Implications', [OncoKbCardDataType.PX]: 'Prognostic Implications', }; export type OncoKbCardBodyProps = { type: OncoKbCardDataType; geneNotExist: boolean; isCancerGene: boolean; hugoSymbol: string; indicator?: IndicatorQueryResp; usingPublicOncoKbInstance: boolean; displayHighestLevelInTabTitle?: boolean; }; const TabContentWrapper: React.FunctionComponent<{}> = props => { return
{props.children}
; }; const TabTitle: React.FunctionComponent<{ type: OncoKbCardDataType; indicator?: IndicatorQueryResp; displayHighestLevelInTabTitle?: boolean; }> = props => { const title = DATA_TYPE_TO_TITLE[props.type]; const icon = props.displayHighestLevelInTabTitle ? ( props.type === OncoKbCardDataType.BIOLOGICAL ? ( ) : ( ) ) : null; return icon ? ( {icon} {title} ) : ( {title} ); }; export const OncoKbCardBody: React.FunctionComponent = props => { let defaultTabActiveKey: OncoKbCardDataType | undefined; // Do not assign a default key if the data type specified through the property does not have any content // When the content is not available, we do not render the tab. if (dataTypeHasContent(props.type)) { defaultTabActiveKey = props.type; // Both TXS and TXR are therapeutic implication data type which will be shown in the same tab. We use TXS as the tab key when rendering if ( [OncoKbCardDataType.TXS, OncoKbCardDataType.TXR].includes( defaultTabActiveKey ) ) { defaultTabActiveKey = OncoKbCardDataType.TXS; } } const [activateTabKey, setActivateTabKey] = useState(defaultTabActiveKey); const [levelsOfEvidence, setLevelsOfEvidence] = useState( getLevelsOfEvidence(activateTabKey) ); function updateActivateTabKey(newKey: any) { setActivateTabKey(newKey); setLevelsOfEvidence(getLevelsOfEvidence(newKey)); } function hasMutationEffectInfo(mutationEffect?: MutationEffectResp) { return ( mutationEffect && (mutationEffect.description || mutationEffect.citations.abstracts.length > 0 || mutationEffect.citations.pmids.length > 0) ); } function dataTypeHasContent(type: OncoKbCardDataType) { switch (type) { case OncoKbCardDataType.BIOLOGICAL: return hasMutationEffectInfo(props.indicator?.mutationEffect); case OncoKbCardDataType.TXS: case OncoKbCardDataType.TXR: return ( !!props.indicator?.highestSensitiveLevel || !!props.indicator?.highestResistanceLevel ); case OncoKbCardDataType.DX: return !!props.indicator?.highestDiagnosticImplicationLevel; case OncoKbCardDataType.PX: return !!props.indicator?.highestPrognosticImplicationLevel; default: return false; } } function getBody(type: OncoKbCardDataType, indicator: IndicatorQueryResp) { const tabs = []; if (dataTypeHasContent(OncoKbCardDataType.BIOLOGICAL)) { tabs.push( } > ); } if ( !props.usingPublicOncoKbInstance && dataTypeHasContent(OncoKbCardDataType.TXS) ) { tabs.push( } >
); } if ( !props.usingPublicOncoKbInstance && dataTypeHasContent(OncoKbCardDataType.DX) ) { tabs.push( } > ); } if ( !props.usingPublicOncoKbInstance && dataTypeHasContent(OncoKbCardDataType.PX) ) { tabs.push( } > ); } return (

{indicator.geneSummary}

{indicator.variantSummary}

{props.usingPublicOncoKbInstance ? (

Therapeutic, diagnostic and prognostic implications are not available in this instance of cBioPortal.{' '}

) : (

{indicator.tumorTypeSummary}

)} {tabs.length > 0 && ( {tabs} )}
); } function getLevelsOfEvidence(activateTabKey?: OncoKbCardDataType) { switch (activateTabKey) { case OncoKbCardDataType.TXS: case OncoKbCardDataType.TXR: return { levels: OncoKbHelper.TX_LEVELS, levelDes: OncoKbHelper.getLevelsDesc(activateTabKey), }; case OncoKbCardDataType.DX: return { levels: OncoKbHelper.DX_LEVELS, levelDes: OncoKbHelper.getLevelsDesc(OncoKbCardDataType.DX), }; case OncoKbCardDataType.PX: return { levels: OncoKbHelper.PX_LEVELS, levelDes: OncoKbHelper.getLevelsDesc(OncoKbCardDataType.PX), }; default: return { levels: [], levelDes: {}, }; } } const UNKNOWN = 'Unknown'; function getOncogenicity() { let oncogenicity = props.indicator?.oncogenic; if (!oncogenicity || oncogenicity === UNKNOWN) { oncogenicity = 'Unknown Oncogenic Effect'; } return oncogenicity; } function getMutationEffect() { let mutationEffect = props.indicator?.mutationEffect.knownEffect; if (!mutationEffect || mutationEffect === UNKNOWN) { mutationEffect = 'Unknown Biological Effect'; } return mutationEffect; } return ( <> {!props.geneNotExist && (
{props.indicator && ( <>
{getOncogenicity()}
{getMutationEffect()}
{getBody(props.type, props.indicator)}
)} {!props.usingPublicOncoKbInstance && ( <> {/*Use tab pane style for the disclaimer to keep the consistency since the info is attached right under the tab pane*/}
{OncoKbMedicalDisclaimer}
{levelsOfEvidence && levelsOfEvidence.levels.length > 0 && ( )} )}
)} {!props.isCancerGene && (
There is currently no information about this gene in OncoKB.
)} {props.geneNotExist && props.isCancerGene && (
)} ); };