Skip to content

Commit 65dd9cb

Browse files
authored
Merge pull request #334 from VariantEffect/release-2024.4.1
Release 2024.4.1
2 parents d87b726 + db5b952 commit 65dd9cb

File tree

183 files changed

+5858
-2916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+5858
-2916
lines changed

.flake8

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/run-tests-on-push.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- run: pip install --upgrade pip
1919
- run: pip install poetry
2020
- run: poetry install --with dev --extras server
21-
- run: poetry run pytest tests/ --show-capture=stdout
21+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
2222

2323
run-tests-3_10:
2424
runs-on: ubuntu-latest
@@ -32,7 +32,7 @@ jobs:
3232
- run: pip install --upgrade pip
3333
- run: pip install poetry
3434
- run: poetry install --with dev --extras server
35-
- run: poetry run pytest tests/ --show-capture=stdout
35+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
3636

3737
run-tests-3_11:
3838
runs-on: ubuntu-latest
@@ -46,7 +46,7 @@ jobs:
4646
- run: pip install --upgrade pip
4747
- run: pip install poetry
4848
- run: poetry install --with dev --extras server
49-
- run: poetry run pytest tests/ --show-capture=stdout
49+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
5050

5151
run-mypy-3_10:
5252
runs-on: ubuntu-latest
@@ -61,3 +61,17 @@ jobs:
6161
- run: pip install poetry
6262
- run: poetry install --with dev --extras server
6363
- run: poetry run mypy src/
64+
65+
run-ruff-lint:
66+
runs-on: ubuntu-latest
67+
name: Ruff linting on Python 3.10
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: actions/setup-python@v5
71+
with:
72+
python-version: "3.10"
73+
cache: 'pip'
74+
- run: pip install --upgrade pip
75+
- run: pip install poetry
76+
- run: poetry install --with dev --extras server
77+
- run: poetry run ruff check

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 23.3.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.6.8
45
hooks:
5-
- id: black
6-
# Latest version of Python supported by the project
7-
# See https://pre-commit.com/#top_level-default_language_version
8-
language_version: python3.9
6+
# Run the linter.
7+
- id: ruff
8+
# Run the formatter.
9+
- id: ruff-format

alembic/alembic_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# From https://improveandrepeat.com/2021/09/python-friday-87-handling-pre-existing-tables-with-alembic-and-sqlalchemy/
22
# Based on https://github.com/talkpython/data-driven-web-apps-with-flask
33

4-
from alembic import op
54
from sqlalchemy import engine_from_config
65
from sqlalchemy.engine import reflection
76

7+
from alembic import op
8+
89

910
def table_does_not_exist(table, schema=None):
1011
config = op.get_context().config

alembic/env.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from logging.config import fileConfig
21
import os
2+
from logging.config import fileConfig
33

4-
from sqlalchemy import engine_from_config
5-
from sqlalchemy import pool
4+
from sqlalchemy import engine_from_config, pool
65

