Skip to content

Commit

Permalink
Merge pull request #1204 from onursumer/oncokb-error-catch
Browse files Browse the repository at this point in the history
Suppressing oncokb data fetch errors

Former-commit-id: b9e2fdc
  • Loading branch information
alisman authored Jun 1, 2018
2 parents e3a7369 + d6724bc commit 0d1fb84
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
fetchMutSigData, findMrnaRankMolecularProfileId, mergeDiscreteCNAData, fetchSamplesForPatient, fetchClinicalData,
fetchCopyNumberSegments, fetchClinicalDataForPatient, makeStudyToCancerTypeMap,
fetchCivicGenes, fetchCnaCivicGenes, fetchCivicVariants, groupBySampleId, findSamplesWithoutCancerTypeClinicalData,
fetchStudiesForSamplesWithoutCancerTypeClinicalData, fetchOncoKbAnnotatedGenes
fetchStudiesForSamplesWithoutCancerTypeClinicalData, fetchOncoKbAnnotatedGenesSuppressErrors
} from "shared/lib/StoreUtils";
import {indexHotspotsData, fetchHotspotsData} from "shared/lib/CancerHotspotsUtils";
import {stringListToSet} from "../../../shared/lib/StringUtils";
Expand Down Expand Up @@ -497,13 +497,10 @@ export class PatientViewPageStore {
}, []);

readonly oncoKbAnnotatedGenes = remoteData({
invoke:()=>fetchOncoKbAnnotatedGenes(),
onError: (err: Error) => {
// fail silently, leave the error handling responsibility to the data consumer
}
invoke:()=>fetchOncoKbAnnotatedGenesSuppressErrors()
}, {});

