-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3024 from alisman/separate-cache
Add separate genome nexus cache for mutation assessor Former-commit-id: e10f8e889b5bde02c5edd937a4c2870f0175f25e
- Loading branch information
Showing
18 changed files
with
409 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |
Oops, something went wrong.