Skip to content

Commit 3ca62ca

Browse files
authored
Merge pull request #139 from cancervariants/issue-114-cleanup
Clean up handling queries, dont initialize gene-normalizer in init
2 parents f38fb5b + 9f3a048 commit 3ca62ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+278
-161
lines changed

tests/classifiers/classifier_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import yaml
33
from variation.tokenizers import Tokenize
44
from tests import PROJECT_ROOT
5+
from variation.tokenizers.caches import AminoAcidCache
6+
from variation.tokenizers import GeneSymbol
7+
from gene.query import QueryHandler as GeneQueryHandler
58

69

710
class ClassifierBase:
@@ -16,7 +19,8 @@ def setUp(self):
1619
{'should_match': [], 'should_not_match': []}
1720
)
1821
self.classifier = self.classifier_instance()
19-
self.tokenizer = Tokenize()
22+
self.tokenizer = Tokenize(AminoAcidCache(),
23+
GeneSymbol(GeneQueryHandler()))
2024

2125
def classifier_instance(self):
2226
"""Check that the classifier_instance method is implemented."""

tests/test_normalize.py

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
"""Module for testing the normalize endpoint."""
22
import pytest
3-
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
4-
from ga4gh.vrs.extras.translator import Translator
5-
from variation.normalize import Normalize
3+
from variation.query import QueryHandler
64
from variation.schemas.ga4gh_vrsatile import VariationDescriptor
7-
from variation.to_vrs import ToVRS
8-
from variation.main import normalize as normalize_get_response
9-
from variation.main import translate as to_vrs_get_response
10-
from variation.classifiers import Classify
11-
from variation.tokenizers import Tokenize
12-
from variation.validators import Validate
13-
from variation.translators import Translate
14-
from variation.data_sources import SeqRepoAccess, TranscriptMappings, \
15-
UTA, MANETranscriptMappings
16-
from variation.mane_transcript import MANETranscript
17-
from variation.tokenizers import GeneSymbol
18-
from variation.tokenizers.caches import AminoAcidCache
195
from datetime import datetime
6+
from variation.main import normalize as normalize_get_response
7+
from variation.main import to_vrs as to_vrs_get_response
208
import copy
219

2210

@@ -26,40 +14,13 @@ def test_normalize():
2614
class TestNormalize:
2715

2816
def __init__(self):
29-
tokenizer = Tokenize()
30-
classifier = Classify()
31-
seqrepo_access = SeqRepoAccess()
32-
transcript_mappings = TranscriptMappings()
33-
gene_symbol = GeneSymbol()
34-
amino_acid_cache = AminoAcidCache()
35-
uta = UTA()
36-
mane_transcript_mappings = MANETranscriptMappings()
37-
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
38-
tlr = Translator(data_proxy=dp)
39-
mane_transcript = MANETranscript(seqrepo_access,
40-
transcript_mappings,
41-
mane_transcript_mappings, uta)
42-
validator = Validate(seqrepo_access, transcript_mappings,
43-
gene_symbol, mane_transcript, uta,
44-
dp, tlr, amino_acid_cache)
45-
translator = Translate()
46-
47-
self.to_vrs = ToVRS(tokenizer, classifier, seqrepo_access,
48-
transcript_mappings, gene_symbol,
49-
amino_acid_cache, uta,
50-
mane_transcript_mappings, mane_transcript,
51-
validator, translator)
52-
self.test_normalize = Normalize(seqrepo_access, uta)
17+
self.query_handler = QueryHandler()
18+
19+
def to_vrs(self, q):
20+
return self.query_handler.to_vrs(q)
5321

5422
def normalize(self, q):
55-
validations, warnings = self.to_vrs.get_validations(
56-
q, normalize_endpoint=True
57-
)
58-
resp = \
59-
self.test_normalize.normalize(q,
60-
validations,
61-
warnings)
62-
return resp
23+
return self.query_handler.normalize(q)
6324

6425
return TestNormalize()
6526

tests/tokenizers/test_gene.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import unittest
33
from variation.tokenizers import GeneSymbol
44
from .tokenizer_base import TokenizerBase
5+
from gene.query import QueryHandler as GeneQueryHandler
56

67

78
class TestGenePairTokenizer(TokenizerBase, unittest.TestCase):
89
"""The Gene Pair Tokenizer class."""
910

1011
def tokenizer_instance(self):
1112
"""Return the Gene Pair tokenizer instance."""
12-
return GeneSymbol()
13+
return GeneSymbol(GeneQueryHandler())
1314

1415
def token_type(self):
1516
"""Return the Gene Pair token type."""

tests/translators/test_amino_acid_deletion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from variation.mane_transcript import MANETranscript
1212
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1313
from ga4gh.vrs.extras.translator import Translator
14+
from gene.query import QueryHandler as GeneQueryHandler
1415

1516

1617
class TestAminoAcidDeletionTranslator(TranslatorBase, unittest.TestCase):
@@ -28,7 +29,8 @@ def validator_instance(self):
2829
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2930
tlr = Translator(data_proxy=dp)
3031
return AAD_V(
31-
seqrepo_access, transcript_mappings, GeneSymbol(),
32+
seqrepo_access, transcript_mappings,
33+
GeneSymbol(GeneQueryHandler()),
3234
MANETranscript(seqrepo_access, transcript_mappings,
3335
MANETranscriptMappings(), uta),
3436
uta, dp, tlr, AminoAcidCache())

