import * as React from 'react'; import { observer } from 'mobx-react'; import autobind from 'autobind-decorator'; import { buildDriverAnnotationControlsHandlers, buildDriverAnnotationControlsState, IAnnotationFilterSettings, IDriverAnnotationControlsHandlers, IDriverAnnotationControlsState, } from '../../alterationFiltering/AnnotationFilteringSettings'; import InfoIcon from '../InfoIcon'; import styles from './styles.module.scss'; import classNames from 'classnames'; import DriverTierControls from 'shared/components/driverAnnotations/DriverTierControls'; import { computed, makeObservable, observable } from 'mobx'; enum EVENT_KEY { showPutativeDrivers = '0', showPutativePassengers = '1', showUnknownOncogenicity = '2', showGermlineMutations = '3', showSomaticMutations = '4', showUnknownStatusMutations = '5', showUnknownTier = '6', toggleAllMutationStatus = '8', toggleAllDriverAnnotation = '9', toggleAllDriverTiers = '10', } export interface SettingsMenuProps { store: IAnnotationFilterSettings; infoElement?: JSX.Element | undefined; disabled?: boolean; customDriverSourceName?: string; showDriverAnnotationSection?: boolean; showTierAnnotationSection?: boolean; } @observer export default class SettingsMenu extends React.Component< SettingsMenuProps, {} > { public driverSettingsState: IDriverAnnotationControlsState; public driverSettingsHandlers: IDriverAnnotationControlsHandlers; @observable _driverAnnotationsCheckboxToggle = true; @observable _driverTiersCheckboxToggle = false; constructor(props: SettingsMenuProps) { super(props); makeObservable(this, { driverSettingsState: observable, driverSettingsHandlers: observable, }); this.driverSettingsState = buildDriverAnnotationControlsState( props.store.driverAnnotationSettings, props.store.customDriverAnnotationReport.result, props.store.didOncoKbFailInOncoprint, props.store.didHotspotFailInOncoprint ); this.driverSettingsHandlers = buildDriverAnnotationControlsHandlers( props.store.driverAnnotationSettings, this.driverSettingsState ); } @autobind private onInputClick(event: React.MouseEvent) { let value: boolean; switch ((event.target as HTMLInputElement).value) { case EVENT_KEY.showPutativeDrivers: this.props.store.driverAnnotationSettings.includeDriver = !this .props.store.driverAnnotationSettings.includeDriver; break; case EVENT_KEY.showPutativePassengers: this.props.store.driverAnnotationSettings.includeVUS = !this .props.store.driverAnnotationSettings.includeVUS; break; case EVENT_KEY.showUnknownOncogenicity: this.props.store.driverAnnotationSettings.includeUnknownOncogenicity = !this .props.store.driverAnnotationSettings .includeUnknownOncogenicity; break; case EVENT_KEY.showGermlineMutations: this.props.store.includeGermlineMutations = !this.props.store .includeGermlineMutations; break; case EVENT_KEY.showSomaticMutations: this.props.store.includeSomaticMutations = !this.props.store .includeSomaticMutations; break; case EVENT_KEY.showUnknownStatusMutations: this.props.store.includeUnknownStatusMutations = !this.props .store.includeUnknownStatusMutations; break; case EVENT_KEY.toggleAllMutationStatus: value = !this.isAnyMutationStatusOptionSelected; this.props.store.includeGermlineMutations = value; this.props.store.includeSomaticMutations = value; this.props.store.includeUnknownStatusMutations = value; break; case EVENT_KEY.toggleAllDriverAnnotation: value = !this.isAnyDriverAnnotationOptionSelected; this.props.store.driverAnnotationSettings.includeDriver = value; this.props.store.driverAnnotationSettings.includeVUS = value; this.props.store.driverAnnotationSettings.includeUnknownOncogenicity = value; break; case EVENT_KEY.toggleAllDriverTiers: if (this.driverSettingsState.customDriverAnnotationTiers) { value = !( this.driverSettingsState .anyCustomDriverAnnotationTiersSelected && this.props.store.driverAnnotationSettings .includeUnknownTier ); this.driverSettingsState.customDriverAnnotationTiers.forEach( t => this.driverSettingsHandlers .onSelectCustomDriverAnnotationTier && this.driverSettingsHandlers.onSelectCustomDriverAnnotationTier( t, value ) ); this.props.store.driverAnnotationSettings.includeUnknownTier = value; } break; case EVENT_KEY.showUnknownTier: if (this.driverSettingsState.customDriverAnnotationTiers) { this.props.store.driverAnnotationSettings.includeUnknownTier = !this .props.store.driverAnnotationSettings .includeUnknownTier; } break; } } @computed get isAnyMutationStatusOptionSelected() { return ( this.props.store.includeSomaticMutations || this.props.store.includeGermlineMutations || this.props.store.includeUnknownStatusMutations ); } @computed get isAnyDriverAnnotationOptionSelected() { return ( this.props.store.driverAnnotationSettings.includeDriver || this.props.store.driverAnnotationSettings.includeVUS || this.props.store.driverAnnotationSettings.includeUnknownOncogenicity ); } @computed get isAnyTierOptionSelected() { return !!( this.driverSettingsState.anyCustomDriverAnnotationTiersSelected || this.props.store.driverAnnotationSettings.includeUnknownTier ); } render() { if (this.props.disabled) { return (
Filtering based on annotations is not available for this study.
Load custom driver annotations for the selected study to enable filtering.
); } return (
{!!this.props.infoElement && this.props.infoElement}
Germline/Somatic status (mutations only) Germline/somatic annotations are based on data provided during study load.
For most studies Unknown status refers to somatic mutations. } />
{this.props.showDriverAnnotationSection && (
Driver Annotation Driver/passenger annotations are based on {' ' + this.props .customDriverSourceName || '' + ' '} data. } />
)} {this.props.showTierAnnotationSection && (
Categorical Annotation Alteration categories are based on {' ' + this.props .customDriverSourceName || '' + ' '} tier annotations. } />
)}
); } }