Skip to content

Commit b12e0e2

Browse files
authored
build: update pydantic to v2 and remove GeneNormalizer class (#189)
- Update to pydantic v2 - Remove GeneNormalizer class (#187) - Temporarily remove `get_mapped_mane_data` since we do not have a Chromosome Location in VRS 2.0-alpha yet. Will be added back in #194 . I still left gene-normalizer dependency + instance variable in CoolSeqTool since it will be added back
1 parent e502616 commit b12e0e2

File tree

12 files changed

+365
-507
lines changed

12 files changed

+365
-507
lines changed

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ hgvs = "*"
1414
pydantic = "*"
1515
fastapi = "*"
1616
uvicorn = "*"
17-
gene-normalizer = ">=0.1.34, != 0.2.0, != 0.2.1, != 0.2.2, != 0.2.3, != 0.2.4, != 0.2.5, != 0.2.6, != 0.2.7, != 0.2.8"
18-
"ga4gh.vrs" = "*"
17+
gene-normalizer = "~=0.3.0.dev0"
18+
"ga4gh.vrs" = "~=2.0.0.dev0"
1919

2020
[dev-packages]
2121
cool_seq_tool = {editable = true, path = "."}

cool_seq_tool/app.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from biocommons.seqrepo import SeqRepo
88
from gene.query import QueryHandler as GeneQueryHandler
9+
from gene.database import create_db
910

1011
from cool_seq_tool.data_sources.alignment_mapper import AlignmentMapper
1112
from cool_seq_tool.data_sources.uta_database import UTA_DB_URL
@@ -14,7 +15,7 @@
1415
from cool_seq_tool.schemas import Assembly, GenomicData, TranscriptExonData, \
1516
ResidueMode, GenomicDataResponse, ServiceMeta, TranscriptExonDataResponse
1617
from cool_seq_tool.data_sources import MANETranscript, MANETranscriptMappings, \
17-
SeqRepoAccess, TranscriptMappings, UTADatabase, GeneNormalizer
18+
SeqRepoAccess, TranscriptMappings, UTADatabase
1819
from cool_seq_tool.version import __version__
1920

2021

@@ -34,25 +35,19 @@ def __init__(
3435
lrg_refseqgene_path: Path = LRG_REFSEQGENE_PATH,
3536
mane_data_path: Path = MANE_SUMMARY_PATH,
3637
db_url: str = UTA_DB_URL, gene_query_handler: Optional[GeneQueryHandler] = None,
37-
gene_db_url: str = "", gene_db_region: str = "us-east-2",
3838
sr: Optional[SeqRepo] = None
3939
) -> None:
4040
"""Initialize CoolSeqTool class
4141
42-
:param Path transcript_file_path: The path to transcript_mapping.tsv
43-
:param Path lrg_refseqgene_path: The path to LRG_RefSeqGene
44-
:param Path mane_data_path: Path to RefSeq MANE summary data
45-
:param str db_url: PostgreSQL connection URL
42+
:param transcript_file_path: The path to transcript_mapping.tsv
43+
:param lrg_refseqgene_path: The path to LRG_RefSeqGene
44+
:param mane_data_path: Path to RefSeq MANE summary data
45+
:param db_url: PostgreSQL connection URL
4646
Format: `driver://user:password@host/database/schema`
47-
:param Optional[GeneQueryHandler] gene_query_handler: Gene normalizer query
48-
handler instance. If this is provided, will use a current instance. If this
49-
is not provided, will create a new instance.
50-
:param str gene_db_url: URL to gene normalizer dynamodb. Only used when
51-
`gene_query_handler` is `None`.
52-
:param str gene_db_region: AWS region for gene normalizer db. Only used when
53-
`gene_query_handler` is `None`.
54-
:param Optional[SeqRepo] sr: SeqRepo instance. If this is not provided, will
55-
create a new instance.
47+
:param gene_query_handler: Gene normalizer query handler instance. If this is
48+
provided, will use a current instance. If this is not provided, will create
49+
a new instance.
50+
:param sr: SeqRepo instance. If this is not provided, will create a new instance
5651
"""
5752
if not sr:
5853
sr = SeqRepo(root_dir=SEQREPO_ROOT_DIR)
@@ -63,14 +58,14 @@ def __init__(
6358
self.mane_transcript_mappings = MANETranscriptMappings(
6459
mane_data_path=mane_data_path)
6560
self.uta_db = UTADatabase(db_url=db_url)
66-
gene_normalizer = GeneNormalizer(gene_query_handler, gene_db_url,
67-
gene_db_region)
68-
self.gene_query_handler = gene_normalizer.query_handler
61+
if not gene_query_handler:
62+
gene_query_handler = GeneQueryHandler(create_db())
63+
self.gene_query_handler = gene_query_handler
6964
self.alignment_mapper = AlignmentMapper(
7065
self.seqrepo_access, self.transcript_mappings, self.uta_db)
7166
self.mane_transcript = MANETranscript(
7267
self.seqrepo_access, self.transcript_mappings,
73-
self.mane_transcript_mappings, self.uta_db, gene_normalizer)
68+
self.mane_transcript_mappings, self.uta_db)
7469

7570
@staticmethod
7671
def service_meta() -> ServiceMeta:
@@ -242,7 +237,7 @@ async def genomic_to_transcript_exon_coordinates(
242237
residue_mode=ResidueMode.INTER_RESIDUE
243238
)
244239
if start_data.transcript_exon_data:
245-
start_data = start_data.transcript_exon_data.dict()
240+
start_data = start_data.transcript_exon_data.model_dump()
246241
else:
247242
return self._return_warnings(resp, start_data.warnings[0])
248243
else:
@@ -257,7 +252,7 @@ async def genomic_to_transcript_exon_coordinates(
257252
residue_mode=ResidueMode.INTER_RESIDUE
258253
)
259254
if end_data.transcript_exon_data:
260-
end_data = end_data.transcript_exon_data.dict()
255+
end_data = end_data.transcript_exon_data.model_dump()
261256
else:
262257
return self._return_warnings(resp, end_data.warnings[0])
263258
else:

cool_seq_tool/data_sources/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
from .mane_transcript_mappings import MANETranscriptMappings
44
from .transcript_mappings import TranscriptMappings
55
from .uta_database import UTADatabase
6-
from .gene_normalizer import GeneNormalizer
76
from .mane_transcript import MANETranscript
87
from .alignment_mapper import AlignmentMapper

cool_seq_tool/data_sources/gene_normalizer.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)