Skip to content

Commit

Permalink
test: fix and reactivate nucleotide mutations tests
Browse files Browse the repository at this point in the history
issue: #283
  • Loading branch information
fengelniederhammer committed Jul 4, 2023
1 parent 148ea4b commit f4115df
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class MutationData(
example = "G29741T",
description = "(nucleotide symbol in reference genome)(position in genome)" +
"(mutation's target nucleotide symbol)",
) val mutation: String,
) val position: String,
@Schema(
example = "42",
description = "Total number of sequences with this mutation matching the given sequence filter criteria",
Expand Down
6 changes: 3 additions & 3 deletions siloLapisTests/test/aggregated.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {expect} from 'chai';
import {lapisClient} from './common';
import fs from 'fs';
import {AggregatedResponse, SequenceFiltersWithGroupByFields} from './lapisClient';
import {AggregatedResponse, SequenceFiltersWithFields} from './lapisClient';

const queriesPath = __dirname + '/aggregatedQueries';
const aggregatedQueryFiles = fs.readdirSync(queriesPath);

type TestCase = {
testCaseName: string;
lapisRequest: SequenceFiltersWithGroupByFields;
lapisRequest: SequenceFiltersWithFields;
expected: AggregatedResponse;
};

Expand All @@ -19,7 +19,7 @@ describe('The /aggregated endpoint', () => {
it('should return data for the test case ' + testCase.testCaseName, async () => {

const result = await lapisClient.postAggregated(
{sequenceFiltersWithGroupByFields: testCase.lapisRequest}
{sequenceFiltersWithFields: testCase.lapisRequest}
);

expect(result).deep.equals(testCase.expected);
Expand Down
75 changes: 37 additions & 38 deletions siloLapisTests/test/nucleotideMutations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,41 @@ import fs from 'fs';
import { SequenceFilters } from './lapisClient';

describe('The /nucleotideMutationProportions endpoint', () => {
let mutationWithLessThan10PercentProportion = 'G29741T';
let mutationWithMoreThan50PercentProportion = 'G28880A';

// TODO: reenable this as soon as SILO supports nuc mutation queries again
// it('should return mutation proportions for Switzerland', async () => {
// const result = await lapisClient.postNucleotideMutations({
// sequenceFiltersWithMinProportion: { country: 'Switzerland' },
// });
//
// expect(result).to.have.length(362);
//
// const rareMutationProportion = result.find(
// mutationData => mutationData.mutation === mutationWithLessThan10PercentProportion
// );
// expect(rareMutationProportion?.count).to.equal(8);
// expect(rareMutationProportion?.proportion).to.be.approximately(0.0816326, 0.0001);
//
// const commonMutationProportion = result.find(
// mutationProportion => mutationProportion.mutation === mutationWithMoreThan50PercentProportion
// );
// expect(commonMutationProportion?.count).to.equal(61);
// expect(commonMutationProportion?.proportion).to.be.approximately(0.6288659793814433, 0.0001);
// });
//
// it('should return mutation proportions for Switzerland with minProportion 0.5', async () => {
// const result = await lapisClient.postNucleotideMutations({
// sequenceFiltersWithMinProportion: {
// country: 'Switzerland',
// minProportion: 0.5,
// },
// });
//
// expect(result).to.have.length(108);
//
// const mutationsAboveThreshold = result.map(mutationData => mutationData.mutation);
// expect(mutationsAboveThreshold).to.contain(mutationWithMoreThan50PercentProportion);
// expect(mutationsAboveThreshold).to.not.contain(mutationWithLessThan10PercentProportion);
// });
let mutationWithLessThan10PercentProportion = 'C19220T';
let mutationWithMoreThan50PercentProportion = 'G28280C';

it('should return mutation proportions for Switzerland', async () => {
const result = await lapisClient.postNucleotideMutations({
sequenceFiltersWithMinProportion: { country: 'Switzerland' },
});

expect(result).to.have.length(362);

const rareMutationProportion = result.find(
mutationData => mutationData.position === mutationWithLessThan10PercentProportion
);
expect(rareMutationProportion?.count).to.equal(8);
expect(rareMutationProportion?.proportion).to.be.approximately(0.0816, 0.0001);

const commonMutationProportion = result.find(
mutationProportion => mutationProportion.position === mutationWithMoreThan50PercentProportion
);
expect(commonMutationProportion?.count).to.equal(51);
expect(commonMutationProportion?.proportion).to.be.approximately(0.5204, 0.0001);
});

it('should return mutation proportions for Switzerland with minProportion 0.5', async () => {
const result = await lapisClient.postNucleotideMutations({
sequenceFiltersWithMinProportion: {
country: 'Switzerland',
minProportion: 0.5,
},
});

expect(result).to.have.length(108);

const mutationsAboveThreshold = result.map(mutationData => mutationData.position);
expect(mutationsAboveThreshold).to.contain(mutationWithMoreThan50PercentProportion);
expect(mutationsAboveThreshold).to.not.contain(mutationWithLessThan10PercentProportion);
});
});

0 comments on commit f4115df

Please sign in to comment.