Skip to content

Commit 54d7c9a

Browse files
Merge branch 'develop' into feature/DEVSU-2824-add-mutation-signature-search
2 parents 76c0a01 + d0203c4 commit 54d7c9a

6 files changed

Lines changed: 46 additions & 2 deletions

File tree

app/libs/createReport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const createReportObservedVariantAnnotationSection = async (reportId, sectionCon
148148
variantType: record.variantType,
149149
variantId: record.variantId,
150150
annotations: record.annotations,
151+
flags: record.flags,
151152
};
152153

153154
const annotation = await db.models.observedVariantAnnotations.create({

app/models/reports/observedVariantAnnotations.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ module.exports = (sequelize, Sq) => {
3737
},
3838
},
3939
},
40+
flags: {
41+
name: 'flags',
42+
field: 'flags',
43+
type: Sq.ARRAY(Sq.TEXT),
44+
},
4045
}, {
4146
...DEFAULT_REPORT_OPTIONS,
4247
tableName: 'reports_observed_variant_annotations',

app/routes/report/observedVariantAnnotations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const createSchema = schemaGenerator(db.models.observedVariantAnnotations, {
2020
// we only want to allow updates to annotations
2121
const updateSchema = schemaGenerator(db.models.observedVariantAnnotations, {
2222
baseUri: REPORT_UPDATE_BASE_URI,
23-
required: ['annotations'],
23+
required: ['annotations', 'flags'],
2424
exclude: ['variantType', 'variantId', 'ident', 'createdAt'],
2525
});
2626

app/routes/report/variants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,11 @@ router.route('/set-summary-table/')
548548
if (!annotationMatch) {
549549
const newAnnotation = {...(annotation.annotations || {})};
550550
newAnnotation.rapidReportTableTag = req.body.rapidTable;
551+
const newFlags = req.body.flags ?? null;
551552
try {
552553
await db.models.observedVariantAnnotations.update({
553554
annotations: newAnnotation,
555+
flags: newFlags,
554556
}, {where: {id: annotation.id}});
555557
} catch (error) {
556558
logger.error(`Unable to create update observed variant annotation ${error}`);
@@ -566,6 +568,7 @@ router.route('/set-summary-table/')
566568
variantId: req.body.variantId,
567569
variantType: req.body.variantType,
568570
annotations: {rapidReportTableTag: req.body.rapidTable},
571+
flags: req.body.flags ?? null,
569572
reportId: req.report.id,
570573
});
571574
} catch (error) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const TABLE = 'reports_observed_variant_annotations';
2+
3+
module.exports = {
4+
async up(queryInterface, Sq) {
5+
return queryInterface.sequelize.transaction(async (transaction) => {
6+
await queryInterface.addColumn(
7+
TABLE,
8+
'flags',
9+
{
10+
type: Sq.ARRAY(Sq.TEXT),
11+
},
12+
{transaction},
13+
);
14+
});
15+
},
16+
17+
async down() {
18+
throw new Error('Not Implemented!');
19+
},
20+
};

test/routes/report/observedVariantAnnotations.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
101101
variantType: 'cnv',
102102
variantIdent: variant.ident,
103103
annotations: {rapidReportTableTag: 'cancerRelevance'},
104+
flags: ['test'],
104105
})
105106
.expect(StatusCodes.CREATED);
106107

107108
const checkVar = await getVariantByIdent(variant.ident, rapidReportIdent.ident);
108109
const annotation = checkVar.observedVariantAnnotation;
109110
expect(annotation.variantType).toEqual('cnv');
110111
expect(annotation.annotations.rapidReportTableTag).toEqual('cancerRelevance');
112+
expect(annotation.flags).toEqual(['test']);
111113
});
112114

113115
test('Does not create new annotation with no matching variant - OK', async () => {
@@ -119,6 +121,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
119121
variantType: 'mut',
120122
variantIdent: 'hello',
121123
annotations: {rapidReportTableTag: 'therapeuticAssociation'},
124+
flags: ['test'],
122125
})
123126
.expect(StatusCodes.BAD_REQUEST);
124127
});
@@ -132,6 +135,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
132135
variantType: 'test',
133136
variantIdent: 'hello',
134137
annotations: {rapidReportTableTag: 'therapeuticAssociation'},
138+
flags: ['test'],
135139
})
136140
.expect(StatusCodes.BAD_REQUEST);
137141
});
@@ -157,6 +161,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
157161
variantType: 'mut',
158162
variantIdent: variant.ident,
159163
annotations: {rapidReportTableTag: 'therapeuticAssociation'},
164+
flags: ['test'],
160165
})
161166
.expect(StatusCodes.CREATED);
162167

