From 95e22d17318066f8e79f48350375bf7741fe600c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Oct 2021 23:04:35 +0000 Subject: [PATCH 01/16] Bump coverage from 6.0 to 6.0.2 Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.0 to 6.0.2. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/6.0...6.0.2) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0ab44670..f1f78d9f 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ "Cython==0.29.24", ], "test": [ - "coverage==6.0", + "coverage==6.0.2", "pytest<6.3", "pytest-cov==3.0.0", "testfixtures==6.18.3", From 854f18db19562e0f35def7c33b65319872925e6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:00:24 +0000 Subject: [PATCH 02/16] Bump flake8 from 3.9.2 to 4.0.1 Bumps [flake8](https://github.com/pycqa/flake8) from 3.9.2 to 4.0.1. - [Release notes](https://github.com/pycqa/flake8/releases) - [Commits](https://github.com/pycqa/flake8/compare/3.9.2...4.0.1) --- updated-dependencies: - dependency-name: flake8 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f1f78d9f..0f6a7a9a 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ "pytest-cov==3.0.0", "testfixtures==6.18.3", "tox==3.24.4", - "flake8==3.9.2", + "flake8==4.0.1", "flake8-docstrings==1.6.0", "asynctest==0.13.0", "aioresponses==0.7.2", From 5ffcfd488dce3d582bb00d6de764d6c2379e592e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:47:09 +0000 Subject: [PATCH 03/16] Bump jsonschema from 4.0.1 to 4.1.0 Bumps [jsonschema](https://github.com/Julian/jsonschema) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/Julian/jsonschema/releases) - [Changelog](https://github.com/Julian/jsonschema/blob/main/CHANGELOG.rst) - [Commits](https://github.com/Julian/jsonschema/compare/v4.0.1...v4.1.0) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1bc02c8c..74e0916a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohttp==3.7.4.post0 aiohttp-cors==0.7.0 asyncpg==0.24.0 jsonschema==3.2.0; python_version < '3.7' -jsonschema==4.0.1; python_version >= '3.7' +jsonschema==4.1.0; python_version >= '3.7' Cython==0.29.24 cyvcf2==0.10.1; python_version < '3.7' cyvcf2; python_version >= '3.7' diff --git a/setup.py b/setup.py index 0f6a7a9a..55ac1bda 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ "Authlib==0.15.4", "aiohttp-cors==0.7.0", "jsonschema==3.2.0; python_version < '3.7'", - "jsonschema==4.0.1; python_version >= '3.7'", + "jsonschema==4.1.0; python_version >= '3.7'", "gunicorn==20.1.0", "uvloop==0.14.0; python_version < '3.7'", "uvloop==0.16.0; python_version >= '3.7'", From 68a2ef79ee73d2cac5cc4e91bef77c35e4ae8273 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 23:03:37 +0000 Subject: [PATCH 04/16] Bump authlib from 0.15.4 to 0.15.5 Bumps [authlib](https://github.com/lepture/authlib) from 0.15.4 to 0.15.5. - [Release notes](https://github.com/lepture/authlib/releases) - [Changelog](https://github.com/lepture/authlib/blob/v0.15.5/docs/changelog.rst) - [Commits](https://github.com/lepture/authlib/compare/v0.15.4...v0.15.5) --- updated-dependencies: - dependency-name: authlib dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 74e0916a..9ad1fd95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,5 +11,5 @@ uvloop==0.16.0; python_version >= '3.7' aiocache==0.11.1 ujson==4.2.0 aiomcache==0.6.0 -Authlib==0.15.4 +Authlib==0.15.5 gunicorn==20.1.0 diff --git a/setup.py b/setup.py index 55ac1bda..1e902d13 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ install_requires=[ "asyncpg==0.24.0", "aiohttp==3.7.4.post0", - "Authlib==0.15.4", + "Authlib==0.15.5", "aiohttp-cors==0.7.0", "jsonschema==3.2.0; python_version < '3.7'", "jsonschema==4.1.0; python_version >= '3.7'", From e362f0e8a2b914341bca710d76306076365e2b30 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Thu, 21 Oct 2021 12:49:11 +0300 Subject: [PATCH 05/16] fix typo postgresql docker command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48377215..7fc1b721 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ It is recommended to start PostgreSQL using [Docker](https://www.docker.com/): ```shell docker run -e POSTGRES_USER=beacon \ -e POSTGRES_PASSWORD=beacon \ - -v "$PWD/data":/docker-entrypoint-initdb.d + -v "$PWD/data":/docker-entrypoint-initdb.d \ -e POSTGRES_DB=beacondb \ -p 5432:5432 postgres:11.6 ``` From e54662ed884796177e050525acdcfef88ffc11e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Oct 2021 23:04:29 +0000 Subject: [PATCH 06/16] Bump numpy from 1.21.2 to 1.21.3 Bumps [numpy](https://github.com/numpy/numpy) from 1.21.2 to 1.21.3. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt) - [Commits](https://github.com/numpy/numpy/compare/v1.21.2...v1.21.3) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1e902d13..6a574c83 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ extras_require={ "vcf": [ "cyvcf2==0.10.1; python_version < '3.7'", - "numpy==1.21.2", + "numpy==1.21.3", "cyvcf2; python_version >= '3.7'", "Cython==0.29.24", ], From 3513616025c8d271da8b9b91bc4f72fa8b427703 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Oct 2021 05:29:17 +0000 Subject: [PATCH 07/16] Bump jsonschema from 4.1.0 to 4.1.2 Bumps [jsonschema](https://github.com/Julian/jsonschema) from 4.1.0 to 4.1.2. - [Release notes](https://github.com/Julian/jsonschema/releases) - [Changelog](https://github.com/Julian/jsonschema/blob/main/CHANGELOG.rst) - [Commits](https://github.com/Julian/jsonschema/compare/v4.1.0...v4.1.2) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9ad1fd95..8ed110a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohttp==3.7.4.post0 aiohttp-cors==0.7.0 asyncpg==0.24.0 jsonschema==3.2.0; python_version < '3.7' -jsonschema==4.1.0; python_version >= '3.7' +jsonschema==4.1.2; python_version >= '3.7' Cython==0.29.24 cyvcf2==0.10.1; python_version < '3.7' cyvcf2; python_version >= '3.7' diff --git a/setup.py b/setup.py index 6a574c83..65eab221 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ "Authlib==0.15.5", "aiohttp-cors==0.7.0", "jsonschema==3.2.0; python_version < '3.7'", - "jsonschema==4.1.0; python_version >= '3.7'", + "jsonschema==4.1.2; python_version >= '3.7'", "gunicorn==20.1.0", "uvloop==0.14.0; python_version < '3.7'", "uvloop==0.16.0; python_version >= '3.7'", From 9af92350021040aa81b958e11d843d91197e53d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:05:34 +0000 Subject: [PATCH 08/16] Bump black from 21.9b0 to 21.10b0 Bumps [black](https://github.com/psf/black) from 21.9b0 to 21.10b0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/commits) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 65eab221..278c3d9c 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ "flake8-docstrings==1.6.0", "asynctest==0.13.0", "aioresponses==0.7.2", - "black==21.9b0", + "black==21.10b0", ], "docs": ["sphinx >= 1.4", "sphinx_rtd_theme==1.0.0"], }, From 6db90ffdcbe3f2bbf6bce4a89e16cc57df0bbb69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Nov 2021 05:35:21 +0000 Subject: [PATCH 09/16] Bump coverage from 6.0.2 to 6.1.1 Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.0.2 to 6.1.1. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/6.0.2...6.1.1) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 278c3d9c..6f82c478 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ "Cython==0.29.24", ], "test": [ - "coverage==6.0.2", + "coverage==6.1.1", "pytest<6.3", "pytest-cov==3.0.0", "testfixtures==6.18.3", From 045e74f1533f768774b2e2cf96335da25f82e4e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Nov 2021 23:05:43 +0000 Subject: [PATCH 10/16] Bump jsonschema from 4.1.2 to 4.2.1 Bumps [jsonschema](https://github.com/Julian/jsonschema) from 4.1.2 to 4.2.1. - [Release notes](https://github.com/Julian/jsonschema/releases) - [Changelog](https://github.com/Julian/jsonschema/blob/main/CHANGELOG.rst) - [Commits](https://github.com/Julian/jsonschema/compare/v4.1.2...v4.2.1) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8ed110a8..58437ea6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohttp==3.7.4.post0 aiohttp-cors==0.7.0 asyncpg==0.24.0 jsonschema==3.2.0; python_version < '3.7' -jsonschema==4.1.2; python_version >= '3.7' +jsonschema==4.2.1; python_version >= '3.7' Cython==0.29.24 cyvcf2==0.10.1; python_version < '3.7' cyvcf2; python_version >= '3.7' diff --git a/setup.py b/setup.py index 6f82c478..7fffb43a 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ "Authlib==0.15.5", "aiohttp-cors==0.7.0", "jsonschema==3.2.0; python_version < '3.7'", - "jsonschema==4.1.2; python_version >= '3.7'", + "jsonschema==4.2.1; python_version >= '3.7'", "gunicorn==20.1.0", "uvloop==0.14.0; python_version < '3.7'", "uvloop==0.16.0; python_version >= '3.7'", From c4dae6e3b405bd712f3c6e00c3f7cb73256080a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Nov 2021 05:09:09 +0000 Subject: [PATCH 11/16] Bump numpy from 1.21.3 to 1.21.4 Bumps [numpy](https://github.com/numpy/numpy) from 1.21.3 to 1.21.4. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt) - [Commits](https://github.com/numpy/numpy/compare/v1.21.3...v1.21.4) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7fffb43a..5f034299 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ extras_require={ "vcf": [ "cyvcf2==0.10.1; python_version < '3.7'", - "numpy==1.21.3", + "numpy==1.21.4", "cyvcf2; python_version >= '3.7'", "Cython==0.29.24", ], From fe72b556eb270c41d39dfc0ff3557609a56afdc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Nov 2021 23:05:45 +0000 Subject: [PATCH 12/16] Bump coverage from 6.1.1 to 6.1.2 Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.1.1 to 6.1.2. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/6.1.1...6.1.2) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5f034299..ed8d1d34 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ "Cython==0.29.24", ], "test": [ - "coverage==6.1.1", + "coverage==6.1.2", "pytest<6.3", "pytest-cov==3.0.0", "testfixtures==6.18.3", From fc4ad68c29ab99f0cb3880abf8ca63a316804311 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Nov 2021 23:05:25 +0000 Subject: [PATCH 13/16] Bump black from 21.10b0 to 21.11b1 Bumps [black](https://github.com/psf/black) from 21.10b0 to 21.11b1. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/commits) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ed8d1d34..5c08f0a1 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ "flake8-docstrings==1.6.0", "asynctest==0.13.0", "aioresponses==0.7.2", - "black==21.10b0", + "black==21.11b1", ], "docs": ["sphinx >= 1.4", "sphinx_rtd_theme==1.0.0"], }, From 0f85db02e78147ec6e90b481148eb7bbb9d1d5e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Nov 2021 05:48:33 +0000 Subject: [PATCH 14/16] Bump ujson from 4.2.0 to 4.3.0 Bumps [ujson](https://github.com/ultrajson/ultrajson) from 4.2.0 to 4.3.0. - [Release notes](https://github.com/ultrajson/ultrajson/releases) - [Commits](https://github.com/ultrajson/ultrajson/compare/4.2.0...4.3.0) --- updated-dependencies: - dependency-name: ujson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 58437ea6..6e791585 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ cyvcf2; python_version >= '3.7' uvloop==0.14.0; python_version < '3.7' uvloop==0.16.0; python_version >= '3.7' aiocache==0.11.1 -ujson==4.2.0 +ujson==4.3.0 aiomcache==0.6.0 Authlib==0.15.5 gunicorn==20.1.0 diff --git a/setup.py b/setup.py index 5c08f0a1..bd1e035e 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ "cyvcf2==0.10.1; python_version < '3.7'", "cyvcf2; python_version >= '3.7'", "aiocache==0.11.1", - "ujson==4.2.0", + "ujson==4.3.0", "aiomcache==0.6.0", ], extras_require={ From 033c7ab94eadeeb87018d2fa75eaeff91911c810 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Nov 2021 06:53:37 +0000 Subject: [PATCH 15/16] Bump asyncpg from 0.24.0 to 0.25.0 Bumps [asyncpg](https://github.com/MagicStack/asyncpg) from 0.24.0 to 0.25.0. - [Release notes](https://github.com/MagicStack/asyncpg/releases) - [Commits](https://github.com/MagicStack/asyncpg/compare/v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: asyncpg dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6e791585..a67d62e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ aiohttp==3.7.4.post0 aiohttp-cors==0.7.0 -asyncpg==0.24.0 +asyncpg==0.25.0 jsonschema==3.2.0; python_version < '3.7' jsonschema==4.2.1; python_version >= '3.7' Cython==0.29.24 diff --git a/setup.py b/setup.py index bd1e035e..89262e2a 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ "Programming Language :: Python :: 3.7", ], install_requires=[ - "asyncpg==0.24.0", + "asyncpg==0.25.0", "aiohttp==3.7.4.post0", "Authlib==0.15.5", "aiohttp-cors==0.7.0", From a644b0915b299f1fdec6806ce678fd430f6d1ab3 Mon Sep 17 00:00:00 2001 From: "teemu.kataja" Date: Tue, 23 Nov 2021 14:48:59 +0200 Subject: [PATCH 16/16] frequency check should be performed before unpack --- beacon_api/utils/db_load.py | 131 ++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/beacon_api/utils/db_load.py b/beacon_api/utils/db_load.py index bd100e6d..94b64d3a 100644 --- a/beacon_api/utils/db_load.py +++ b/beacon_api/utils/db_load.py @@ -302,83 +302,82 @@ async def insert_variants(self, dataset_id, variants, min_ac): async with self._conn.transaction(): LOG.info("Insert variants into the database") for variant in variants: - # params = (frequency, count, actual variant Type) - params = self._unpack(variant) - # Coordinates that are read from VCF are 1-based, - # cyvcf2 reads them as 0-based, and they are inserted into the DB as such - - # params may carry single variants [1] or packed variants [20, 15, 10, 1] - # The first check prunes for single variants, packed variants must be removed afterwards - if params[1][0] >= min_ac: - # Remove packed variants that don't meet the minimum allele count requirements - # Packed variants are always ordered from largest to smallest, this process starts - # popping values from the right (small) side until there are no more small values to pop - while params[1][-1] < min_ac: - params[0].pop() # aaf - params[1].pop() # ac - params[2].pop() # vt - params[3].pop() # alt - if len(params[5]) > 0: - params[5].pop() # bnd - - # Nothing interesting on the variant with no aaf - # because none of the samples have it - if variant.aaf > 0: - - # We Process Breakend Records into a different table for now - if params[5] != []: - # await self.insert_mates(dataset_id, variant, params) - # Most likely there will be only one BND per Record - for bnd in params[5]: - await self._conn.execute( - """INSERT INTO beacon_mate_table - (datasetId, chromosome, chromosomeStart, chromosomePos, - mate, mateStart, matePos, reference, alternate, alleleCount, - callCount, frequency, "end") - SELECT ($1), ($2), ($3), ($4), - ($5), ($6), ($7), ($8), t.alt, t.ac, ($11), t.freq, ($13) - FROM (SELECT unnest($9::varchar[]) alt, unnest($10::integer[]) ac, - unnest($12::float[]) freq) t - ON CONFLICT (datasetId, chromosome, mate, chromosomePos, matePos) - DO NOTHING""", - dataset_id, - variant.CHROM.replace("chr", ""), - variant.start, - variant.ID, - bnd[0].replace("chr", ""), - bnd[1], - bnd[6], - variant.REF, - params[3], - params[1], - params[4], - params[0], - variant.end, - ) - else: + # Nothing interesting on the variant with no aaf + # because none of the samples have it + if variant.aaf > 0: + # params = (frequency, count, actual variant Type) + params = self._unpack(variant) + # Coordinates that are read from VCF are 1-based, + # cyvcf2 reads them as 0-based, and they are inserted into the DB as such + + # params may carry single variants [1] or packed variants [20, 15, 10, 1] + # The first check prunes for single variants, packed variants must be removed afterwards + if params[1][0] >= min_ac: + # Remove packed variants that don't meet the minimum allele count requirements + # Packed variants are always ordered from largest to smallest, this process starts + # popping values from the right (small) side until there are no more small values to pop + while params[1][-1] < min_ac: + params[0].pop() # aaf + params[1].pop() # ac + params[2].pop() # vt + params[3].pop() # alt + if len(params[5]) > 0: + params[5].pop() # bnd + + # We Process Breakend Records into a different table for now + if params[5] != []: + # await self.insert_mates(dataset_id, variant, params) + # Most likely there will be only one BND per Record + for bnd in params[5]: await self._conn.execute( - """INSERT INTO beacon_data_table - (datasetId, chromosome, start, reference, alternate, - "end", aggregatedVariantType, alleleCount, callCount, frequency, variantType) - SELECT ($1), ($2), ($3), ($4), t.alt, ($6), ($7), t.ac, ($9), t.freq, t.vt - FROM (SELECT unnest($5::varchar[]) alt, unnest($8::integer[]) ac, - unnest($10::float[]) freq, unnest($11::varchar[]) as vt) t - ON CONFLICT (datasetId, chromosome, start, reference, alternate) + """INSERT INTO beacon_mate_table + (datasetId, chromosome, chromosomeStart, chromosomePos, + mate, mateStart, matePos, reference, alternate, alleleCount, + callCount, frequency, "end") + SELECT ($1), ($2), ($3), ($4), + ($5), ($6), ($7), ($8), t.alt, t.ac, ($11), t.freq, ($13) + FROM (SELECT unnest($9::varchar[]) alt, unnest($10::integer[]) ac, + unnest($12::float[]) freq) t + ON CONFLICT (datasetId, chromosome, mate, chromosomePos, matePos) DO NOTHING""", dataset_id, variant.CHROM.replace("chr", ""), variant.start, + variant.ID, + bnd[0].replace("chr", ""), + bnd[1], + bnd[6], variant.REF, params[3], - variant.end, - variant.var_type.upper(), params[1], params[4], params[0], - params[2], + variant.end, ) - - LOG.debug("Variants have been inserted") + else: + await self._conn.execute( + """INSERT INTO beacon_data_table + (datasetId, chromosome, start, reference, alternate, + "end", aggregatedVariantType, alleleCount, callCount, frequency, variantType) + SELECT ($1), ($2), ($3), ($4), t.alt, ($6), ($7), t.ac, ($9), t.freq, t.vt + FROM (SELECT unnest($5::varchar[]) alt, unnest($8::integer[]) ac, + unnest($10::float[]) freq, unnest($11::varchar[]) as vt) t + ON CONFLICT (datasetId, chromosome, start, reference, alternate) + DO NOTHING""", + dataset_id, + variant.CHROM.replace("chr", ""), + variant.start, + variant.REF, + params[3], + variant.end, + variant.var_type.upper(), + params[1], + params[4], + params[0], + params[2], + ) + + LOG.debug("Variants have been inserted") except Exception as e: LOG.error(f"AN ERROR OCCURRED WHILE ATTEMPTING TO INSERT VARIANTS -> {e}")