Skip to content

Commit

Permalink
fix(lapis): nucleotideInsertionContains correctly handles segment
Browse files Browse the repository at this point in the history
squash this: add multi segmented run config
  • Loading branch information
JonasKellerer committed Jun 18, 2024
1 parent 3d4cefb commit 4776a3e
Show file tree
Hide file tree
Showing 75 changed files with 396 additions and 44 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lapis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ jobs:
arguments: generateOpenApiDocs -PopennessLevel=protected
build-root-directory: lapis

- name: Build OpenAPI Spec Multi segmented
uses: gradle/actions/setup-gradle@v3
with:
arguments: generateOpenApiDocs -Psegmented=true
build-root-directory: lapis

- name: Cache .npm
uses: actions/cache@v4
with:
Expand All @@ -109,6 +115,10 @@ jobs:
run: npm run generateLapisClientProtected
working-directory: lapis-e2e

- name: Generate Lapis Client Multi Segmented
run: npm run generateLapisClientMultiSegmented
working-directory: lapis-e2e

- name: Check Format
run: npm run check-format
working-directory: lapis-e2e
Expand Down Expand Up @@ -150,8 +160,12 @@ jobs:
cd lapis
mkdir p e2e-logs
docker compose logs silo > e2e-logs/silo.log
docker compose logs siloPreprocessing > e2e-logs/siloPreprocessing.log
docker compose logs siloMultisegmented > e2e-logs/siloMultisegmented.log
docker compose logs siloPreprocessingMultisegmented > e2e-logs/siloPreprocessingMultisegmented.log
docker compose logs lapisOpen > e2e-logs/lapisOpen.log
docker compose logs lapisProtected > e2e-logs/lapisProtected.log
docker compose logs lapisMultiSegmented > e2e-logs/lapisMultiSegmented.log
env:
SILO_TAG: latest
LAPIS_TAG: ${{ steps.lapisBranchTag.outputs.lapisTag }}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/runConfigurations/LapisOpen.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/runConfigurations/LapisProtected.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions .idea/runConfigurations/lapis_protected.xml

This file was deleted.

4 changes: 2 additions & 2 deletions lapis-docs/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Create a .env file with this input might NOT work. You might need to properly set CONFIG_FILE as an
# environment variable.
CONFIG_FILE=../lapis-e2e/testData/testDatabaseConfig.yaml
REFERENCE_GENOMES_FILE=../lapis-e2e/testData/reference_genomes.json
CONFIG_FILE=../lapis-e2e/testData/singleSegmented/testDatabaseConfig.yaml
REFERENCE_GENOMES_FILE=../lapis-e2e/testData/singleSegmented/reference_genomes.json
2 changes: 1 addition & 1 deletion lapis-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro",
"check-format": "prettier --check \"**/*.{ts,tsx,json,astro,md,mdx,mjs,cjs}\"",
"format": "prettier --write \"**/*.{ts,tsx,json,astro,md,mdx,mjs,cjs}\"",
"check-types": "CONFIG_FILE=../lapis-e2e/testData/testDatabaseConfig.yaml astro sync && tsc --noEmit",
"check-types": "CONFIG_FILE=../lapis-e2e/testData/singleSegmented/testDatabaseConfig.yaml astro sync && tsc --noEmit",
"e2e": "playwright test"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions lapis-docs/test-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ services:
ports:
- "4321:3000"
volumes:
- ../lapis-e2e/testData/testDatabaseConfig.yaml:/config/database_config.yaml
- ../lapis-e2e/testData/reference_genomes.json:/config/reference_genomes.json
- ../lapis-e2e/testData/singleSegmented/testDatabaseConfig.yaml:/config/database_config.yaml
- ../lapis-e2e/testData/singleSegmented/reference_genomes.json:/config/reference_genomes.json
environment:
LAPIS_URL: http://localhost:8090
BASE_URL: /docs/
1 change: 1 addition & 0 deletions lapis-e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/

