Skip to content

Commit

Permalink
Fixed bug in VCF SV Filter wrapper and expanded coverage (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
eudesbarbosa committed Dec 1, 2022
1 parent a19805b commit 5b3f739
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion snappy_wrappers/wrappers/vcf_sv_filter/vcf_sv_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def get_inner_region(self, record):
else:
# confidence intervals don't overlap
pos_begin += ci_pos[1]
pos_end += ci_pos[0] # negative
pos_end += ci_end[0] # negative
return GenomeRegion(record.CHROM, pos_begin, pos_end)


Expand Down
119 changes: 119 additions & 0 deletions tests/snappy_wrappers/wrappers/test_vcf_sv_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# -*- coding: utf-8 -*-
"""Code for testing vcf_sv_filter wrapper"""

import vcfpy

from snappy_wrappers.wrappers.vcf_sv_filter.vcf_sv_filter import (
GenomeRegion,
MantaGenotypeMetricsBuilder,
)


def test_manta_genotype_metrics_builder_get_length_dup_no_end():
"""Tests MantaGenotypeMetricsBuilder.get_length() - DUP no END"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("DUP")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict({"SVTYPE": "DUP"}),
)
actual = MantaGenotypeMetricsBuilder().get_length(record)
assert actual is None


def test_manta_genotype_metrics_builder_get_length_del():
"""Tests MantaGenotypeMetricsBuilder.get_length() - DEL"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("DEL")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict({"END": 1535, "SVTYPE": "DEL"}),
)
expected = 1036
actual = MantaGenotypeMetricsBuilder().get_length(record)
assert actual == expected


def test_manta_genotype_metrics_builder_get_length_ins():
"""Tests MantaGenotypeMetricsBuilder.get_length() - INS without SVLEN"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("INS")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict({"SVTYPE": "INS", "SVLEN": [1500, 9999]}),
)
expected = 1500 # first coordinate in list
actual = MantaGenotypeMetricsBuilder().get_length(record)
assert actual == expected


def test_manta_genotype_metrics_builder_get_length_ins_no_svlen():
"""Tests MantaGenotypeMetricsBuilder.get_length() - INS without SVLEN"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("INS")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict({"SVTYPE": "INS"}),
)
expected = 0 # default value
actual = MantaGenotypeMetricsBuilder().get_length(record)
assert actual == expected


def test_manta_genotype_metrics_builder_get_inner_region():
"""Tests MantaGenotypeMetricsBuilder.get_inner_region()"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("DEL")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict(
{
"END": 1535,
"SVTYPE": "DEL",
"SVLEN": [-1036],
"IMPRECISE": True,
"CIPOS": [-538, 538],
"CIEND": [-294, 294],
"SIZE_CLASS": "MEDIUM",
}
),
)
expected = GenomeRegion("chr1", 1037, 1241)
actual = MantaGenotypeMetricsBuilder().get_inner_region(record)
assert actual == expected


def test_manta_genotype_metrics_builder_get_inner_region_no_length():
"""Tests MantaGenotypeMetricsBuilder.get_inner_region() - Length is None"""
record = vcfpy.Record(
CHROM="chr1",
POS=500,
ID=[],
REF="A",
ALT=[vcfpy.SymbolicAllele("DEL")],
QUAL=None,
FILTER=[],
INFO=vcfpy.OrderedDict({"SVTYPE": "DEL"}),
)
actual = MantaGenotypeMetricsBuilder().get_inner_region(record)
assert actual is None

0 comments on commit 5b3f739

Please sign in to comment.