76
from alembic import context
87

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import sqlalchemy as sa
2+
from sqlalchemy.orm import Session, configure_mappers
3+
4+
from mavedb.models import *
5+
6+
from mavedb.models.score_set import ScoreSet
7+
from mavedb.models.variant import Variant
8+
from mavedb.models.target_gene import TargetGene
9+
from mavedb.models.target_accession import TargetAccession
10+
11+
from mavedb.db.session import SessionLocal
12+
13+
configure_mappers()
14+
15+
16+
def do_migration(db: Session):
17+
accession_based_score_sets = db.execute(
18+
sa.select(ScoreSet).join(TargetGene).where(TargetGene.accession_id.isnot(None))
19+
).scalars()
20+
21+
for score_set in accession_based_score_sets:
22+
total_targets = len(
23+
list(db.execute(sa.select(TargetGene).where(TargetGene.score_set_id == score_set.id)).scalars())
24+
)
25+
26+
# Variants from score sets with multiple targets are already in the desired format.
27+
if total_targets > 1:
28+
continue
29+
30+
target_accession = db.execute(
31+
sa.select(TargetAccession.accession).join(TargetGene).where(TargetGene.score_set_id == score_set.id)
32+
).scalar()
33+
variants = db.execute(sa.select(Variant).where(Variant.score_set_id == score_set.id)).scalars()
34+
35+
if target_accession is None:
36+
raise ValueError("target accession should never be None.")
37+
38+
for variant in variants:
39+
if variant.hgvs_nt:
40+
variant.hgvs_nt = f"{target_accession}:{variant.hgvs_nt}"
41+
if variant.hgvs_pro:
42+
variant.hgvs_pro = f"{target_accession}:{variant.hgvs_pro}"
43+
if variant.hgvs_splice:
44+
variant.hgvs_splice = f"{target_accession}:{variant.hgvs_splice}"
45+
46+
db.add(variant)
47+
48+
49+
if __name__ == "__main__":
50+
db = SessionLocal()
51+
db.current_user = None # type: ignore
52+
53+
do_migration(db)
54+
55+
db.commit()
56+
db.close()

alembic/versions/194cfebabe32_rename_wild_type_sequence.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
Create Date: 2023-08-29 12:48:18.390567
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
108

9+
from alembic import op
1110

1211
# revision identifiers, used by Alembic.
1312
revision = "194cfebabe32"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""make index on contributors unique
2+
3+
Revision ID: 1cee01c42909
4+
Revises: 76e1e55bc5c1
5+
Create Date: 2024-09-03 09:53:21.635751
6+
7+
"""
8+
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "1cee01c42909"
13+
down_revision = "1d4933b4b6f7"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.drop_index("ix_contributors_orcid_id", table_name="contributors")
21+
op.create_index(op.f("ix_contributors_orcid_id"), "contributors", ["orcid_id"], unique=True)
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_index(op.f("ix_contributors_orcid_id"), table_name="contributors")
28+
op.create_index("ix_contributors_orcid_id", "contributors", ["orcid_id"], unique=False)
29+
# ### end Alembic commands ###

alembic/versions/1d4933b4b6f7_merge_76e1e55bc5c1_and_d7e6f8c3b9dc.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
Create Date: 2024-09-04 16:17:20.875937
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
10-
118

129
# revision identifiers, used by Alembic.
13-
revision = '1d4933b4b6f7'
14-
down_revision = ('76e1e55bc5c1', 'd7e6f8c3b9dc')
10+
revision = "1d4933b4b6f7"
11+
down_revision = ("76e1e55bc5c1", "d7e6f8c3b9dc")
1512
branch_labels = None
1613
depends_on = None
1714

alembic/versions/22e2d92d602e_add_publication_identifier_metadata_.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
Create Date: 2023-06-01 14:51:04.700969
66
77
"""
8-
from typing import Optional
8+
99
import os
10+
from typing import Optional
1011

1112
import eutils
12-
from eutils._internal.xmlfacades.pubmedarticleset import PubmedArticleSet
1313
import sqlalchemy as sa
1414
from eutils import EutilsNCBIError
15-
from mavedb.lib.exceptions import AmbiguousIdentifierError
15+
from eutils._internal.xmlfacades.pubmedarticleset import PubmedArticleSet
1616
from sqlalchemy.dialects.postgresql import JSONB
1717
from sqlalchemy.orm import Session
1818

1919
from alembic import op
20-
from mavedb.lib.identifiers import ExternalPublication
20+
from mavedb.lib.exceptions import AmbiguousIdentifierError
2121
from mavedb.lib.external_publications import Rxiv
22+
from mavedb.lib.identifiers import ExternalPublication
2223
from mavedb.models.publication_identifier import PublicationIdentifier
2324

2425
# revision identifiers, used by Alembic.

0 commit comments

Comments
 (0)