Skip to content

Commit 82cc0d6

Browse files
authored
Merge pull request #362 from VariantEffect/release-2024.4.2
Release 2024.4.2
2 parents 65dd9cb + f772db4 commit 82cc0d6

Some content is hidden

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

59 files changed

+2017
-630
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import sqlalchemy as sa
2+
from sqlalchemy.orm import Session, configure_mappers
3+
4+
from mavedb.models import *
5+
from mavedb.models.enums.target_category import TargetCategory
6+
from mavedb.models.target_gene import TargetGene
7+
8+
from mavedb.db.session import SessionLocal
9+
10+
configure_mappers()
11+
12+
def api_like_target_gene_category(category: str):
13+
if category == "Protein coding":
14+
return TargetCategory.protein_coding
15+
elif category == "Other noncoding":
16+
return TargetCategory.other_noncoding
17+
elif category == "Regulatory":
18+
return TargetCategory.regulatory
19+
else:
20+
raise ValueError()
21+
22+
23+
def do_migration(db: Session):
24+
target_genes = db.scalars(sa.select(TargetGene)).all()
25+
26+
for target in target_genes:
27+
target.category = api_like_target_gene_category(target.category)
28+
db.add(target)
29+
30+
db.commit()
31+
32+
33+
if __name__ == "__main__":
34+
db = SessionLocal()
35+
db.current_user = None # type: ignore
36+
37+
do_migration(db)
38+
39+
db.commit()
40+
db.close()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sqlalchemy as sa
2+
from sqlalchemy.orm import Session, configure_mappers
3+
4+
from mavedb.models import *
5+
6+
from mavedb.lib.score_sets import refresh_variant_urns
7+
8+
from mavedb.models.score_set import ScoreSet
9+
from mavedb.models.variant import Variant
10+
11+
from mavedb.db.session import SessionLocal
12+
13+
configure_mappers()
14+
15+
16+
def do_migration(db: Session):
17+
published_score_sets_with_associated_tmp_variants: sa.ScalarResult[str]
18+
published_score_sets_with_associated_tmp_variants = db.execute(
19+
sa.select(sa.distinct(ScoreSet.urn)).join(Variant).where(ScoreSet.published_date.is_not(None), Variant.urn.like("%tmp:%"))
20+
).scalars()
21+
22+
for score_set_urn in published_score_sets_with_associated_tmp_variants:
23+
refresh_variant_urns(db, db.execute(sa.select(ScoreSet).where(ScoreSet.urn == score_set_urn)).scalar_one())
24+
25+
26+
if __name__ == "__main__":
27+
db = SessionLocal()
28+
db.current_user = None # type: ignore
29+
30+
do_migration(db)
31+
32+
db.commit()
33+
db.close()
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Target category enum
2+
3+
Revision ID: 03c7124c33e1
4+
Revises: 2b6f40ea2fb6
5+
Create Date: 2024-11-01 11:27:03.609116
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "03c7124c33e1"
15+
down_revision = "2b6f40ea2fb6"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.alter_column(
23+
"target_genes",
24+
"category",
25+
type_=sa.Enum(
26+
"protein_coding",
27+
"other_noncoding",
28+
"regulatory",
29+
name="targetcategory",
30+
native_enum=False,
31+
create_constraint=True,
32+
length=32,
33+
),
34+
)
35+
# ### end Alembic commands ###
36+
37+
38+
def downgrade():
39+
# ### commands auto generated by Alembic - please adjust! ###
40+
op.alter_column(
41+
"target_genes",
42+
"category",
43+
type_=sa.String(),
44+
existing_type=sa.Enum(
45+
"protein_coding",
46+
"other_noncoding",
47+
"regulatory",
48+
name="targetcategory",
49+
native_enum=False,
50+
create_constraint=True,
51+
length=32,
52+
),
53+
)
54+
# ### end Alembic commands ###

alembic/versions/2b6f40ea2fb6_add_score_range_column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Add score range column
22
33
Revision ID: 2b6f40ea2fb6
4-
Revises: 1d4933b4b6f7
4+
Revises: 1cee01c42909
55
Create Date: 2024-09-09 12:25:33.180077
66
77
"""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Add active column to licenses
2+
3+
Revision ID: 68a0ec57694e
4+
Revises: 03c7124c33e1
5+
Create Date: 2024-10-22 15:36:41.868909
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "68a0ec57694e"
15+
down_revision = "03c7124c33e1"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.add_column("licenses", sa.Column("active", sa.Boolean(), nullable=False, server_default=sa.true()))
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column("licenses", "active")
29+
# ### end Alembic commands ###

poetry.lock

Lines changed: 307 additions & 248 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "mavedb"
7-
version = "2024.4.1"
7+
version = "2024.4.2"
88
description = "API for MaveDB, the database of Multiplexed Assays of Variant Effect."
99
license = "AGPL-3.0-only"
1010
readme = "README.md"
@@ -26,7 +26,7 @@ python = "^3.9"
2626

2727
fqfa = "~1.3.0"
2828
pyhumps = "~3.8.0"
29-
pyyaml = "~5.1"
29+
pyyaml = "~6.0.1"
3030
IDUtils = "~1.2.0"
3131
mavehgvs = "~0.6.0"
3232
eutils = "~0.6.0"
@@ -99,6 +99,7 @@ mypy_path = "mypy_stubs"
9999
addopts = "-v -rP --import-mode=importlib --disable-socket --allow-hosts localhost,::1,127.0.0.1"
100100
asyncio_mode = 'strict'
101101
testpaths = "tests/"
102+
pythonpath = "."
102103
norecursedirs = "tests/helpers/"
103104
# Uncomment the following lines to include application log output in Pytest logs.
104105
# log_cli = true

src/mavedb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
logger = module_logging.getLogger(__name__)
77

88
__project__ = "mavedb-api"
9-
__version__ = "2024.4.1"
9+
__version__ = "2024.4.2"
1010

1111
logger.info(f"MaveDB {__version__}")

src/mavedb/lib/experiments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def search_experiments(
9999
)
100100
)
101101

102-
items: list[Experiment] = query.order_by(Experiment.title).all()
102+
items: list[Experiment] = query.order_by(Experiment.urn, Experiment.title).all()
103103
if not items:
104104
items = []
105105

src/mavedb/lib/score_sets.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,21 @@ def create_variants(db, score_set: ScoreSet, variants_data: list[VariantData], b
617617
return len(score_set.variants)
618618

619619

620+
def refresh_variant_urns(db: Session, score_set: ScoreSet):
621+
variants = db.execute(select(Variant).where(Variant.score_set_id == score_set.id)).scalars()
622+
623+
for variant in variants:
624+
if not variant.urn:
625+
raise ValueError("All variants should have an associated URN.")
626+
627+
variant_number = variant.urn.split("#")[1]
628+
refreshed_urn = f"{score_set.urn}#{variant_number}"
629+
variant.urn = refreshed_urn
630+
db.add(variant)
631+
632+
db.commit()
633+
634+
620635
def bulk_create_urns(n, score_set, reset_counter=False) -> list[str]:
621636
start_value = 0 if reset_counter else score_set.num_variants
622637
parent_urn = score_set.urn

0 commit comments

Comments
 (0)