**/output/
**/logs/
**/temp/
3 changes: 2 additions & 1 deletion lapis-e2e/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/test/lapisClient
/test/lapisClientProtected
/test/lapisClientProtected
/test/lapisClientMultiSegmented
8 changes: 6 additions & 2 deletions lapis-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
"scripts": {
"test": "mocha --exit",
"generateLapisClient": "npm run runOpenApiGenerator && npm run copyGeneratedFiles && npm run cleanUpGeneratedFiles",
"runOpenApiGenerator": "openapi-generator-cli generate -i ../lapis/lapis-openapi.json -g typescript-fetch -o generated-sources",
"runOpenApiGenerator": "openapi-generator-cli generate -i ../lapis/lapis-openapi-single-segmented.json -g typescript-fetch -o generated-sources",
"copyGeneratedFiles": "mkdir -p test/lapisClient && cp generated-sources/index.ts generated-sources/runtime.ts test/lapisClient && cp -r generated-sources/apis generated-sources/models test/lapisClient",
"generateLapisClientProtected": "npm run runOpenApiGeneratorProtected && npm run copyGeneratedFilesProtected && npm run cleanUpGeneratedFilesProtected",
"runOpenApiGeneratorProtected": "openapi-generator-cli generate -i ../lapis/lapis-openapi-protected.json -g typescript-fetch -o generated-sources-protected",
"runOpenApiGeneratorProtected": "openapi-generator-cli generate -i ../lapis/lapis-openapi-single-segmented-protected.json -g typescript-fetch -o generated-sources-protected",
"copyGeneratedFilesProtected": "mkdir -p test/lapisClientProtected && cp generated-sources-protected/index.ts generated-sources-protected/runtime.ts test/lapisClientProtected && cp -r generated-sources-protected/apis generated-sources-protected/models test/lapisClientProtected",
"generateLapisClientMultiSegmented": "npm run runOpenApiGeneratorMultiSegmented && npm run copyGeneratedFilesMultiSegmented && npm run cleanUpGeneratedFilesMultiSegmented",
"runOpenApiGeneratorMultiSegmented": "openapi-generator-cli generate -i ../lapis/lapis-openapi-multi-segmented.json -g typescript-fetch -o generated-sources-multi-segmented",
"copyGeneratedFilesMultiSegmented": "mkdir -p test/lapisClientMultiSegmented && cp generated-sources-multi-segmented/index.ts generated-sources-multi-segmented/runtime.ts test/lapisClientMultiSegmented && cp -r generated-sources-multi-segmented/apis generated-sources-multi-segmented/models test/lapisClientMultiSegmented",
"cleanUpGeneratedFiles": "rm -rf generated-sources",
"cleanUpGeneratedFilesProtected": "rm -rf generated-sources-protected",
"cleanUpGeneratedFilesMultiSegmented": "rm -rf generated-sources-multi-segmented",
"check-format": "prettier --check .",
"format": "prettier --write ."
},
Expand Down
13 changes: 12 additions & 1 deletion lapis-e2e/test/aggregated.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient } from './common';
import { basePath, lapisClient, lapisClientMultiSegmented } from './common';
import fs from 'fs';
import { AggregatedPostRequest, AggregatedResponse } from './lapisClient';

Expand Down Expand Up @@ -46,6 +46,17 @@ describe('The /aggregated endpoint', () => {
})
);

it('should correcty handle aggregated request with multiple segments', async () => {
const result = await lapisClientMultiSegmented.postAggregated1({
aggregatedPostRequest: {
nucleotideMutations: ['L:T1A', 'M:T1C'],
},
});

expect(result.data).to.have.length(1);
expect(result.data[0]).to.have.property('count', 1);
});

