Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
a3d4940
Fix Docker Casing Warnings
bencap Feb 26, 2025
a7c39af
Refactor Dataframe Validation Logic
bencap Feb 28, 2025
2af368b
Refactor Tests to Better Identify Dependency Separation Issues
bencap Feb 28, 2025
b257447
Bump Dependencies
bencap Feb 28, 2025
a2c28e1
Check for Nonetype Target Sequences to Silence MyPy Error
bencap Feb 28, 2025
4a65b2d
Replace DataSet Columns Setter in Worker Variant Mocker
bencap Mar 1, 2025
7c93e19
Add Base Editor Column to Target Accessions Table
bencap Mar 2, 2025
833f6d9
Validation logic and test cases for base editor data
bencap Mar 3, 2025
0c74f1d
Add isBaseEditor Flag to Remaining Accession Tests
bencap Mar 3, 2025
e56d299
Add GUIDE_SEQUENCE_COLUMN constant to mave lib
bencap Mar 3, 2025
5bc49de
Use existing boolean flag for transgenic marker in prefix validation
bencap Mar 3, 2025
6fc41fe
Clarify error message for accession based variants with accessions mi…
bencap Mar 3, 2025
9f7a88e
Move guide sequence column to the end of the standard columns sorted …
bencap Mar 3, 2025
ddd6517
Add additional column validation tests
bencap Mar 3, 2025
1ffb891
Fix sort order of dataframe test case columns
bencap Mar 3, 2025
9cb16e4
Use equality comparison over is operator for column name comparison
bencap Mar 3, 2025
d1f4f9e
Allow the Unix Domain Socket during test runs
bencap Mar 3, 2025
2b4761b
Add Multi-Variant Support for Accession Based Targets
bencap Mar 7, 2025
53e9065
Multi-Variant Genomic Validation Tests
bencap Mar 7, 2025
4afa8a7
Logical names for git action checks
bencap Mar 7, 2025
291fc7e
Bump SeqRepo Version, Add Volume to Dev Containers
bencap Mar 7, 2025
c56b374
Add SeqRepo based seqfetcher to data provider
bencap Mar 7, 2025
8165685
Add SeqFetcher MyPy type stub
bencap Mar 8, 2025
db7f250
Refactor fixes
bencap Mar 13, 2025
47650a8
Use MaveHGVS to determine if variant is a multi-variant
bencap Mar 13, 2025
cf8a95b
Fix tests for MaveHGVS parsing
bencap Mar 13, 2025
82813af
Rebase fixes (could fixup)
bencap Mar 29, 2025
21fc0dc
Show the variants that have problem in error message.
EstelleDa Apr 3, 2025
633dcf5
Modify codes to triggers
EstelleDa Apr 8, 2025
b66b66a
Added ClinGen allele IDs to the variant data model.
jstone-dev Jan 27, 2025
f4d14b0
Added a ClinGen allele ID variant lookup endpoint to the API.
jstone-dev Jan 27, 2025
04526f7
Added a "get variant" endpoint; added permission checks to the varian…
jstone-dev Jan 28, 2025
b7fc08d
Include mapped variants in get/lookup variant responses.
jstone-dev Jan 28, 2025
0d5b1eb
ClinVar Variant Table
bencap Jan 29, 2025
4582b75
fixup
bencap Jan 29, 2025
89edb37
Minimal Script for ClinVar Variant Data Refresh
bencap Jan 30, 2025
7ec9672
View model updates to support clinvar variants
bencap Jan 30, 2025
47baa03
Add check for Nonetype clingen allele ids
bencap Jan 30, 2025
ea69e68
HACK: Expedient solution for surfacing clinsig/reviewstat in CSV scor…
bencap Jan 30, 2025
569d40c
Fixed HTTP method typo.
jstone-dev Jan 28, 2025
56b05ae
Include full score set details in "get variant" response.
jstone-dev Jan 30, 2025
0063f72
Revised the temporary hack that presents ClinVar significances as sco…
jstone-dev Jan 31, 2025
b5b599e
Bug fixes
jstone-dev Jan 31, 2025
8a40392
Genericize ClinVar Variants Table
bencap Feb 18, 2025
7e10d7f
Move clingen_allele_id column to mapped_variants table
bencap Feb 19, 2025
0b1a432
fixup
bencap Feb 19, 2025
aa74796
Clinical control router tests and code fixup from tests output
bencap Feb 19, 2025
a906eb8
Undo demo hack, refactors variant data to csv function into a single …
bencap Feb 20, 2025
df91ffb
Replace id with URN for mapped variant view models, inherit create vi…
bencap Feb 20, 2025
453c7a7
Add route for generating pairwise db_name/db_version clinical control…
bencap Feb 20, 2025
bd0d389
Format changes to clinical control options
bencap Feb 24, 2025
9071ad4
Fix foreign key downgrade constraint name
bencap Feb 25, 2025
8f1002b
Rebase alembic revision ordering
bencap Mar 4, 2025
cbfb139
Current and 2.0 filter for mapped variants
bencap Mar 4, 2025
f88b856
tmp: Staging filter. Drop this commit prior to release.
bencap Mar 4, 2025
6b3d8e1
Make allele ID column alembic upgrade revise stats mat view
bencap Mar 24, 2025
e436b49
wip: clingen ldh submission
bencap Mar 26, 2025
db47a69
wip: clingen ldh submission job
bencap Mar 28, 2025
ddd5079
wip: clingen submission script
bencap Apr 8, 2025
733b086
Alembic revision reorder from rebase
bencap Apr 8, 2025
81bf500
wip: clingen submission and linkage scripts
bencap Apr 9, 2025
cee36d2
Script and LDH Connection Fixes
bencap Apr 17, 2025
d062761
Create distinction between Slack errors and messages
bencap Apr 17, 2025
bd17d1a
Refactor clingen variation function into clingen lib
bencap Apr 17, 2025
73ab329
Only submit mapped variants with a defined post mapped object
bencap Apr 17, 2025
1543d0a
Ensure post mapped metadata is not empty
bencap Apr 17, 2025
b4ba745
Flesh out retry logic for linking clingen allele ids
bencap Apr 18, 2025
d0c2f85
Handle Haplotype VRS Objects
bencap Apr 22, 2025
a9ace94
Add unlinked flag to linking job
bencap Apr 22, 2025
1d4d6b5
wip: docs and tests for clingen jobs
bencap Apr 22, 2025
2410696
Add enqueue linking error to exceptions classes
bencap Apr 22, 2025
6e67d1a
Add new clingen functions to worker
bencap Apr 22, 2025
4f19304
Tests for VRS Variation Extraction Utilities
bencap Apr 23, 2025
631ae0f
Tests for ClinGen Library Methods
bencap Apr 24, 2025
8f53861
Test cases for ClinGen submission
bencap Apr 26, 2025
467fe3b
Tests for Clingen Linkage Job
bencap Apr 28, 2025
82d5970
Test case fixes
bencap Apr 28, 2025
ae8ad7c
Use ubuntu-latest for 3.9 Tests
bencap Apr 28, 2025
b84b17a
Make Mapping Job Enqueue ClinGen Submission Job
bencap Apr 29, 2025
903461e
Dont backoff clingen submission requests
bencap Apr 29, 2025
f3c56fd
Defer linking job in seconds
bencap Apr 29, 2025
95beefd
Mock Requests.put in tests rather than outdate request_with_backoff
bencap Apr 29, 2025
7082958
Use Named Function for Linkage Job
bencap Apr 29, 2025
43ed08b
Define clingen fetch at top level of module
bencap Apr 29, 2025
a32335b
Modify the mapped variants'
EstelleDa May 5, 2025
5884925
Fix poetry run ruff check error.
EstelleDa May 5, 2025
5eb9e9f
The Ubuntu 20.04 Actions runner image will begin deprecation on 2025-…
EstelleDa May 6, 2025
0bed5d6
Merge pull request #388 from VariantEffect/jstone-dev/variant-search
jstone-dev May 6, 2025
cd96d07
Fix Docker Casing Warnings
bencap Feb 26, 2025
0ab2558
Refactor Dataframe Validation Logic
bencap Feb 28, 2025
5c7e823
Refactor Tests to Better Identify Dependency Separation Issues
bencap Feb 28, 2025
038b012
Bump Dependencies
bencap Feb 28, 2025
f78c485
Check for Nonetype Target Sequences to Silence MyPy Error
bencap Feb 28, 2025
119e7f2
Replace DataSet Columns Setter in Worker Variant Mocker
bencap Mar 1, 2025
58dfb7b
Add Base Editor Column to Target Accessions Table
bencap Mar 2, 2025
4fbdbd7
Validation logic and test cases for base editor data
bencap Mar 3, 2025
a9dc19a
Add isBaseEditor Flag to Remaining Accession Tests
bencap Mar 3, 2025
3850996
Add GUIDE_SEQUENCE_COLUMN constant to mave lib
bencap Mar 3, 2025
0b89482
Use existing boolean flag for transgenic marker in prefix validation
bencap Mar 3, 2025
965c4f5
Clarify error message for accession based variants with accessions mi…
bencap Mar 3, 2025
6d0d8f5
Move guide sequence column to the end of the standard columns sorted …
bencap Mar 3, 2025
45afca8
Add additional column validation tests
bencap Mar 3, 2025
d965f68
Fix sort order of dataframe test case columns
bencap Mar 3, 2025
73a0799
Use equality comparison over is operator for column name comparison
bencap Mar 3, 2025
9308643
Allow the Unix Domain Socket during test runs
bencap Mar 3, 2025
58f2af2
Add Multi-Variant Support for Accession Based Targets
bencap Mar 7, 2025
84334cb
Multi-Variant Genomic Validation Tests
bencap Mar 7, 2025
41d2a1f
Logical names for git action checks
bencap Mar 7, 2025
d20bc6d
Bump SeqRepo Version, Add Volume to Dev Containers
bencap Mar 7, 2025
645bcbf
Add SeqRepo based seqfetcher to data provider
bencap Mar 7, 2025
9b4a9ae
Add SeqFetcher MyPy type stub
bencap Mar 8, 2025
941cb49
Refactor fixes
bencap Mar 13, 2025
5e9f6f1
Use MaveHGVS to determine if variant is a multi-variant
bencap Mar 13, 2025
5d261df
Fix tests for MaveHGVS parsing
bencap Mar 13, 2025
57bb3bc
Rebase fixes (could fixup)
bencap Mar 29, 2025
a40afb5
wip: Use new MaveHGVS methods for allelic validation
bencap Apr 4, 2025
6226c93
Fixed rebasing error.
jstone-dev May 6, 2025
a71b71f
Updated MaveHGVS to version 0.7.0.
jstone-dev May 6, 2025
219e1e0
Fixed: MaveHGVS parsing error handling
jstone-dev May 6, 2025
38a0d7b
Fixed rebasing error.
jstone-dev May 6, 2025
a5835a5
Fixed rebasing error.
jstone-dev May 6, 2025
9cfd981
Merge pull request #433 from VariantEffect/bugfix/estelle/432/filterM…
EstelleDa May 7, 2025
68b1a42
Ignore problematic MyPy error.
jstone-dev May 7, 2025
b4e6a15
Run 3.9 tests on ubuntu-latest
bencap May 8, 2025
9c29649
Add Import Skipper to ClinGen LDH Service Tests
bencap May 8, 2025
e7ca7b1
Import all SA models up-front for testing
bencap May 8, 2025
dc6559a
Merge pull request #395 from VariantEffect/feature/bencap/317/base-ed…
bencap May 8, 2025
7dff914
Add ClinGen Submission EnvVar to Control Submission
bencap May 13, 2025
f3c4a77
Reorder Base Editor Alembic Migration
bencap May 13, 2025
ce029be
Rework ClinGen LDH Access Endpoint Environment Variable
bencap May 13, 2025
bc06144
Merge branch 'release-2025.2.0' into improve/estelle/350/surfaceValid…
EstelleDa May 15, 2025
81b0def
New ClinGen LDH submission script options
jstone-dev May 19, 2025
b73d0bd
Add score set description and null IRI to the ClinGen LDH submission.
jstone-dev May 19, 2025
8e58ee9
Add "urns" option to the ClinVar control refresh script.
jstone-dev May 19, 2025
eca6221
Fixed: ClinVar control script sometimes throws an exception due to du…
jstone-dev May 19, 2025
dd50b98
Fixed: ClinVar control script fails on score sets with fewer than 100…
jstone-dev May 19, 2025
a29d94c
Fixed MyPy error.
jstone-dev May 19, 2025
2977ea6
Use Highlighted Variant in Score Set as entIri for ClinGen
bencap May 19, 2025
4cdb972
Fixed: Optional mapping results in the wrong block of the ClinGen LDH…
jstone-dev May 19, 2025
b9de115
Fixed MyPy errors.
jstone-dev May 19, 2025
c75c71c
Updated ClinGen submission unit tests.
jstone-dev May 19, 2025
c16b299
Fixed ClinVar script build & ruff errors.
jstone-dev May 19, 2025
3a6243c
Fixed MyPy error.
jstone-dev May 19, 2025
489c59c
Update tests/routers/test_score_set.py
EstelleDa May 21, 2025
a16e7b3
Merge pull request #420 from VariantEffect/improve/estelle/350/surfac…
EstelleDa May 21, 2025
80a9246
Added unit tests for ClinGen LDH submission without a mapped variant.
jstone-dev May 21, 2025
a68de0a
Support mapper update for multi-target score sets
sallybg May 22, 2025
0febe78
Merge pull request #435 from VariantEffect/jstone-dev/clingen-linkage
bencap May 23, 2025
f44197e
Add OddsPath Property to ScoreRange Data Model
bencap May 23, 2025
e4bd7e4
Due to permission check and superseding problems, enriching experimen…
EstelleDa May 28, 2025
56f88ab
Modified add_contributor function and add two more related tests.
EstelleDa May 28, 2025
dfd9c0c
Remove unnecessary import
EstelleDa May 28, 2025
3f119b9
Store Odds Path Ratios alongside their Score Range
bencap May 28, 2025
8fc7e8a
Modify the db.execute code.
EstelleDa May 29, 2025
195ab49
Merge pull request #442 from VariantEffect/bugfix/estelle/441/fixAddC…
EstelleDa May 29, 2025
3eb8375
Merge release-2025.2.0
EstelleDa May 29, 2025
fe5b29d
Add all ACMG evidence codes, make OddsPath evidence optional
bencap May 29, 2025
13157ea
Merge pull request #439 from VariantEffect/feature/bencap/438/add-odd…
bencap May 29, 2025
991bbfe
Add and modify some tests. Modify part of the codes.
EstelleDa May 30, 2025
f5f114b
Merge branch 'release-2025.2.0' into bugfix/estelle/61/numScoreSetsAn…
EstelleDa May 30, 2025
5a1ff11
Adjust import position
EstelleDa May 30, 2025
3eb8ddc
Add import fastapi
EstelleDa May 30, 2025
571b296
Debug a test.
EstelleDa May 30, 2025
d11d117
Remove an unnecessary import.
EstelleDa May 30, 2025
9edf3f5
Try again. Add an importorskip.
EstelleDa Jun 1, 2025
03090af
Modify code and tests. Revert the yml file back to original content.
EstelleDa Jun 2, 2025
0050085
Resolved importorskips prior to MaveDB imports
bencap Jun 2, 2025
8637a18
Remove obsolete Any typing import
bencap Jun 2, 2025
2a22cd2
Move the numScoreSet to keys to be set part.
EstelleDa Jun 2, 2025
3e165bc
Fix bugs in mapper job, and centralize some mapper resources
sallybg Jun 4, 2025
0d6efc6
Update tests to reflect multi-target mapper changes
sallybg Jun 4, 2025
0a0ebaa
Merge pull request #447 from VariantEffect/bugfix/estelle/61/numScore…
EstelleDa Jun 5, 2025
06d1996
Update VRSMap class and script for multi-target mapper changes
sallybg Jun 9, 2025
deabbc2
Create accession-based score set in db before mapping tests
sallybg Jun 10, 2025
ccbe20f
Add worker tests for multi-target scoresets
sallybg Jun 11, 2025
0e52962
Merge pull request #436 from VariantEffect/mapper-multi-target
bencap Jun 11, 2025
2c5f3c9
Update requests dependency version to 2.32.2 in pyproject.toml
bencap Jun 11, 2025
d8f3b37
Bump version to 2025.2.0 in pyproject.toml and __init__.py
bencap Jun 11, 2025
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
54 changes: 48 additions & 6 deletions .github/workflows/run-tests-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ env:
LOG_CONFIG: test

