Skip to content

Commit

Permalink
Merge pull request #3024 from alisman/separate-cache
Browse files Browse the repository at this point in the history
Add separate genome nexus cache for mutation assessor

Former-commit-id: e10f8e889b5bde02c5edd937a4c2870f0175f25e
  • Loading branch information
alisman authored Jan 30, 2020
2 parents d78b73a + a71b3fb commit 0a2245e
Show file tree
Hide file tree
Showing 18 changed files with 409 additions and 206 deletions.
5 changes: 5 additions & 0 deletions src/pages/patientView/PatientViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,11 @@ export default class PatientViewPage extends React.Component<
.patientViewPageStore
.genomeNexusCache
}
genomeNexusMutationAssessorCache={
this
.patientViewPageStore
.genomeNexusMutationAssessorCache
}
genomeNexusMyVariantInfoCache={
this
.patientViewPageStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import OncoKbEvidenceCache from 'shared/cache/OncoKbEvidenceCache';
import PubMedCache from 'shared/cache/PubMedCache';
import GenomeNexusCache from 'shared/cache/GenomeNexusCache';
import GenomeNexusMutationAssessorCache from 'shared/cache/GenomeNexusMutationAssessorCache';
import GenomeNexusMyVariantInfoCache from 'shared/cache/GenomeNexusMyVariantInfoCache';
import { IOncoKbData } from 'shared/model/OncoKB';
import { IHotspotIndex, indexHotspotsData } from 'react-mutation-mapper';
Expand Down Expand Up @@ -1391,6 +1392,10 @@ export class PatientViewPageStore {
return new GenomeNexusMyVariantInfoCache();
}

@cached get genomeNexusMutationAssessorCache() {
return new GenomeNexusMutationAssessorCache();
}

@cached get pubMedCache() {
return new PubMedCache();
}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { cached, labelMobxPromises, MobxPromise } from 'mobxpromise';
import OncoKbEvidenceCache from 'shared/cache/OncoKbEvidenceCache';
import PubMedCache from 'shared/cache/PubMedCache';
import GenomeNexusCache from 'shared/cache/GenomeNexusCache';
import GenomeNexusMutationAssessorCache from 'shared/cache/GenomeNexusMutationAssessorCache';
import GenomeNexusMyVariantInfoCache from 'shared/cache/GenomeNexusMyVariantInfoCache';
import CancerTypeCache from 'shared/cache/CancerTypeCache';
import MutationCountCache from 'shared/cache/MutationCountCache';
Expand Down Expand Up @@ -2958,6 +2959,7 @@ export class ResultsViewPageStore {
] || [],
() => this.mutationCountCache,
() => this.genomeNexusCache,
() => this.genomeNexusMutationAssessorCache,
() => this.genomeNexusMyVariantInfoCache,
() => this.discreteCNACache,
this.studyToMolecularProfileDiscrete.result!,
Expand Down Expand Up @@ -4870,6 +4872,10 @@ export class ResultsViewPageStore {
return new GenomeNexusCache();
}

@cached get genomeNexusMutationAssessorCache() {
return new GenomeNexusMutationAssessorCache();
}

@cached get genomeNexusMyVariantInfoCache() {
return new GenomeNexusMyVariantInfoCache();
}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/resultsView/mutation/Mutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export default class Mutations extends React.Component<
this.props.store.mutationCountCache
}
genomeNexusCache={this.props.store.genomeNexusCache}
genomeNexusMutationAssessorCache={
this.props.store
.genomeNexusMutationAssessorCache
}
genomeNexusMyVariantInfoCache={
this.props.store.genomeNexusMyVariantInfoCache
}
Expand Down
3 changes: 3 additions & 0 deletions src/pages/resultsView/mutation/ResultsViewMutationMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ export default class ResultsViewMutationMapper extends MutationMapper<
pubMedCache={this.props.pubMedCache}
mutationCountCache={this.props.mutationCountCache}
genomeNexusCache={this.props.genomeNexusCache}
genomeNexusMutationAssessorCache={
this.props.genomeNexusMutationAssessorCache
}
genomeNexusMyVariantInfoCache={
this.props.genomeNexusMyVariantInfoCache
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import MutationCountCache from 'shared/cache/MutationCountCache';
import DiscreteCNACache from 'shared/cache/DiscreteCNACache';
import GenomeNexusCache from 'shared/cache/GenomeNexusCache';
import GenomeNexusMutationAssessorCache from 'shared/cache/GenomeNexusMutationAssessorCache';
import GenomeNexusMyVariantInfoCache from 'shared/cache/GenomeNexusMyVariantInfoCache';
import { MutationTableDownloadDataFetcher } from 'shared/lib/MutationTableDownloadDataFetcher';
import MutationMapperStore, {
Expand All @@ -47,6 +48,7 @@ export default class ResultsViewMutationMapperStore extends MutationMapperStore
getMutations: () => Mutation[],
private getMutationCountCache: () => MutationCountCache,
private getGenomeNexusCache: () => GenomeNexusCache,
private getGenomeNexusMutationAssessorCache: () => GenomeNexusMutationAssessorCache,
private getGenomeNexusMyVariantInfoCache: () => GenomeNexusMyVariantInfoCache,
private getDiscreteCNACache: () => DiscreteCNACache,
public studyToMolecularProfileDiscrete: {
Expand Down Expand Up @@ -132,6 +134,7 @@ export default class ResultsViewMutationMapperStore extends MutationMapperStore
this.mutationData,
this.studyToMolecularProfileDiscrete,
this.getGenomeNexusCache,
this.getGenomeNexusMutationAssessorCache,
this.getGenomeNexusMyVariantInfoCache,
this.getMutationCountCache,
this.getDiscreteCNACache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ export default class MutationMapperTool extends React.Component<
}
downloadDataFetcher={this.store.downloadDataFetcher}
genomeNexusCache={this.store.genomeNexusCache}
genomeNexusMutationAssessorCache={
this.store.genomeNexusMutationAssessorCache
}
genomeNexusMyVariantInfoCache={
this.store.genomeNexusMyVariantInfoCache
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { fetchHotspotsData } from 'shared/lib/CancerHotspotsUtils';
import OncoKbEvidenceCache from 'shared/cache/OncoKbEvidenceCache';
import PubMedCache from 'shared/cache/PubMedCache';
import GenomeNexusCache from 'shared/cache/GenomeNexusCache';
import GenomeNexusMutationAssessorCache from 'shared/cache/GenomeNexusMutationAssessorCache';
import GenomeNexusMyVariantInfoCache from 'shared/cache/GenomeNexusMyVariantInfoCache';
import PdbHeaderCache from 'shared/cache/PdbHeaderCache';
import MutationMapperStore from 'shared/components/mutationMapper/MutationMapperStore';
Expand Down Expand Up @@ -380,6 +381,10 @@ export default class MutationMapperToolStore {
return new GenomeNexusCache();
}

@cached get genomeNexusMutationAssessorCache() {
return new GenomeNexusMutationAssessorCache();
}

@cached get genomeNexusMyVariantInfoCache() {
return new GenomeNexusMyVariantInfoCache();
}
Expand All @@ -397,6 +402,7 @@ export default class MutationMapperToolStore {
this.mutations,
undefined,
() => this.genomeNexusCache,
() => this.genomeNexusMutationAssessorCache,
() => this.genomeNexusMyVariantInfoCache
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export default class StandaloneMutationMapper extends MutationMapper<
this.props.store.indexedVariantAnnotations
}
genomeNexusCache={this.props.genomeNexusCache}
genomeNexusMutationAssessorCache={
this.props.genomeNexusMutationAssessorCache
}
genomeNexusMyVariantInfoCache={
this.props.genomeNexusMyVariantInfoCache
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/cache/GenomeNexusCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function fetch(queries: Mutation[]): Promise<VariantAnnotation[]> {
if (queries.length > 0) {
return fetchVariantAnnotationsByMutation(
queries,
['annotation_summary', 'mutation_assessor'],
['annotation_summary'],
AppConfig.serverConfig.isoformOverrideSource
);
} else {
Expand Down
49 changes: 49 additions & 0 deletions src/shared/cache/GenomeNexusMutationAssessorCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as _ from 'lodash';
import { fetchVariantAnnotationsByMutation } from 'shared/lib/StoreUtils';
import {
extractGenomicLocation,
genomicLocationString,
} from 'shared/lib/MutationUtils';
import { Mutation } from 'shared/api/generated/CBioPortalAPI';
import LazyMobXCache, { CacheData } from 'shared/lib/LazyMobXCache';
import AppConfig from 'appConfig';
import { VariantAnnotation } from 'cbioportal-frontend-commons';

export type GenomeNexusCacheDataType = CacheData<VariantAnnotation>;

export function fetch(queries: Mutation[]): Promise<VariantAnnotation[]> {
if (queries.length > 0) {
return fetchVariantAnnotationsByMutation(
queries,
['annotation_summary', 'mutation_assessor'],
AppConfig.serverConfig.isoformOverrideSource
);
} else {
return Promise.resolve([]);
}
}

export function queryToKey(m: Mutation) {
const genomicLocation = extractGenomicLocation(m);
if (genomicLocation) {
return genomicLocationString(genomicLocation);
} else {
// TODO: might be a better way to handle mutations w/o genomic location
// info. They should maybe not be fed to the cache in the first place
return '';
}
}

export default class GenomeNexusMutationAssessorCache extends LazyMobXCache<
VariantAnnotation,
Mutation
> {
constructor() {
super(
(m: Mutation) => queryToKey(m), // queryToKey
(v: VariantAnnotation) =>
genomicLocationString(v.annotation_summary.genomicLocation), // dataToKey
fetch
);
}
}
Loading

0 comments on commit 0a2245e

Please sign in to comment.