Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jul 24, 2024
1 parent 6c5dca1 commit 23f9438
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/cool_seq_tool/mappers/mane_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from cool_seq_tool.schemas import (
AnnotationLayer,
Assembly,
ManeGeneData,
ResidueMode,
Strand,
TranscriptPriority,
)
from cool_seq_tool.sources import (
ManeGeneData,
ManeTranscriptMappings,
TranscriptMappings,
UtaDatabase,
Expand Down
8 changes: 8 additions & 0 deletions src/cool_seq_tool/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ class BaseModelForbidExtra(BaseModel, extra="forbid"):
"""Base Pydantic model class with extra values forbidden."""


class ManeGeneData(BaseModel, extra="forbid"):
"""Define minimal object model for representing a MANE gene"""

ncbi_gene_id: StrictInt
hgnc_id: StrictInt | None
symbol: StrictStr


class TranscriptExonData(BaseModelForbidExtra):
"""Model containing transcript exon data."""

Expand Down
3 changes: 1 addition & 2 deletions src/cool_seq_tool/sources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Module for providing basic acquisition/setup for the various resources"""

from .mane_transcript_mappings import ManeGeneData, ManeTranscriptMappings
from .mane_transcript_mappings import ManeTranscriptMappings
from .transcript_mappings import TranscriptMappings
from .uta_database import UtaDatabase

__all__ = [
"ManeGeneData",
"ManeTranscriptMappings",
"TranscriptMappings",
"UtaDatabase",
Expand Down
10 changes: 1 addition & 9 deletions src/cool_seq_tool/sources/mane_transcript_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@
from pathlib import Path

import polars as pl
from pydantic import BaseModel, StrictInt, StrictStr

from cool_seq_tool.resources.data_files import DataFile, get_data_file
from cool_seq_tool.schemas import ManeGeneData

_logger = logging.getLogger(__name__)


class ManeGeneData(BaseModel, extra="forbid"):
"""Define minimal object model for representing a MANE gene"""

ncbi_gene_id: StrictInt
hgnc_id: StrictInt | None
symbol: StrictStr


class ManeTranscriptMappings:
"""Provide fast tabular access to MANE summary file.
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pytest

from cool_seq_tool.app import CoolSeqTool
from cool_seq_tool.schemas import Strand
from cool_seq_tool.sources import ManeGeneData
from cool_seq_tool.schemas import ManeGeneData, Strand


@pytest.fixture(scope="session")
Expand Down
25 changes: 21 additions & 4 deletions tests/mappers/test_mane_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,19 +671,36 @@ async def test_get_longest_compatible_transcript(test_mane_transcript):
@pytest.mark.asyncio()
async def test_g_to_grch38(test_mane_transcript, grch38_egfr, grch38_braf):
"""Test that g_to_grch38 method works correctly."""
resp = await test_mane_transcript.g_to_grch38("NC_000007.13", 55259515, 55259515)
resp = await test_mane_transcript.g_to_grch38(
"NC_000007.13", 55259515, 55259515, get_mane_genes=False
)
grch38_egfr_no_genes = grch38_egfr.copy()
grch38_egfr_no_genes.mane_genes = []
assert resp == grch38_egfr_no_genes

resp = await test_mane_transcript.g_to_grch38(
"NC_000007.13", 55259515, 55259515, get_mane_genes=True
)
assert resp == grch38_egfr

resp = await test_mane_transcript.g_to_grch38("NC_000007.13", 140453136, 140453136)
resp = await test_mane_transcript.g_to_grch38(
"NC_000007.13", 140453136, 140453136, get_mane_genes=True
)
assert resp == grch38_braf

resp = await test_mane_transcript.g_to_grch38(
"NC_000007.13", 140453135, 140453136, residue_mode=ResidueMode.INTER_RESIDUE
"NC_000007.13",
140453135,
140453136,
residue_mode=ResidueMode.INTER_RESIDUE,
get_mane_genes=True,
)
assert resp == grch38_braf

# Already on GRCh38
resp = await test_mane_transcript.g_to_grch38("NC_000007.14", 140753336, 140753336)
resp = await test_mane_transcript.g_to_grch38(
"NC_000007.14", 140753336, 140753336, get_mane_genes=True
)
assert resp == grch38_braf


Expand Down
2 changes: 1 addition & 1 deletion tests/sources/test_mane_transcript_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import polars as pl
import pytest

from cool_seq_tool.sources import ManeGeneData
from cool_seq_tool.schemas import ManeGeneData


@pytest.fixture(scope="module")
Expand Down

0 comments on commit 23f9438

Please sign in to comment.