jobs:
run-tests-3_9-core-dependencies:
runs-on: ubuntu-latest
name: Pytest on Core Dependencies-- Python 3.9
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: 'pip'
- run: pip install --upgrade pip
- run: pip install poetry
- run: poetry install --with dev
- run: poetry run pytest tests/

run-tests-3_9:
runs-on: ubuntu-20.04
name: Pytest on Python 3.9 / Ubuntu 20.04
runs-on: ubuntu-latest
name: Pytest on Optional Dependencies-- Python 3.9
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -20,9 +34,23 @@ jobs:
- run: poetry install --with dev --extras server
- run: poetry run pytest tests/ --show-capture=stdout --cov=src

run-tests-3_10-core-dependencies:
runs-on: ubuntu-latest
name: Pytest on Core Dependencies-- Python 3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- run: pip install --upgrade pip
- run: pip install poetry
- run: poetry install --with dev
- run: poetry run pytest tests/

run-tests-3_10:
runs-on: ubuntu-latest
name: Pytest on Python 3.10
name: Pytest on Optional Dependencies-- Python 3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -34,9 +62,23 @@ jobs:
- run: poetry install --with dev --extras server
- run: poetry run pytest tests/ --show-capture=stdout --cov=src

run-tests-3_11-core-dependencies:
runs-on: ubuntu-latest
name: Pytest on Core Dependencies-- Python 3.11
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- run: pip install --upgrade pip
- run: pip install poetry
- run: poetry install --with dev
- run: poetry run pytest tests/