tests/translators/test_amino_acid_delins.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from variation.mane_transcript import MANETranscript
1212
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1313
from ga4gh.vrs.extras.translator import Translator
14+
from gene.query import QueryHandler as GeneQueryHandler
1415

1516

1617
class TestAminoAcidDelInsTranslator(TranslatorBase, unittest.TestCase):
@@ -28,7 +29,8 @@ def validator_instance(self):
2829
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2930
tlr = Translator(data_proxy=dp)
3031
return AAD_V(
31-
seqrepo_access, transcript_mappings, GeneSymbol(),
32+
seqrepo_access, transcript_mappings,
33+
GeneSymbol(GeneQueryHandler()),
3234
MANETranscript(seqrepo_access, transcript_mappings,
3335
MANETranscriptMappings(), uta),
3436
uta, dp, tlr, AminoAcidCache())

tests/translators/test_amino_acid_insertion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from variation.mane_transcript import MANETranscript
1212
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1313
from ga4gh.vrs.extras.translator import Translator
14+
from gene.query import QueryHandler as GeneQueryHandler
1415

1516

1617
class TestAminoAcidInsertionTranslator(TranslatorBase, unittest.TestCase):
@@ -28,7 +29,8 @@ def validator_instance(self):
2829
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2930
tlr = Translator(data_proxy=dp)
3031
return AAI_V(
31-
seqrepo_access, transcript_mappings, GeneSymbol(),
32+
seqrepo_access, transcript_mappings,
33+
GeneSymbol(GeneQueryHandler()),
3234
MANETranscript(seqrepo_access, transcript_mappings,
3335
MANETranscriptMappings(), uta),
3436
uta, dp, tlr, AminoAcidCache())

tests/translators/test_amino_acid_substitution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from variation.mane_transcript import MANETranscript
1212
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1313
from ga4gh.vrs.extras.translator import Translator
14+
from gene.query import QueryHandler as GeneQueryHandler
1415

1516

1617
class TestAminoAcidSubstitutionTranslator(TranslatorBase, unittest.TestCase):
@@ -28,7 +29,8 @@ def validator_instance(self):
2829
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2930
tlr = Translator(data_proxy=dp)
3031
return AASUB_V(
31-
seqrepo_access, transcript_mappings, GeneSymbol(),
32+
seqrepo_access, transcript_mappings,
33+
GeneSymbol(GeneQueryHandler()),
3234
MANETranscript(seqrepo_access, transcript_mappings,
3335
MANETranscriptMappings(), uta),
3436
uta, dp, tlr, AminoAcidCache())

tests/translators/test_coding_dna_deletion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from variation.mane_transcript import MANETranscript
1111
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1212
from ga4gh.vrs.extras.translator import Translator
13+
from gene.query import QueryHandler as GeneQueryHandler
1314

1415

1516
class TestCodingDNADeletionTranslator(TranslatorBase, unittest.TestCase):
@@ -27,7 +28,8 @@ def validator_instance(self):
2728
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2829
tlr = Translator(data_proxy=dp)
2930
return CDNAD_V(
30-
seqrepo_access, transcript_mappings, GeneSymbol(),
31+
seqrepo_access, transcript_mappings,
32+
GeneSymbol(GeneQueryHandler()),
3133
MANETranscript(seqrepo_access, transcript_mappings,
3234
MANETranscriptMappings(), uta),
3335
uta, dp, tlr

tests/translators/test_coding_dna_delins.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from variation.mane_transcript import MANETranscript
1111
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1212
from ga4gh.vrs.extras.translator import Translator
13+
from gene.query import QueryHandler as GeneQueryHandler
1314

1415

1516
class TestCodingDNADelInsTranslator(TranslatorBase, unittest.TestCase):
@@ -27,7 +28,8 @@ def validator_instance(self):
2728
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2829
tlr = Translator(data_proxy=dp)
2930
return CDNADELINS_V(
30-
seqrepo_access, transcript_mappings, GeneSymbol(),
31+
seqrepo_access, transcript_mappings,
32+
GeneSymbol(GeneQueryHandler()),
3133
MANETranscript(seqrepo_access, transcript_mappings,
3234
MANETranscriptMappings(), uta),
3335
uta, dp, tlr

tests/translators/test_coding_dna_insertion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from variation.mane_transcript import MANETranscript
1111
from ga4gh.vrs.dataproxy import SeqRepoDataProxy
1212
from ga4gh.vrs.extras.translator import Translator
13+
from gene.query import QueryHandler as GeneQueryHandler
1314

1415

1516
class TestCodingDNAInsertionTranslator(TranslatorBase, unittest.TestCase):
@@ -27,7 +28,8 @@ def validator_instance(self):
2728
dp = SeqRepoDataProxy(seqrepo_access.seq_repo_client)
2829
tlr = Translator(data_proxy=dp)
2930
return CDNAD_V(
30-
seqrepo_access, transcript_mappings, GeneSymbol(),
31+
seqrepo_access, transcript_mappings,
32+
GeneSymbol(GeneQueryHandler()),
3133
MANETranscript(seqrepo_access, transcript_mappings,
3234
MANETranscriptMappings(), uta),
3335
uta, dp, tlr

0 commit comments

Comments
 (0)