Skip to content

Commit

Permalink
build: update pydantic to v2 and remove GeneNormalizer class (#189)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
korikuzma authored Sep 11, 2023
1 parent e502616 commit b12e0e2
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 507 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ hgvs = "*"
pydantic = "*"
fastapi = "*"
uvicorn = "*"
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"
"ga4gh.vrs" = "*"
gene-normalizer = "~=0.3.0.dev0"
"ga4gh.vrs" = "~=2.0.0.dev0"

[dev-packages]
cool_seq_tool = {editable = true, path = "."}
Expand Down
37 changes: 16 additions & 21 deletions cool_seq_tool/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from biocommons.seqrepo import SeqRepo
from gene.query import QueryHandler as GeneQueryHandler
from gene.database import create_db

from cool_seq_tool.data_sources.alignment_mapper import AlignmentMapper
from cool_seq_tool.data_sources.uta_database import UTA_DB_URL
Expand All @@ -14,7 +15,7 @@
from cool_seq_tool.schemas import Assembly, GenomicData, TranscriptExonData, \
ResidueMode, GenomicDataResponse, ServiceMeta, TranscriptExonDataResponse
from cool_seq_tool.data_sources import MANETranscript, MANETranscriptMappings, \
SeqRepoAccess, TranscriptMappings, UTADatabase, GeneNormalizer
SeqRepoAccess, TranscriptMappings, UTADatabase
from cool_seq_tool.version import __version__


Expand All @@ -34,25 +35,19 @@ def __init__(
lrg_refseqgene_path: Path = LRG_REFSEQGENE_PATH,
mane_data_path: Path = MANE_SUMMARY_PATH,
db_url: str = UTA_DB_URL, gene_query_handler: Optional[GeneQueryHandler] = None,
gene_db_url: str = "", gene_db_region: str = "us-east-2",
sr: Optional[SeqRepo] = None
) -> None:
"""Initialize CoolSeqTool class
:param Path transcript_file_path: The path to transcript_mapping.tsv
:param Path lrg_refseqgene_path: The path to LRG_RefSeqGene
:param Path mane_data_path: Path to RefSeq MANE summary data
:param str db_url: PostgreSQL connection URL
:param transcript_file_path: The path to transcript_mapping.tsv
:param lrg_refseqgene_path: The path to LRG_RefSeqGene
:param mane_data_path: Path to RefSeq MANE summary data
:param db_url: PostgreSQL connection URL
Format: `driver://user:password@host/database/schema`
:param Optional[GeneQueryHandler] gene_query_handler: Gene normalizer query
handler instance. If this is provided, will use a current instance. If this
is not provided, will create a new instance.
:param str gene_db_url: URL to gene normalizer dynamodb. Only used when
`gene_query_handler` is `None`.
:param str gene_db_region: AWS region for gene normalizer db. Only used when
`gene_query_handler` is `None`.
:param Optional[SeqRepo] sr: SeqRepo instance. If this is not provided, will
create a new instance.
:param gene_query_handler: Gene normalizer query handler instance. If this is
provided, will use a current instance. If this is not provided, will create
a new instance.
:param sr: SeqRepo instance. If this is not provided, will create a new instance
"""
if not sr:
sr = SeqRepo(root_dir=SEQREPO_ROOT_DIR)
Expand All @@ -63,14 +58,14 @@ def __init__(
self.mane_transcript_mappings = MANETranscriptMappings(
mane_data_path=mane_data_path)
self.uta_db = UTADatabase(db_url=db_url)
gene_normalizer = GeneNormalizer(gene_query_handler, gene_db_url,
gene_db_region)
self.gene_query_handler = gene_normalizer.query_handler
if not gene_query_handler:
gene_query_handler = GeneQueryHandler(create_db())
self.gene_query_handler = gene_query_handler
self.alignment_mapper = AlignmentMapper(
self.seqrepo_access, self.transcript_mappings, self.uta_db)
self.mane_transcript = MANETranscript(
self.seqrepo_access, self.transcript_mappings,
self.mane_transcript_mappings, self.uta_db, gene_normalizer)
self.mane_transcript_mappings, self.uta_db)

@staticmethod
def service_meta() -> ServiceMeta:
Expand Down Expand Up @@ -242,7 +237,7 @@ async def genomic_to_transcript_exon_coordinates(
residue_mode=ResidueMode.INTER_RESIDUE
)
if start_data.transcript_exon_data:
start_data = start_data.transcript_exon_data.dict()
start_data = start_data.transcript_exon_data.model_dump()
else:
return self._return_warnings(resp, start_data.warnings[0])
else:
Expand All @@ -257,7 +252,7 @@ async def genomic_to_transcript_exon_coordinates(
residue_mode=ResidueMode.INTER_RESIDUE
)
if end_data.transcript_exon_data:
end_data = end_data.transcript_exon_data.dict()
end_data = end_data.transcript_exon_data.model_dump()
else:
return self._return_warnings(resp, end_data.warnings[0])
else:
Expand Down
1 change: 0 additions & 1 deletion cool_seq_tool/data_sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
from .mane_transcript_mappings import MANETranscriptMappings
from .transcript_mappings import TranscriptMappings
from .uta_database import UTADatabase
from .gene_normalizer import GeneNormalizer
from .mane_transcript import MANETranscript
from .alignment_mapper import AlignmentMapper
49 changes: 0 additions & 49 deletions cool_seq_tool/data_sources/gene_normalizer.py

This file was deleted.

Loading

0 comments on commit b12e0e2

Please sign in to comment.