Skip to content

Commit

Permalink
feat(/IPVC-2695): Updates needed to retain HGNC on transcript (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsgiles73 authored Aug 26, 2024
1 parent d33f0d0 commit 684c804
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
30 changes: 30 additions & 0 deletions src/alembic/versions/77076df4224c_add_tx_hgnc_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""hgnc test
Revision ID: 77076df4224c
Revises: 19561fe444c8
Create Date: 2024-08-26 17:08:13.160259
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '77076df4224c'
down_revision: Union[str, None] = '19561fe444c8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_uta_transcript_hgnc'), 'transcript', ['hgnc'], unique=False, schema='uta')
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_uta_transcript_hgnc'), table_name='transcript', schema='uta')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,8 @@ def upgrade() -> None:
""")
# ### end of updates to existing views ###

# ### drop hgnc from transcript ###
op.drop_column('transcript', 'hgnc', schema='uta')
# ### end Alembic commands ###


def downgrade() -> None:
# ### updates to views to add hgnc to transcript ###
op.add_column('transcript', sa.Column('hgnc', sa.Text(), nullable=True), schema='uta')
# ### end of updates to transcript ###

# ### commands to downgrade views before adding hgnc to transcript ###
op.execute("DROP VIEW IF EXISTS tx_similarity_v CASCADE;")
op.execute("DROP MATERIALIZED VIEW IF EXISTS tx_def_summary_mv CASCADE;")
Expand Down
3 changes: 2 additions & 1 deletion src/uta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ class Transcript(Base):
origin_id = sa.Column(
sa.Integer, sa.ForeignKey("origin.origin_id", onupdate="CASCADE", ondelete="CASCADE"), nullable=False, index=True)
gene_id = sa.Column(sa.Text, sa.ForeignKey("gene.gene_id"), nullable=False, index=True)
hgnc = sa.Column(sa.Text, nullable=True, index=True)
cds_start_i = sa.Column(sa.Integer)
cds_end_i = sa.Column(sa.Integer)
cds_md5 = sa.Column(sa.Text, index=True)
added = sa.Column(
sa.DateTime, default=datetime.datetime.now(), nullable=False)
codon_table = sa.Column(sa.Integer, nullable=False, server_default='1') # 1 = standard, 2 = mitochondrial
codon_table = sa.Column(sa.Text, nullable=True, server_default='1') # 1 = standard, 2 = mitochondrial

# relationships:
origin = sao.relationship("Origin", backref="transcripts")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_uta_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_load_txinfo(self):
'gene_id': '140606',
'cds_start_i': 63,
'cds_end_i': 501,
'codon_table': 1,
'codon_table': '1',
},
)

Expand All @@ -232,7 +232,7 @@ def test_load_txinfo(self):
'gene_id': '4514',
'cds_start_i': 0,
'cds_end_i': 784,
'codon_table': 2,
'codon_table': '2',
},
)

Expand Down

0 comments on commit 684c804

Please sign in to comment.