-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-2024.4.2' into feature/bencap/251/variant-mappi…
…ng-script
- Loading branch information
Showing
182 changed files
with
5,857 additions
and
2,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.6.8 | ||
hooks: | ||
- id: black | ||
# Latest version of Python supported by the project | ||
# See https://pre-commit.com/#top_level-default_language_version | ||
language_version: python3.9 | ||
# Run the linter. | ||
- id: ruff | ||
# Run the formatter. | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ual_migrations/migrate_single_target_endogenous_edit_transcripts_to_be_fully_qualified.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sqlalchemy as sa | ||
from sqlalchemy.orm import Session, configure_mappers | ||
|
||
from mavedb.models import * | ||
|
||
from mavedb.models.score_set import ScoreSet | ||
from mavedb.models.variant import Variant | ||
from mavedb.models.target_gene import TargetGene | ||
from mavedb.models.target_accession import TargetAccession | ||
|
||
from mavedb.db.session import SessionLocal | ||
|
||
configure_mappers() | ||
|
||
|
||
def do_migration(db: Session): | ||
accession_based_score_sets = db.execute( | ||
sa.select(ScoreSet).join(TargetGene).where(TargetGene.accession_id.isnot(None)) | ||
).scalars() | ||
|
||
for score_set in accession_based_score_sets: | ||
total_targets = len( | ||
list(db.execute(sa.select(TargetGene).where(TargetGene.score_set_id == score_set.id)).scalars()) | ||
) | ||
|
||
# Variants from score sets with multiple targets are already in the desired format. | ||
if total_targets > 1: | ||
continue | ||
|
||
target_accession = db.execute( | ||
sa.select(TargetAccession.accession).join(TargetGene).where(TargetGene.score_set_id == score_set.id) | ||
).scalar() | ||
variants = db.execute(sa.select(Variant).where(Variant.score_set_id == score_set.id)).scalars() | ||
|
||
if target_accession is None: | ||
raise ValueError("target accession should never be None.") | ||
|
||
for variant in variants: | ||
if variant.hgvs_nt: | ||
variant.hgvs_nt = f"{target_accession}:{variant.hgvs_nt}" | ||
if variant.hgvs_pro: | ||
variant.hgvs_pro = f"{target_accession}:{variant.hgvs_pro}" | ||
if variant.hgvs_splice: | ||
variant.hgvs_splice = f"{target_accession}:{variant.hgvs_splice}" | ||
|
||
db.add(variant) | ||
|
||
|
||
if __name__ == "__main__": | ||
db = SessionLocal() | ||
db.current_user = None # type: ignore | ||
|
||
do_migration(db) | ||
|
||
db.commit() | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
alembic/versions/1cee01c42909_make_index_on_contributors_unique.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""make index on contributors unique | ||
Revision ID: 1cee01c42909 | ||
Revises: 76e1e55bc5c1 | ||
Create Date: 2024-09-03 09:53:21.635751 | ||
""" | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "1cee01c42909" | ||
down_revision = "1d4933b4b6f7" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index("ix_contributors_orcid_id", table_name="contributors") | ||
op.create_index(op.f("ix_contributors_orcid_id"), "contributors", ["orcid_id"], unique=True) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_contributors_orcid_id"), table_name="contributors") | ||
op.create_index("ix_contributors_orcid_id", "contributors", ["orcid_id"], unique=False) | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Add score range column | ||
Revision ID: 2b6f40ea2fb6 | ||
Revises: 1d4933b4b6f7 | ||
Create Date: 2024-09-09 12:25:33.180077 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2b6f40ea2fb6" | ||
down_revision = "1cee01c42909" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("scoresets", sa.Column("score_ranges", postgresql.JSONB(astext_type=sa.Text()), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("scoresets", "score_ranges") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.