From 5a8b09f5bb71db019e2cb1663205f5387dd179a9 Mon Sep 17 00:00:00 2001 From: Karthik K Date: Tue, 5 Dec 2023 13:27:31 -0500 Subject: [PATCH] Use appropriate genome-nexus url depending on study (#4787) Use appropriate genome-nexus url depending on reference genome build --- .../GroupComparisonMutationMapperWrapper.tsx | 10 ++++- .../mutationMapper/MutationMapperTool.tsx | 11 +++-- .../mutationMapper/MutationMapperToolStore.ts | 43 ++++++++++++------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/pages/groupComparison/GroupComparisonMutationMapperWrapper.tsx b/src/pages/groupComparison/GroupComparisonMutationMapperWrapper.tsx index d6b76cb0aab..793701116fb 100644 --- a/src/pages/groupComparison/GroupComparisonMutationMapperWrapper.tsx +++ b/src/pages/groupComparison/GroupComparisonMutationMapperWrapper.tsx @@ -22,7 +22,10 @@ import { LollipopTooltipCountInfo } from './LollipopTooltipCountInfo'; import MutationMapperUserSelectionStore from 'shared/components/mutationMapper/MutationMapperUserSelectionStore'; import styles from './styles.module.scss'; import { saveOncoKbIconStyleToLocalStorage } from 'shared/lib/AnnotationColumnUtils'; -import { generateMutationIdByGeneAndProteinChange } from 'shared/lib/StoreUtils'; +import { + generateMutationIdByGeneAndProteinChange, + getGenomeBuildFromStudies, +} from 'shared/lib/StoreUtils'; interface IGroupComparisonMutationMapperWrapperProps { store: GroupComparisonStore; @@ -45,6 +48,9 @@ export default class GroupComparisonMutationMapperWrapper extends React.Componen } @computed get mutationMapperToolStore() { + const genomeBuild = getGenomeBuildFromStudies( + this.props.store.studies.result + ); const store = new MutationMapperToolStore( this.props.store.filteredAndAnnotatedMutations.result, { @@ -56,8 +62,10 @@ export default class GroupComparisonMutationMapperWrapper extends React.Componen .uniqueSampleKeyToTumorType.result, uniqueSampleKeyToCancerType: this.props.store .uniqueSampleKeyToCancerType.result, + genomeBuild: genomeBuild, } ); + return store; } diff --git a/src/pages/staticPages/tools/mutationMapper/MutationMapperTool.tsx b/src/pages/staticPages/tools/mutationMapper/MutationMapperTool.tsx index ffce23fa108..315a1fbe42b 100644 --- a/src/pages/staticPages/tools/mutationMapper/MutationMapperTool.tsx +++ b/src/pages/staticPages/tools/mutationMapper/MutationMapperTool.tsx @@ -59,7 +59,10 @@ export default class MutationMapperTool extends React.Component< @observable.ref lastParsedInputContent: string | undefined = undefined; @observable referenceGenomeSelection: string = REFERENCE_GENOME.grch37.NCBI; - private store: MutationMapperToolStore = new MutationMapperToolStore(); + private store: MutationMapperToolStore = new MutationMapperToolStore( + undefined, + { genomeBuild: REFERENCE_GENOME.grch37.NCBI } + ); constructor(props: IMutationMapperToolProps) { super(props); @@ -73,9 +76,9 @@ export default class MutationMapperTool extends React.Component< getBrowserWindow().localStorage.getItem('referenceGenomeId') === REFERENCE_GENOME.grch38.NCBI ) { - this.store.setGenomeNexusUrl( - getServerConfig().genomenexus_url_grch38! - ); + this.store = new MutationMapperToolStore(undefined, { + genomeBuild: REFERENCE_GENOME.grch38.UCSC, + }); this.referenceGenomeSelection = REFERENCE_GENOME.grch38.NCBI; } diff --git a/src/pages/staticPages/tools/mutationMapper/MutationMapperToolStore.ts b/src/pages/staticPages/tools/mutationMapper/MutationMapperToolStore.ts index 96ce5075e49..d3c94099854 100644 --- a/src/pages/staticPages/tools/mutationMapper/MutationMapperToolStore.ts +++ b/src/pages/staticPages/tools/mutationMapper/MutationMapperToolStore.ts @@ -60,8 +60,6 @@ import { SiteError } from 'shared/model/appMisc'; export default class MutationMapperToolStore { @observable mutationData: Partial[] | undefined; @observable criticalErrors: Error[] = []; - // if we use grch37(default), grch38GenomeNexusUrl will be undefined - @observable grch38GenomeNexusUrl: string | undefined = undefined; readonly genes = remoteData( { @@ -107,9 +105,15 @@ export default class MutationMapperToolStore { } @computed get genomeNexusClient() { - const client = this.grch38GenomeNexusUrl - ? new GenomeNexusAPI(this.grch38GenomeNexusUrl) - : defaultGenomeNexusClient; + let client = defaultGenomeNexusClient; + if ( + this.mutationMapperStoreConfigOverride?.genomeBuild === + REFERENCE_GENOME.grch38.UCSC + ) { + client = new GenomeNexusAPI( + getServerConfig().genomenexus_url_grch38! + ); + } client.addErrorHandler(err => { eventBus.emit( @@ -126,9 +130,15 @@ export default class MutationMapperToolStore { } @computed get genomeNexusInternalClient() { - const client = this.grch38GenomeNexusUrl - ? new GenomeNexusAPIInternal(this.grch38GenomeNexusUrl) - : defaultGenomeNexusInternalClient; + let client = defaultGenomeNexusInternalClient; + if ( + this.mutationMapperStoreConfigOverride?.genomeBuild === + REFERENCE_GENOME.grch38.UCSC + ) { + client = new GenomeNexusAPIInternal( + getServerConfig().genomenexus_url_grch38! + ); + } client.addErrorHandler(err => { eventBus.emit( @@ -349,9 +359,11 @@ export default class MutationMapperToolStore { { filterMutationsBySelectedTranscript: !this .hasInputWithProteinChanges, - genomeBuild: this.grch38GenomeNexusUrl - ? REFERENCE_GENOME.grch38.UCSC - : REFERENCE_GENOME.grch37.UCSC, + genomeBuild: + this + .mutationMapperStoreConfigOverride + ?.genomeBuild || + REFERENCE_GENOME.grch37.UCSC, ...this .mutationMapperStoreConfigOverride, }, @@ -446,13 +458,12 @@ export default class MutationMapperToolStore { ); } - public setGenomeNexusUrl(grch38GenomeNexusUrl: string | undefined) { - this.grch38GenomeNexusUrl = grch38GenomeNexusUrl; - } - @autobind generateGenomeNexusHgvsgUrl(hgvsg: string) { - return getGenomeNexusHgvsgUrl(hgvsg, this.grch38GenomeNexusUrl); + return getGenomeNexusHgvsgUrl( + hgvsg, + this.genomeNexusClient.getDomain() + ); } @cached @computed get pubMedCache() {