it('should correctly handle multiple mutation requests in GET requests', async () => {
const urlParams = new URLSearchParams({
nucleotideMutations: 'T1-,A23062T',
Expand Down
15 changes: 15 additions & 0 deletions lapis-e2e/test/alignedNucleotideSequence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from 'chai';
import {
basePath,
expectIsZstdEncoded,
lapisMultiSegmentedSequenceController,
lapisSingleSegmentedSequenceController,
sequenceData,
} from './common';
Expand All @@ -20,6 +21,20 @@ describe('The /alignedNucleotideSequence endpoint', () => {
expect(sequences[0]).to.have.length(29903);
});

it('should return aligned nucleotide sequences for multi segmented sequences', async () => {
const result = await lapisMultiSegmentedSequenceController.postAlignedNucleotideSequence({
nucleotideSequenceRequest: { country: 'Switzerland' },
segment: 'M',
});

const { primaryKeys, sequences } = sequenceData(result);

expect(primaryKeys).to.have.length(6);
expect(sequences).to.have.length(6);
expect(primaryKeys[0]).to.equal('>key_5');
expect(sequences[0]).to.equal('TGGG');
});

it('should order ascending by specified fields', async () => {
const result = await lapisSingleSegmentedSequenceController.postAlignedNucleotideSequence({
nucleotideSequenceRequest: { orderBy: [{ field: 'primaryKey', type: 'ascending' }] },
Expand Down
2 changes: 1 addition & 1 deletion lapis-e2e/test/aminoAcidSequence.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient, sequenceData } from './common';
import { lapisClient, sequenceData } from './common';

describe('The /alignedAminoAcidSequence endpoint', () => {
it('should return amino acid sequences for Switzerland', async () => {
Expand Down
10 changes: 10 additions & 0 deletions lapis-e2e/test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import {
Middleware,
SingleSegmentedSequenceControllerApi,
} from './lapisClient';
import { LapisControllerApi as LapisControllerApiMultiSegmented } from './lapisClientMultiSegmented';
import { expect } from 'chai';

import {
LapisControllerApi as LapisControllerApiProtected,
Configuration as ConfigurationProtected,
} from './lapisClientProtected';
import { MultiSegmentedSequenceControllerApi } from './lapisClientMultiSegmented';

export const basePath = 'http://localhost:8090';
export const basePathProtected = 'http://localhost:8092';
export const basePathMultiSegmented = 'http://localhost:8094';

const middleware: Middleware = {
onError: errorContext => {
Expand Down Expand Up @@ -40,11 +43,18 @@ export const lapisClient = new LapisControllerApi(new Configuration({ basePath }
export const lapisClientProtected = new LapisControllerApiProtected(
new ConfigurationProtected({ basePath: basePathProtected })
).withMiddleware(middleware);
export const lapisClientMultiSegmented = new LapisControllerApiMultiSegmented(
new Configuration({ basePath: basePathMultiSegmented })
).withMiddleware(middleware);

export const lapisSingleSegmentedSequenceController = new SingleSegmentedSequenceControllerApi(
new Configuration({ basePath })
).withMiddleware(middleware);

export const lapisMultiSegmentedSequenceController = new MultiSegmentedSequenceControllerApi(
new Configuration({ basePath: basePathMultiSegmented })
).withMiddleware(middleware);

export function sequenceData(serverResponse: string) {
const lines = serverResponse.split('\n').filter(line => line.length > 0);
const primaryKeys = lines.filter(line => line.startsWith('>'));
Expand Down
1 change: 1 addition & 0 deletions lapis-e2e/test/lapisClientMultiSegmented/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
16 changes: 15 additions & 1 deletion lapis-e2e/test/nucleotideInsertions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient } from './common';
import { basePath, lapisClient, lapisClientMultiSegmented } from './common';

describe('The /nucleotideInsertions endpoint', () => {
let someInsertion = 'ins_25701:CCC';
Expand All @@ -18,6 +18,20 @@ describe('The /nucleotideInsertions endpoint', () => {
expect(specificInsertion?.sequenceName).to.be.undefined;
});

it('should return nucleotide insertions for multi segmented sequences', async () => {
const result = await lapisClientMultiSegmented.postNucleotideInsertions1({
insertionsRequest: { country: 'Switzerland' },
});

expect(result.data).to.have.length(2);

const insertionsFirstSegment = result.data.find(mutationData => mutationData.insertion === 'ins_L:1:AB');
expect(insertionsFirstSegment?.count).to.equal(2);

const insertionsSecondSegment = result.data.find(mutationData => mutationData.insertion === 'ins_M:2:BC');
expect(insertionsSecondSegment?.count).to.equal(1);
});

it('should order by specified fields', async () => {
const ascendingOrderedResult = await lapisClient.postNucleotideInsertions1({
insertionsRequest: {
Expand Down
20 changes: 19 additions & 1 deletion lapis-e2e/test/nucleotideMutations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient } from './common';
import { basePath, lapisClient, lapisClientMultiSegmented } from './common';

describe('The /nucleotideMutations endpoint', () => {
let mutationWithLessThan10PercentProportion = 'C19220T';
Expand Down Expand Up @@ -29,6 +29,24 @@ describe('The /nucleotideMutations endpoint', () => {
expect(commonMutationProportion?.position).to.be.equal(28280);
});

it('should return mutations proportions for multi segmented', async () => {
const result = await lapisClientMultiSegmented.postNucleotideMutations1({
sequenceFiltersWithMinProportion: { country: 'Switzerland' },
});

expect(result.data).to.have.length(2);

const mutationProportionOnFirstSegment = result.data.find(
mutationData => mutationData.mutation === 'L:T1A'
);
expect(mutationProportionOnFirstSegment?.count).to.equal(2);

const mutationProportionOnSecondSegment = result.data.find(
mutationData => mutationData.mutation === 'M:T1C'
);
expect(mutationProportionOnSecondSegment?.count).to.equal(1);
});

it('should return mutation proportions for Switzerland with minProportion 0.5', async () => {
const result = await lapisClient.postNucleotideMutations1({
sequenceFiltersWithMinProportion: {
Expand Down
7 changes: 7 additions & 0 deletions lapis-e2e/testData/multiSegmented/aa_insertions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
primaryKey RdRp NP GPC
key_0 [] [] []
key_1 [] [] []
key_2 [] [] []
key_3 [] [] []
key_4 [] [] []
key_5 [] [] []
12 changes: 12 additions & 0 deletions lapis-e2e/testData/multiSegmented/gene_GPC.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>key_0
MS*
>key_1
MS*
>key_2
MS*
>key_3
MS*
>key_4
MS*
>key_5
MS*
12 changes: 12 additions & 0 deletions lapis-e2e/testData/multiSegmented/gene_NP.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>key_0
MEN*
>key_1
MEN*
>key_2
MEN*
>key_3
MEN*
>key_4
MEN*
>key_5
MEN*
12 changes: 12 additions & 0 deletions lapis-e2e/testData/multiSegmented/gene_RdRp.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>key_0
MDFL*
>key_1
MDFL*
>key_2
MDFL*
>key_3
MDFL*
>key_4
MDFL*
>key_5
MDFL*
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
primaryKey date country
key_0 2021-03-18 Switzerland
key_1 2021-04-13 Switzerland
key_2 2021-04-25 Switzerland
key_3 2021-04-13 Switzerland
key_4 2021-03-19 Switzerland
key_5 Switzerland
12 changes: 12 additions & 0 deletions lapis-e2e/testData/multiSegmented/nuc_L.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>key_0
ACTCT
>key_1
ACTCT
>key_2
TCTCT
>key_3
TCTCT
>key_4
TCTCT
>key_5
TCTCT
12 changes: 12 additions & 0 deletions lapis-e2e/testData/multiSegmented/nuc_M.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>key_0
CGGG
>key_1
TGGG
>key_2
TGGG
>key_3
TGGG
>key_4
TGGG
>key_5
TGGG
Loading

0 comments on commit 4776a3e

Please sign in to comment.