Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/routes/report/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,18 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
const unknownSignificanceFromAnnotation = [];
const unknownSignificanceFromGeneProperty = [];
const doNotReport = [];
const doNotReportIdents = new Set();

Comment thread
Copilot marked this conversation as resolved.
Outdated
const tumourSuppressorLofVariants = {};

// separate out variants that qualify based on gene properties alone, if filtering for table 3
if (rapidTable === 'unknownSignificance') {
for (const variant of allKbMatches) {
if (variant?.observedVariantAnnotation?.annotations?.rapidReportTableTag === 'noTable') {
doNotReport.push(variant);
doNotReportIdents.add(variant.ident);
continue;
}
if (variant.gene.cancerGeneListMatch
|| variant.gene.oncogene
|| variant.gene.tumourSuppressor) {
Expand Down Expand Up @@ -180,7 +186,9 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
} else if (tableTag === 'unknownSignificance') {
unknownSignificanceFromAnnotation.push(variant);
} else if (tableTag === 'noTable') {
console.log(`Variant ${variant.ident} is tagged as noTable, will not be reported`);
doNotReport.push(variant);
doNotReportIdents.add(variant.ident);
}
}
}
Expand Down Expand Up @@ -356,7 +364,7 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
const existingVariants = new Set(unknownSignificanceResults.map((variant) => {return variant.ident;}));

unknownSignificanceFromGeneProperty.forEach((variant) => {
if (!existingVariants.has(variant.ident)) {
if (!existingVariants.has(variant.ident) && !doNotReportIdents.has(variant.ident)) {
unknownSignificanceResults.push(variant);
existingVariants.add(variant.ident);
}
Expand All @@ -377,7 +385,9 @@ const getRapidReportVariants = async (tableName, variantType, reportId, rapidTab
// reason there may be to exclude them
unknownSignificanceResultsFiltered.push(...unknownSignificanceFromAnnotation);

return unknownSignificanceResultsFiltered;
return unknownSignificanceResultsFiltered.filter((variant) => {
return !doNotReportIdents.has(variant.ident);
});
};

const updateKbDataSummaryTableTag = (kbData, rapidTable, variantType, variantIdent) => {
Expand Down
33 changes: 33 additions & 0 deletions test/routes/report/variants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,39 @@ describe('/reports/{REPORTID}/variants', () => {
await db.models.report.destroy({where: {ident: reportIdent.ident}});
});

test('Variants tagged noTable stay out of table 3 even when gene properties qualify and there are no kbmatches - OK', async () => {
const newMockReportData = JSON.parse(JSON.stringify(mockReportData));
newMockReportData.genes = newMockReportData.genes.concat([
{name: 'TA5gene', oncogene: true},
]);
newMockReportData.smallMutations = newMockReportData.smallMutations.concat([{
gene: 'TA5gene',
key: 'TA5',
displayName: 'TA5',
}]);

const reportIdent = await createReport(newMockReportData);

const ta5Variant = await db.models.smallMutations.findOne({
where: {
reportId: reportIdent.id,
displayName: 'TA5',
},
});

await db.models.observedVariantAnnotations.create({
variantId: ta5Variant.id,
variantType: 'mut',
annotations: {rapidReportTableTag: 'noTable'},
reportId: reportIdent.id,
});

const table = await checkRapidReportTable(reportIdent.ident, 'TA5', 'mut');
expect(table).toBe('noTable');

await db.models.report.destroy({where: {ident: reportIdent.ident}});
});

test('LOF promotion: Qualifying mutation-type matches promoted if lof variant on tumour suppressor gene found - OK', async () => {
// TA1 - expect lof promotion to occur - table 1
const newMockReportData = JSON.parse(JSON.stringify(mockReportData));
Expand Down
Loading