Skip to content

Commit 8578a49

Browse files
authored
Merge pull request #468 from bcgsc/bugfix/DEVSU-2539-include-nonkbmatched-variants-in-table3
Bugfix/devsu 2539 include nonkbmatched variants in table3
2 parents 17a3ebe + 5da62fb commit 8578a49

2 files changed

Lines changed: 104 additions & 14 deletions

File tree

app/routes/report/variants.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ const geneLinkedVariantTypes = ['mut', 'cnv', 'exp'];
4747
const getRapidReportVariants = async (tableName, variantType, reportId, rapidTable) => {
4848
let allKbMatches;
4949

50+
const kbmatchJoin = {
51+
model: db.models.kbMatches,
52+
attributes: {exclude: KBMATCHEXCLUDE},
53+
include: [
54+
{
55+
model: db.models.kbMatchedStatements,
56+
as: 'kbMatchedStatements',
57+
attributes: {
58+
exclude: STATEMENTEXCLUDE,
59+
},
60+
through: {attributes: ['flags']},
61+
},
62+
],
63+
};
64+
65+
// get variants that don't have kbmatches in the unknownSignificance table (if gene check passes)
66+
if (rapidTable === 'unknownSignificance') {
67+
kbmatchJoin.required = false;
68+
}
69+
5070
const query = {
5171
order: [['id', 'ASC']],
5272
attributes: {
@@ -56,20 +76,7 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
5676
reportId,
5777
},
5878
include: [
59-
{
60-
model: db.models.kbMatches,
61-
attributes: {exclude: KBMATCHEXCLUDE},
62-
include: [
63-
{
64-
model: db.models.kbMatchedStatements,
65-
as: 'kbMatchedStatements',
66-
attributes: {
67-
exclude: STATEMENTEXCLUDE,
68-
},
69-
through: {attributes: ['flags']},
70-
},
71-
],
72-
},
79+
kbmatchJoin,
7380
{
7481
model: db.models.observedVariantAnnotations,
7582
attributes: {exclude: OBSVARANNOTEXCLUDE},
@@ -107,10 +114,26 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
107114
const therapeuticResultsFromAnnotation = [];
108115
const cancerRelevanceResultsFromAnnotation = [];
109116
const unknownSignificanceFromAnnotation = [];
117+
const unknownSignificanceFromGeneProperty = [];
110118
const doNotReport = [];
111119

112120
const tumourSuppressorLofVariants = {};
113121

122+
// separate out variants that qualify based on gene properties alone, if filtering for table 3
123+
if (rapidTable === 'unknownSignificance') {
124+
for (const variant of allKbMatches) {
125+
if (variant.gene.cancerGeneListMatch
126+
|| variant.gene.oncogene
127+
|| variant.gene.tumourSuppressor) {
128+
unknownSignificanceFromGeneProperty.push(variant);
129+
}
130+
}
131+
}
132+
// remove the kbmatch-less variants from further sorting
133+
allKbMatches = allKbMatches.filter((variant) => {
134+
return (variant.kbMatches.length > 0);
135+
});
136+
114137
for (const variant of allKbMatches) {
115138
// check whether the variant has LOF effect on tumour suppressor gene
116139
const tumourSuppressorLof = variant.kbMatches.some((kbmatch) => {
@@ -327,6 +350,11 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
327350
unknownSignificanceResults = unknownSignificanceResults.filter((variant) => {
328351
return variant.kbMatches.length > 0;
329352
});
353+
354+
// add variants back to unknownSig list, that are tagged for this table based on gene properties alone
355+
// so that they can be filtered out of results if they are in TA or CR
356+
unknownSignificanceResults.push(...unknownSignificanceFromGeneProperty);
357+
330358
// remove variants already included in a different section
331359
for (const row of unknownSignificanceResults) {
332360
if (!(therapeuticAssociationResults.find(
@@ -341,6 +369,7 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
341369
// add variants that are tagged for this table regardless of whatever other
342370
// reason there may be to exclude them
343371
unknownSignificanceResultsFiltered.push(...unknownSignificanceFromAnnotation);
372+
344373
return unknownSignificanceResultsFiltered;
345374
};
346375

test/routes/report/variants.test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,67 @@ describe('/reports/{REPORTID}/variants', () => {
843843
await db.models.report.destroy({where: {ident: reportIdent.ident}});
844844
});
845845

846+
test('Variants with no kbmatches can be put in table 3 if gene is tumourSuppressor, cancergenelist or oncogene - OK', async () => {
847+
const newMockReportData = JSON.parse(JSON.stringify(mockReportData));
848+
newMockReportData.genes = newMockReportData.genes.concat([
849+
{name: 'TA4agene', oncogene: true},
850+
{name: 'TA4bgene', cancerGeneListMatch: true},
851+
{name: 'TA4cgene', tumourSuppressor: true},
852+
{name: 'TA4dgene'},
853+
{name: 'TA4egene', oncogene: true},
854+
]);
855+
newMockReportData.smallMutations = newMockReportData.smallMutations.concat([{
856+
gene: 'TA4agene',
857+
key: 'TA4a',
858+
displayName: 'TA4a',
859+
},
860+
{
861+
gene: 'TA4bgene',
862+
key: 'TA4b',
863+
displayName: 'TA4b',
864+
},
865+
{
866+
gene: 'TA4cgene',
867+
key: 'TA4c',
868+
displayName: 'TA4c',
869+
},
870+
{
871+
gene: 'TA4dgene',
872+
key: 'TA4d',
873+
displayName: 'TA4d',
874+
},
875+
{
876+
gene: 'TA4egene',
877+
key: 'TA4e',
878+
displayName: 'TA4e',
879+
}]);
880+
newMockReportData.kbMatches = newMockReportData.kbMatches.concat([{
881+
category: 'therapeutic',
882+
variantType: 'mut',
883+
variant: 'TA4e',
884+
iprEvidenceLevel: 'IPR-A',
885+
kbVariant: 'TA4e specific',
886+
matchedCancer: true,
887+
relevance: 'resistance',
888+
kbVariantId: '#33',
889+
kbStatementId: '#33',
890+
}]);
891+
const reportIdent = await createReport(newMockReportData);
892+
893+
let table = await checkRapidReportTable(reportIdent.ident, 'TA4a', 'mut');
894+
expect(table).toBe('unknownSignificance');
895+
table = await checkRapidReportTable(reportIdent.ident, 'TA4b', 'mut');
896+
expect(table).toBe('unknownSignificance');
897+
table = await checkRapidReportTable(reportIdent.ident, 'TA4c', 'mut');
898+
expect(table).toBe('unknownSignificance');
899+
table = await checkRapidReportTable(reportIdent.ident, 'TA4d', 'mut');
900+
expect(table).toBe('noTable'); // don't put in table 3 if not qualifying
901+
table = await checkRapidReportTable(reportIdent.ident, 'TA4e', 'mut');
902+
expect(table).toBe('therapeuticAssociation'); // don't skip table 1 if qualifying for table 1
903+
904+
await db.models.report.destroy({where: {ident: reportIdent.ident}});
905+
});
906+
846907
test('LOF promotion: Qualifying mutation-type matches promoted if lof variant on tumour suppressor gene found - OK', async () => {
847908
// TA1 - expect lof promotion to occur - table 1
848909
const newMockReportData = JSON.parse(JSON.stringify(mockReportData));

0 commit comments

Comments
 (0)