Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle cases where gene_context is not found #536

Merged
merged 10 commits into from
Feb 13, 2024
9 changes: 8 additions & 1 deletion src/variation/gnomad_vcf_to_protein_variation.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,18 @@ async def gnomad_vcf_to_protein(self, vcf_query: str) -> GnomadVcfToProteinServi
except GnomadVcfToProteinError as e:
warnings.append(str(e))

if p_data.gene and c_data.gene and p_data.gene != c_data.gene:
warnings.append(
f"Protein gene ({p_data.gene}) and cDNA gene ({c_data.gene}) mismatch"
)
gene = p_data.gene or c_data.gene
gene_context = self._get_gene_context(gene) if gene else None

return GnomadVcfToProteinService(
variation_query=vcf_query,
variation=variation,
vrs_ref_allele_seq=self._get_vrs_ref_allele_seq(variation.location, p_ac),
gene_context=self._get_gene_context(p_data.gene),
gene_context=gene_context,
warnings=warnings,
service_meta_=ServiceMeta(
version=__version__,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_gnomad_vcf_to_protein.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ async def test_delins(test_handler, delins_pos, delins_neg):
assert resp.vrs_ref_allele_seq == "PRLLFPTNSSSHLVALQGQP"
assert resp.gene_context

# CA16602420. Example where protein gene not found, but cDNA gene found
resp = await test_handler.gnomad_vcf_to_protein("7-140453136-AC-TT")
assert resp.variation
assert resp.gene_context
assert resp.warnings == []


@pytest.mark.asyncio()
async def test_invalid(test_handler):
Expand Down
Loading