run-tests-3_11:
runs-on: ubuntu-latest
name: Pytest on Python 3.11
name: Pytest on Optional Dependencies-- Python 3.11
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -50,7 +92,7 @@ jobs:

run-mypy-3_10:
runs-on: ubuntu-latest
name: MyPy checks on Python 3.10
name: MyPy on Full Codebase-- Python 3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -64,7 +106,7 @@ jobs:

run-ruff-lint:
runs-on: ubuntu-latest
name: Ruff linting on Python 3.10
name: Ruff on Full Codebase-- Python 3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# python-base
# Set up shared environment variables
################################
FROM python:3.9 as python-base
FROM python:3.9 AS python-base

# Poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
Expand Down Expand Up @@ -69,7 +69,7 @@ RUN samtools faidx GCF_000001405.39_GRCh38.p13_genomic.fna.gz
# builder
# Builds application dependencies and creates venv
################################
FROM python-base as builder
FROM python-base AS builder

WORKDIR /code

Expand All @@ -90,7 +90,7 @@ COPY src/mavedb/server_main.py /code/main.py
# worker
# Worker image
################################
FROM builder as worker
FROM builder AS worker
COPY --from=downloader /data /data

# copy pre-built poetry + venv
Expand All @@ -103,7 +103,7 @@ CMD ["arq", "mavedb.worker.WorkerSettings"]
# application
# Application image
################################
FROM builder as application
FROM builder AS application
COPY --from=downloader /data /data

