11"""Module for translating VCF-like to protein VRS Allele representation"""
22
33import datetime
4+ from typing import Literal
45
56from cool_seq_tool .handlers import SeqRepoAccess
67from cool_seq_tool .mappers import ManeTranscript
1617from variation .schemas .classification_response_schema import Nomenclature
1718from variation .schemas .gnomad_vcf_to_protein_schema import GnomadVcfToProteinService
1819from variation .schemas .normalize_response_schema import ServiceMeta
20+ from variation .schemas .service_schema import ClinVarAssembly
1921from variation .schemas .token_response_schema import AltType
2022from variation .schemas .validation_response_schema import ValidationResult
2123from variation .tokenize import Tokenize
@@ -183,12 +185,16 @@ def __init__(
183185 self .gene_normalizer = gene_normalizer
184186
185187 async def _get_valid_result (
186- self , vcf_query : str , warnings : list
188+ self ,
189+ vcf_query : str ,
190+ warnings : list ,
191+ input_assembly : Literal [ClinVarAssembly .GRCH37 , ClinVarAssembly .GRCH38 ] | None ,
187192 ) -> list [ValidationResult ]:
188193 """Get gnomad vcf validation summary
189194
190195 :param vcf_query: gnomad vcf input query
191196 :param warnings: List of warnings
197+ :param input_assembly: Assembly used for `q`.
192198 :raises GnomadVcfToProteinError: If no tokens, classifications, or valid results
193199 are found. Also if ``vcf_query`` is not a gnomAD VCF-like query.
194200 :return: List of valid results for a gnomad VCF query
@@ -207,7 +213,9 @@ async def _get_valid_result(
207213 msg = f"{ vcf_query } is not a gnomAD VCF-like query (`chr-pos-ref-alt`)"
208214 raise GnomadVcfToProteinError (msg )
209215
210- validation_summary = await self .validator .perform (classification )
216+ validation_summary = await self .validator .perform (
217+ classification , input_assembly = input_assembly
218+ )
211219 valid_results = validation_summary .valid_results
212220 if valid_results :
213221 # Temporary work around until issue-490 complete
@@ -434,12 +442,18 @@ def _get_gene_context(self, gene: str) -> MappableConcept | None:
434442 else None
435443 )
436444
437- async def gnomad_vcf_to_protein (self , vcf_query : str ) -> GnomadVcfToProteinService :
445+ async def gnomad_vcf_to_protein (
446+ self ,
447+ vcf_query : str ,
448+ input_assembly : Literal [ClinVarAssembly .GRCH37 , ClinVarAssembly .GRCH38 ]
449+ | None = None ,
450+ ) -> GnomadVcfToProteinService :
438451 """Get protein consequence for gnomAD-VCF like expression
439452 Assumes input query uses GRCh38 representation
440453
441454 :param vcf_query: gnomAD VCF-like expression (``chr-pos-ref-alt``) on the GRCh38
442455 assembly
456+ :param input_assembly: Assembly used for `q`.
443457 :return: GnomadVcfToProteinService containing protein VRS Allele, if translation
444458 was successful
445459 """
@@ -448,7 +462,9 @@ async def gnomad_vcf_to_protein(self, vcf_query: str) -> GnomadVcfToProteinServi
448462
449463 # First we need to validate the input query
450464 try :
451- valid_result = await self ._get_valid_result (vcf_query , warnings )
465+ valid_result = await self ._get_valid_result (
466+ vcf_query , warnings , input_assembly = input_assembly
467+ )
452468 except GnomadVcfToProteinError as e :
453469 warnings .append (str (e ))
454470 return GnomadVcfToProteinService (
0 commit comments