readonly oncoKbData = remoteData<IOncoKbData>({
readonly oncoKbData = remoteData<IOncoKbData|Error>({
await: () => [
this.oncoKbAnnotatedGenes,
this.mutationData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ICopyNumberTableWrapperProps = {
cnaCivicGenes?: ICivicGeneDataWrapper;
cnaCivicVariants?: ICivicVariantDataWrapper;
oncoKbEvidenceCache?:OncoKbEvidenceCache;
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean};
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error;
enableOncoKb?:boolean;
enableCivic?:boolean;
pubMedCache?:PubMedCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {buildCivicEntry, getCivicCNAVariants} from "shared/lib/CivicUtils";
export default class AnnotationColumnFormatter
{
public static getData(copyNumberData:DiscreteCopyNumberData[]|undefined,
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean},
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error,
oncoKbData?: IOncoKbDataWrapper,
civicGenes?: ICivicGeneDataWrapper,
civicVariants?: ICivicVariantDataWrapper)
Expand All @@ -31,10 +31,20 @@ export default class AnnotationColumnFormatter
let oncoKbIndicator: IndicatorQueryResp|undefined = undefined;
let oncoKbStatus:IAnnotation["oncoKbStatus"] = "complete";
let hugoGeneSymbol = copyNumberData[0].gene.hugoGeneSymbol;
const oncoKbGeneExist = !!oncoKbAnnotatedGenes[copyNumberData[0].entrezGeneId];
const oncoKbGeneExist = !(oncoKbAnnotatedGenes instanceof Error) && !!oncoKbAnnotatedGenes[copyNumberData[0].entrezGeneId];

if (oncoKbGeneExist) {
if (oncoKbData && oncoKbData.result && oncoKbData.status === "complete") {
// oncoKbData may exist but it might be an instance of Error, in that case we flag the status as error
if (oncoKbData && oncoKbData.result instanceof Error) {
oncoKbStatus = "error";
}
else if (oncoKbGeneExist) {
// actually, oncoKbData.result shouldn't be an instance of Error in this case (we already check it above),
// but we need to check it again in order to avoid TS errors/warnings
if (oncoKbData &&
oncoKbData.result &&
!(oncoKbData.result instanceof Error) &&
oncoKbData.status === "complete")
{
oncoKbIndicator = AnnotationColumnFormatter.getIndicatorData(copyNumberData, oncoKbData.result);
}
oncoKbStatus = oncoKbData ? oncoKbData.status : "pending";
Expand Down Expand Up @@ -132,7 +142,7 @@ export default class AnnotationColumnFormatter
}

public static sortValue(data:DiscreteCopyNumberData[],
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean},
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error,
oncoKbData?: IOncoKbDataWrapper,
civicGenes?: ICivicGeneDataWrapper,
civicVariants?: ICivicVariantDataWrapper):number[] {
Expand All @@ -148,7 +158,10 @@ export default class AnnotationColumnFormatter

let evidenceQuery:Query|undefined;

if (columnProps.oncoKbData && columnProps.oncoKbData.result) {
if (columnProps.oncoKbData &&
columnProps.oncoKbData.result &&
!(columnProps.oncoKbData.result instanceof Error))
{
evidenceQuery = this.getEvidenceQuery(data, columnProps.oncoKbData.result);
}

Expand Down
9 changes: 3 additions & 6 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
fetchDiscreteCNAData, findMutationMolecularProfileId, mergeDiscreteCNAData,
fetchSamples, fetchClinicalDataInStudy, generateDataQueryFilter,
fetchSamplesWithoutCancerTypeClinicalData, fetchStudiesForSamplesWithoutCancerTypeClinicalData, IDataQueryFilter,
isMutationProfile, fetchOncoKbAnnotatedGenes, groupBy, fetchOncoKbData,
isMutationProfile, fetchOncoKbAnnotatedGenesSuppressErrors, groupBy, fetchOncoKbData,
ONCOKB_DEFAULT, generateUniqueSampleKeyToTumorTypeMap, cancerTypeForOncoKb, fetchCnaOncoKbData,
fetchCnaOncoKbDataWithNumericGeneMolecularData, fetchGermlineConsentedSamples
} from "shared/lib/StoreUtils";
Expand Down Expand Up @@ -1000,10 +1000,7 @@ export class ResultsViewPageStore {
}

readonly oncoKbAnnotatedGenes = remoteData({
invoke:()=>fetchOncoKbAnnotatedGenes(),
onError: (err: Error) => {
// fail silently, leave the error handling responsibility to the data consumer
}
invoke:()=>fetchOncoKbAnnotatedGenesSuppressErrors()
}, {});

readonly clinicalDataForSamples = remoteData<ClinicalData[]>({
Expand Down Expand Up @@ -1579,7 +1576,7 @@ export class ResultsViewPageStore {
}
});

readonly oncoKbData = remoteData<IOncoKbData>({
readonly oncoKbData = remoteData<IOncoKbData|Error>({
await: () => [
this.mutations,
this.clinicalDataForSamples,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface IAnnotationColumnProps {
myCancerGenomeData?: IMyCancerGenomeData;
oncoKbData?: IOncoKbDataWrapper;
oncoKbEvidenceCache?: OncoKbEvidenceCache;
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean};
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error;
pubMedCache?: OncokbPubMedCache;
userEmailAddress?:string;
civicGenes?: ICivicGeneDataWrapper;
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class AnnotationColumnFormatter
}

public static getData(rowData:Mutation[]|undefined,
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean},
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error,
hotspotData?:IHotspotDataWrapper,
myCancerGenomeData?:IMyCancerGenomeData,
oncoKbData?:IOncoKbDataWrapper,
Expand All @@ -83,7 +83,7 @@ export default class AnnotationColumnFormatter
let oncoKbIndicator: IndicatorQueryResp|undefined;
let hugoGeneSymbol = mutation.gene.hugoGeneSymbol;

const oncoKbGeneExist = !!oncoKbAnnotatedGenes[mutation.entrezGeneId];
const oncoKbGeneExist = !(oncoKbAnnotatedGenes instanceof Error) && !!oncoKbAnnotatedGenes[mutation.entrezGeneId];

value = {
hugoGeneSymbol,
Expand All @@ -101,8 +101,23 @@ export default class AnnotationColumnFormatter
is3dHotspot(mutation, hotspotData.result) : false,
hotspotStatus: hotspotData ? hotspotData.status : "pending"
};
if (oncoKbGeneExist) {
if (oncoKbData && oncoKbData.result && oncoKbData.status === "complete") {

// oncoKbData may exist but it might be an instance of Error, in that case we flag the status as error
if (oncoKbData && oncoKbData.result instanceof Error) {
value = {
...value,
oncoKbStatus: "error",
oncoKbIndicator: undefined
};
}
else if (oncoKbGeneExist) {
// actually, oncoKbData.result shouldn't be an instance of Error in this case (we already check it above),
// but we need to check it again in order to avoid TS errors/warnings
if (oncoKbData &&
oncoKbData.result &&
!(oncoKbData.result instanceof Error) &&
oncoKbData.status === "complete")
{
oncoKbIndicator = AnnotationColumnFormatter.getIndicatorData(mutation, oncoKbData.result);
}

Expand Down Expand Up @@ -217,7 +232,7 @@ export default class AnnotationColumnFormatter
}

public static sortValue(data:Mutation[],
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean},
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error,
hotspotData?: IHotspotDataWrapper,
myCancerGenomeData?:IMyCancerGenomeData,
oncoKbData?: IOncoKbDataWrapper,
Expand All @@ -235,7 +250,7 @@ export default class AnnotationColumnFormatter
}

public static download(data:Mutation[]|undefined,
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean},
oncoKbAnnotatedGenes:{[entrezGeneId:number]:boolean}|Error,
hotspotData?:IHotspotDataWrapper,
myCancerGenomeData?:IMyCancerGenomeData,
oncoKbData?:IOncoKbDataWrapper,
Expand Down Expand Up @@ -267,7 +282,10 @@ export default class AnnotationColumnFormatter

let evidenceQuery:Query|undefined;

if (columnProps.oncoKbData && columnProps.oncoKbData.result) {
if (columnProps.oncoKbData &&
columnProps.oncoKbData.result &&
!(columnProps.oncoKbData.result instanceof Error))
{
evidenceQuery = this.getEvidenceQuery(data[0], columnProps.oncoKbData.result);
}

Expand Down
18 changes: 16 additions & 2 deletions src/shared/lib/StoreUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,29 @@ export async function fetchOncoKbAnnotatedGenes(client: OncoKbAPI = oncokbClient
}, {});
}

export async function fetchOncoKbAnnotatedGenesSuppressErrors(client: OncoKbAPI = oncokbClient): Promise<{[entrezGeneId:number]:boolean}|Error>
{
// we want to catch the error and fail silently with an empty result set,
// because we don't want other MobXPromises depending on this data to fail in case of an error
try {
return await fetchOncoKbAnnotatedGenes(client);
} catch (e) {
return new Error();
}
}

export async function fetchOncoKbData(uniqueSampleKeyToTumorType:{[uniqueSampleKey: string]: string},
annotatedGenes:{[entrezGeneId:number]:boolean},
annotatedGenes:{[entrezGeneId:number]:boolean}|Error,
mutationData:MobxPromise<Mutation[]>,
uncalledMutationData?:MobxPromise<Mutation[]>,
client: OncoKbAPI = oncokbClient)
{
const mutationDataResult = concatMutationData(mutationData, uncalledMutationData);

if (mutationDataResult.length === 0) {
if (annotatedGenes instanceof Error) {
return new Error();
}
else if (mutationDataResult.length === 0) {
return ONCOKB_DEFAULT;
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/model/OncoKB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export interface IOncoKbData {

export interface IOncoKbDataWrapper {
status: "pending" | "error" | "complete";
result?: IOncoKbData;
result?: IOncoKbData|Error;
}

0 comments on commit 0d1fb84

Please sign in to comment.