@@ -168,6 +173,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
168173
variantType: 'mut',
169174
variantIdent: variant.ident,
170175
annotations: {rapidReportTableTag: 'cancerRelevance'},
176+
flags: ['test'],
171177
})
172178
.expect(StatusCodes.CONFLICT);
173179
});
@@ -198,32 +204,36 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
198204
variantType: 'mut',
199205
variantIdent: origVariant.ident,
200206
annotations,
207+
flags: ['test'],
201208
})
202209
.expect(StatusCodes.CREATED);
203-
console.log('here in test at 205');
204210

205211
// get the created variant annotation and check it's correct
206212
const createdVar = await getVariantByIdent(origVariant.ident, rapidReportIdent.ident);
207213
expect(createdVar.observedVariantAnnotation.annotations.secondTag).toEqual(annotations.secondTag);
208214
expect(createdVar.observedVariantAnnotation.annotations.rapidReportTableTag).toEqual(annotations.rapidReportTableTag);
215+
expect(createdVar.observedVariantAnnotation.flags).toEqual(['test']);
209216

210217
// do the update
211218
const updatedSecondTag = 'testValue2';
212219
annotations.secondTag = updatedSecondTag;
220+
const updatedFlags = ['updated'];
213221

214222
await request
215223
.put(`/api/reports/${rapidReportIdent.ident}/observed-variant-annotations/${createdVar.observedVariantAnnotation.ident}`)
216224
.auth(username, password)
217225
.type('json')
218226
.send({
219227
annotations,
228+
flags: updatedFlags,
220229
})
221230
.expect(StatusCodes.OK);
222231

223232
// get the new variant data
224233
const updatedVar = await getVariantByIdent(origVariant.ident, rapidReportIdent.ident);
225234
expect(updatedVar.observedVariantAnnotation.annotations.secondTag).toEqual(updatedSecondTag);
226235
expect(updatedVar.observedVariantAnnotation.annotations.rapidReportTableTag).toEqual(annotations.rapidReportTableTag);
236+
expect(updatedVar.observedVariantAnnotation.flags).toEqual(updatedFlags);
227237
});
228238
});
229239

@@ -260,6 +270,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
260270
variantType,
261271
variantIdent: record.ident,
262272
annotations,
273+
flags: ['test'],
263274
})
264275
.expect(StatusCodes.CREATED);
265276

@@ -275,6 +286,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
275286
.expect(StatusCodes.OK);
276287
const record2 = res2.body;
277288
expect(record2.observedVariantAnnotation.annotations.testTag).toEqual(annotations.testTag);
289+
expect(record2.observedVariantAnnotation.flags).toEqual(['test']);
278290
});
279291

280292
test('Annotations delivered with variants endpt - OK', async () => {
@@ -305,6 +317,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
305317
variantType: record.variantType,
306318
variantIdent: record.ident,
307319
annotations,
320+
flags: ['test'],
308321
})
309322
.expect(StatusCodes.CREATED);
310323

@@ -317,6 +330,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
317330
return variant.ident === record.ident;
318331
})[0];
319332
expect(updatedRecord.observedVariantAnnotation.annotations.testTag).toEqual(annotations.testTag);
333+
expect(updatedRecord.observedVariantAnnotation.flags).toEqual(['test']);
320334
});
321335

322336
// skipping test as rapid report tagging now works through different endpoint
@@ -346,6 +360,7 @@ describe('/reports/{REPORTID}/observed-variant-annotations', () => {
346360
variantType: record.variantType,
347361
variantIdent: record.ident,
348362
annotations: {rapidReportTableTag: 'cancerRelevance', testTag: 'testValue'},
363+
flags: ['test'],
349364
})
350365
.expect(StatusCodes.CREATED);
351366

0 commit comments

Comments
 (0)