From c1dd96de1526d3c28246594fab4b1c9a6eb56e40 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Sat, 22 Jun 2024 21:00:23 +0930 Subject: [PATCH 1/2] #744 - babelfish vcf conversion accept contig accessions as chrom names --- src/hgvs/extras/babelfish.py | 4 ++++ tests/test_hgvs_extras_babelfish.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/hgvs/extras/babelfish.py b/src/hgvs/extras/babelfish.py index 9304f206..f3d46984 100644 --- a/src/hgvs/extras/babelfish.py +++ b/src/hgvs/extras/babelfish.py @@ -33,6 +33,10 @@ def __init__(self, hdp, assembly_name): ) self.ac_to_name_map = make_ac_name_map(assembly_name) self.name_to_ac_map = make_name_ac_map(assembly_name) + # We need to accept accessions as chromosome names, so add them pointing at themselves + accessions = list(self.name_to_ac_map.values()) + self.name_to_ac_map.update({ac: ac for ac in accessions}) + def hgvs_to_vcf(self, var_g): """**EXPERIMENTAL** diff --git a/tests/test_hgvs_extras_babelfish.py b/tests/test_hgvs_extras_babelfish.py index c0d2d1c5..5d3bebee 100644 --- a/tests/test_hgvs_extras_babelfish.py +++ b/tests/test_hgvs_extras_babelfish.py @@ -93,3 +93,8 @@ def _v2h(*v): hgvs_g = _v2h(*v) hgvs_string = hgvs_g.format() assert hgvs_string == expected_hgvs_string + + +def test_vcf_to_hgvs_contig_chrom(parser, babelfish38): + hgvs_g = babelfish38.vcf_to_g_hgvs("NC_000006.12", 49949409, "GAA", "G") + assert hgvs_g.format() == "NC_000006.12:g.49949413_49949414del" From 5fe54d29a018946b03fa90984d615ea5276677b6 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Sat, 22 Jun 2024 21:03:44 +0930 Subject: [PATCH 2/2] #744 - just use iterator rather than explicit list --- src/hgvs/extras/babelfish.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hgvs/extras/babelfish.py b/src/hgvs/extras/babelfish.py index f3d46984..87c198eb 100644 --- a/src/hgvs/extras/babelfish.py +++ b/src/hgvs/extras/babelfish.py @@ -34,9 +34,7 @@ def __init__(self, hdp, assembly_name): self.ac_to_name_map = make_ac_name_map(assembly_name) self.name_to_ac_map = make_name_ac_map(assembly_name) # We need to accept accessions as chromosome names, so add them pointing at themselves - accessions = list(self.name_to_ac_map.values()) - self.name_to_ac_map.update({ac: ac for ac in accessions}) - + self.name_to_ac_map.update({ac: ac for ac in self.name_to_ac_map.values()}) def hgvs_to_vcf(self, var_g): """**EXPERIMENTAL**