diff --git a/src/alembic/versions/77076df4224c_add_tx_hgnc_index.py b/src/alembic/versions/77076df4224c_add_tx_hgnc_index.py new file mode 100644 index 0000000..0a684a2 --- /dev/null +++ b/src/alembic/versions/77076df4224c_add_tx_hgnc_index.py @@ -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 ### diff --git a/src/alembic/versions/f85dd97bd9f5_set_gene_id_and_primary_and_foreign_keys.py b/src/alembic/versions/f85dd97bd9f5_set_gene_id_and_primary_and_foreign_keys.py index 446fae1..1548b95 100644 --- a/src/alembic/versions/f85dd97bd9f5_set_gene_id_and_primary_and_foreign_keys.py +++ b/src/alembic/versions/f85dd97bd9f5_set_gene_id_and_primary_and_foreign_keys.py @@ -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;") diff --git a/src/uta/models.py b/src/uta/models.py index 6dea5ca..a8ec1dd 100644 --- a/src/uta/models.py +++ b/src/uta/models.py @@ -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") diff --git a/tests/test_uta_loading.py b/tests/test_uta_loading.py index 902ccfb..210d2ab 100644 --- a/tests/test_uta_loading.py +++ b/tests/test_uta_loading.py @@ -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', }, ) @@ -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', }, )