# copy pre-built poetry + venv
Expand Down
58 changes: 58 additions & 0 deletions alembic/versions/34026092c7f8_clinvar_variant_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""clinvar variant table

Revision ID: 34026092c7f8
Revises: e8a3b5d8f885
Create Date: 2025-01-28 21:48:42.532346

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "34026092c7f8"
down_revision = "e8a3b5d8f885"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"clinvar_variants",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("allele_id", sa.Integer(), nullable=False),
sa.Column("gene_symbol", sa.String(), nullable=False),
sa.Column("clinical_significance", sa.String(), nullable=False),
sa.Column("clinical_review_status", sa.String(), nullable=False),
sa.Column("clinvar_db_version", sa.String(), nullable=False),
sa.Column("creation_date", sa.Date(), nullable=False),
sa.Column("modification_date", sa.Date(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_clinvar_variants_allele_id"), "clinvar_variants", ["allele_id"], unique=False)
op.add_column("mapped_variants", sa.Column("clinvar_variant_id", sa.Integer(), nullable=True))
op.create_index(
op.f("ix_mapped_variants_clinvar_variant_id"), "mapped_variants", ["clinvar_variant_id"], unique=False
)
op.create_foreign_key(
"mapped_variant_clinvar_variant_id_foreign_key_constraint",
"mapped_variants",
"clinvar_variants",
["clinvar_variant_id"],
["id"],
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"mapped_variant_clinvar_variant_id_foreign_key_constraint", "mapped_variants", type_="foreignkey"
)
op.drop_index(op.f("ix_mapped_variants_clinvar_variant_id"), table_name="mapped_variants")
op.drop_column("mapped_variants", "clinvar_variant_id")
op.drop_index(op.f("ix_clinvar_variants_allele_id"), table_name="clinvar_variants")
op.drop_table("clinvar_variants")
# ### end Alembic commands ###
101 changes: 101 additions & 0 deletions alembic/versions/695b73abe581_genericize_clinvar_variants_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""genericize clinvar variants table

Revision ID: 695b73abe581
Revises: 34026092c7f8
Create Date: 2025-02-18 11:54:15.243078

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "695b73abe581"
down_revision = "34026092c7f8"
branch_labels = None
depends_on = None


def upgrade():
op.rename_table("clinvar_variants", "clinical_controls")
op.execute("ALTER SEQUENCE clinvar_variants_id_seq RENAME TO clinical_controls_id_seq")
op.execute("ALTER INDEX clinvar_variants_pkey RENAME TO clinical_controls_pkey")

op.alter_column("clinical_controls", "clinvar_db_version", nullable=False, new_column_name="db_version")
op.alter_column("clinical_controls", "allele_id", nullable=False, new_column_name="db_identifier")
op.add_column("clinical_controls", sa.Column("db_name", sa.String(), nullable=True))

op.create_index("ix_clinical_controls_gene_symbol", "clinical_controls", ["gene_symbol"])
op.create_index("ix_clinical_controls_db_name", "clinical_controls", ["db_name"])
op.create_index("ix_clinical_controls_db_identifier", "clinical_controls", ["db_identifier"])
op.create_index("ix_clinical_controls_db_version", "clinical_controls", ["db_version"])

op.create_table(
"mapped_variants_clinical_controls",
sa.Column("mapped_variant_id", sa.Integer(), nullable=False),
sa.Column("clinical_control_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["mapped_variant_id"],
["mapped_variants.id"],
),
sa.ForeignKeyConstraint(
["clinical_control_id"],
["clinical_controls.id"],
),
sa.PrimaryKeyConstraint("mapped_variant_id", "clinical_control_id"),
)

# Convert any existing ClinVar variants into clinical control variants. Since
# this table is being update from a clinvar specific table, we assume all existing
# controls are from ClinVar.
op.execute(
"""
INSERT INTO mapped_variants_clinical_controls (
mapped_variant_id,
clinical_control_id
)
SELECT id, clinvar_variant_id
FROM mapped_variants
WHERE clinvar_variant_id IS NOT NULL
"""
)

op.execute("UPDATE clinical_controls SET db_name='ClinVar'")
op.alter_column("clinical_controls", "db_name", nullable=False)

op.drop_index("ix_mapped_variants_clinvar_variant_id", "mapped_variants")
op.drop_column("mapped_variants", "clinvar_variant_id")


def downgrade():
op.rename_table("clinical_controls", "clinvar_variants")
op.execute("ALTER SEQUENCE clinical_controls_id_seq RENAME TO clinvar_variants_id_seq")
op.execute("ALTER INDEX clinical_controls_pkey RENAME TO clinvar_variants_pkey")

op.drop_index("ix_clinical_controls_gene_symbol", "clinical_controls")
op.drop_index("ix_clinical_controls_db_name", "clinical_controls")
op.drop_index("ix_clinical_controls_db_identifier", "clinical_controls")
op.drop_index("ix_clinical_controls_db_version", "clinical_controls")

op.alter_column("clinvar_variants", "db_version", nullable=False, new_column_name="clinvar_db_version")
op.alter_column("clinvar_variants", "db_identifier", nullable=False, new_column_name="allele_id")
op.drop_column("clinvar_variants", "db_name")

op.add_column(
"mapped_variants",
sa.Column("clinvar_variant_id", sa.Integer(), sa.ForeignKey("clinvar_variants.id"), nullable=True),
)

# Downgrades a many-to-many relationship to a one to many. This will result in data loss.
op.execute(
"""
UPDATE mapped_variants
SET clinvar_variant_id=mapped_variants_clinical_controls.clinical_control_id
FROM mapped_variants_clinical_controls
WHERE mapped_variants_clinical_controls.mapped_variant_id=mapped_variants.id
"""
)

op.create_index("ix_mapped_variants_clinvar_variant_id", "mapped_variants", ["clinvar_variant_id"])
op.drop_table("mapped_variants_clinical_controls")
53 changes: 53 additions & 0 deletions alembic/versions/d6e5a9fde3c9_move_clingen_allele_id_to_mapped_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""move clingen allele id to mapped variants table

Revision ID: d6e5a9fde3c9
Revises: 695b73abe581
Create Date: 2025-02-19 10:51:07.319962

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "d6e5a9fde3c9"
down_revision = "695b73abe581"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index("ix_variants_clingen_allele_id", table_name="variants")
op.add_column("mapped_variants", sa.Column("clingen_allele_id", sa.String(), nullable=True))
op.execute(
"""
UPDATE mapped_variants
SET clingen_allele_id=variants.clingen_allele_id
FROM variants
WHERE variants.id=mapped_variants.variant_id
"""
)
op.drop_column("variants", "clingen_allele_id")
op.create_index(
op.f("ix_mapped_variants_clingen_allele_id"), "mapped_variants", ["clingen_allele_id"], unique=False
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_mapped_variants_clingen_allele_id"), table_name="mapped_variants")
op.add_column("variants", sa.Column("clingen_allele_id", sa.String(), nullable=True))
op.execute(
"""
UPDATE variants
SET clingen_allele_id=mapped_variants.clingen_allele_id
FROM mapped_variants
WHERE variants.id=mapped_variants.variant_id
"""
)
op.drop_column("mapped_variants", "clingen_allele_id")
op.create_index("ix_variants_clingen_allele_id", "variants", ["clingen_allele_id"], unique=False)
# ### end Alembic commands ###
27 changes: 27 additions & 0 deletions alembic/versions/e8a3b5d8f885_add_clingen_allele_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add ClinGen allele IDs

Revision ID: e8a3b5d8f885
Revises: 4726e4dddde8
Create Date: 2025-01-27 18:55:09.283855

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "e8a3b5d8f885"
down_revision = "4726e4dddde8"
branch_labels = None
depends_on = None


def upgrade():
op.add_column("variants", sa.Column("clingen_allele_id", sa.String(), nullable=True))
op.create_index(op.f("ix_variants_clingen_allele_id"), "variants", ["clingen_allele_id"], unique=False)


def downgrade():
op.drop_index(op.f("ix_variants_clingen_allele_id"), table_name="variants")
op.drop_column("variants", "clingen_allele_id")
Loading