Skip to content

Commit

Permalink
Use appropriate genome-nexus url depending on study (#4787)
Browse files Browse the repository at this point in the history
Use appropriate genome-nexus url depending on reference genome build
  • Loading branch information
kalletlak committed Dec 5, 2023
1 parent 4bcbe7e commit 5a8b09f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
{
Expand All @@ -56,8 +62,10 @@ export default class GroupComparisonMutationMapperWrapper extends React.Componen
.uniqueSampleKeyToTumorType.result,
uniqueSampleKeyToCancerType: this.props.store
.uniqueSampleKeyToCancerType.result,
genomeBuild: genomeBuild,
}
);

return store;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ import { SiteError } from 'shared/model/appMisc';
export default class MutationMapperToolStore {
@observable mutationData: Partial<MutationInput>[] | undefined;
@observable criticalErrors: Error[] = [];
// if we use grch37(default), grch38GenomeNexusUrl will be undefined
@observable grch38GenomeNexusUrl: string | undefined = undefined;

readonly genes = remoteData<Gene[]>(
{
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 5a8b09f

Please sign in to comment.