Skip to content

Commit f592774

Browse files
authored
Merge pull request #104 from cancervariants/gene-normalizer
Gene normalizer fix
2 parents 83224db + 50c4a00 commit f592774

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ pyproject.toml
3737
# Zip
3838
*.zip
3939

40-
build/
40+
build/
41+
dynamodb_local_latest/

variant/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import logging
55
from ftplib import FTP
66
from os import environ
7+
from gene.query import QueryHandler as GeneQueryHandler
78

8-
__version__ = "0.2.0"
9+
__version__ = "0.2.1"
910

1011
APP_ROOT = Path(__file__).resolve().parents[0]
1112

@@ -16,6 +17,8 @@
1617
else:
1718
LOG_FN = f'{APP_ROOT}/variant/variant.log'
1819

20+
GENE_NORMALIZER = GeneQueryHandler()
21+
1922
logger = logging.getLogger('variant')
2023
if Path(LOG_FN).exists():
2124
fhandler = logging.FileHandler(filename=LOG_FN)

variant/data_sources/transcript_mappings.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Dict, List, Optional
44
from variant.schemas.validation_response_schema import LookupType
55
from variant import TRANSCRIPT_MAPPINGS_PATH, REFSEQ_GENE_SYMBOL_PATH
6-
from gene.query import QueryHandler as GeneQueryHandler
76

87

98
class TranscriptMappings:
@@ -39,8 +38,6 @@ def __init__(self, transcript_file_path=TRANSCRIPT_MAPPINGS_PATH,
3938
self.refseq_lrg_for_gene_symbol: Dict[str, List[str]] = {}
4039
self.refseq_lrg_to_gene_symbol: Dict[str, str] = {}
4140

42-
self.gene_query_handler = GeneQueryHandler()
43-
4441
self._load_transcript_mappings_data(transcript_file_path)
4542
self._load_refseq_gene_symbol_data(refseq_file_path)
4643

variant/normalize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Module for Variant Normalization."""
22
from typing import Tuple, Optional
3+
from variant import GENE_NORMALIZER
34
from variant.schemas.token_response_schema import PolypeptideSequenceVariant,\
45
SingleNucleotideVariant, DelIns, AminoAcidDelInsToken
56
from variant.schemas.ga4gh_vod import Gene, VariationDescriptor, GeneDescriptor
67
from variant.data_sources import SeqRepoAccess
7-
from gene.query import QueryHandler as GeneQueryHandler
88
from urllib.parse import quote
99
from variant import logger
1010

@@ -14,7 +14,6 @@ class Normalize:
1414

1515
def __init__(self):
1616
"""Initialize Normalize class."""
17-
self.gene_query_handler = GeneQueryHandler()
1817
self.seqrepo_access = SeqRepoAccess()
1918
self.warnings = list()
2019

@@ -84,8 +83,7 @@ def get_gene_descriptor(self, gene_token):
8483
gene-normalizer.
8584
"""
8685
gene_symbol = gene_token.matched_value
87-
response = self.gene_query_handler.search_sources(gene_symbol,
88-
incl='hgnc')
86+
response = GENE_NORMALIZER.search_sources(gene_symbol, incl='hgnc')
8987
if response['source_matches'][0]['records']:
9088
record = response['source_matches'][0]['records'][0]
9189
record_location = record.locations[0] if record.locations else None

variant/validators/genomic_base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Module for Genomic Validation methods."""
2-
from gene.query import QueryHandler as GeneQueryHandler
2+
from variant import GENE_NORMALIZER
33
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
44
import logging
55

@@ -29,9 +29,8 @@ def get_nc_accessions(self, classification):
2929
gene_tokens = [t for t in classification.all_tokens
3030
if t.token_type == 'GeneSymbol']
3131
if gene_tokens and len(gene_tokens) == 1:
32-
gene_query_handler = GeneQueryHandler()
33-
resp = gene_query_handler.search_sources(gene_tokens[0].token,
34-
incl='hgnc')
32+
resp = GENE_NORMALIZER.search_sources(gene_tokens[0].token,
33+
incl='hgnc')
3534
if resp['source_matches'][0]['records']:
3635
record = resp['source_matches'][0]['records'][0]
3736
loc = record.locations[0] if record.locations else None

0 commit comments

Comments
 (0)