diff --git a/VERSION b/VERSION index 19ba008..95b25ae 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1 @@ -1.3.5 - +1.3.6 diff --git a/gumpy/variantfile.py b/gumpy/variantfile.py index 8a2b595..a6773be 100644 --- a/gumpy/variantfile.py +++ b/gumpy/variantfile.py @@ -80,14 +80,14 @@ def __init__( # Get the filter attribute value assert len(record.filter.items()) >= 0, "A record has more than 1 filter set!" - self.filter: str | None + self.filter: list[str] | None if len(record.filter.items()) == 0: self.filter = None self.is_filter_pass = False else: - self.filter = str(record.filter.items()[0][0]) + self.filter = [str(x) for x in record.filter.keys()] self.is_filter_pass = ( - True if record.filter.items()[0][0] == "PASS" else False + True if len(self.filter) == 1 and self.filter == ["PASS"] else False ) # Get the info field @@ -157,8 +157,8 @@ def __init__( self.is_alt = False self.is_reference = False - if self.is_null: - # Override filter fails on nulls to enforce that they are detected + if self.is_null and self.filter == ["MIN_FRS"]: + # Override MIN_FRS filter fails on nulls to enforce that they are detected self.is_filter_pass = True def __repr__(self) -> str: @@ -178,7 +178,7 @@ def __repr__(self) -> str: if self.filter is None: s += ".\t" else: - s += self.filter + "\t" + s += ",".join(self.filter) + "\t" for val in self.values.keys(): if val == "POS": continue @@ -561,7 +561,7 @@ def __find_calls(self): not record.is_filter_pass ): # We only want to allow these through if the filter fail is MIN_FRS - if record.filter == "MIN_FRS": + if record.filter == ["MIN_FRS"]: # Allow MIN_FRS variant = record.ref variant_type = "ref" diff --git a/tests/test-cases/TEST-DNA-2.vcf b/tests/test-cases/TEST-DNA-2.vcf index a9fe325..488f5d4 100644 --- a/tests/test-cases/TEST-DNA-2.vcf +++ b/tests/test-cases/TEST-DNA-2.vcf @@ -10,7 +10,7 @@ ##contig= #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT 03.vcf TEST_DNA 2 . A G . PASS KMER=15 GT:DP:COV:GT_CONF ./.:2:1,1:2.05 -TEST_DNA 4 . A G,T . MIN_GT KMER=15 GT:DP:COV:GT_CONF ./.:4:1,2,2:3.77 +TEST_DNA 4 . A G,T . MIN_FRS KMER=15 GT:DP:COV:GT_CONF ./.:4:1,2,2:3.77 TEST_DNA 6 . AAA GGT,GTA,ATA . PASS KMER=15 GT:DP:COV:GT_CONF ./.:4:1,1,1,1:2.76 TEST_DNA 12 . C T . PASS KMER=15 GT:DP:COV:GT_CONF 1/1:50:0,50:200.58 TEST_DNA 14 . C T,G . PASS KMER=15 GT:DP:COV:GT_CONF 2/2:45:0,2,43:155.58 diff --git a/tests/test-cases/TEST-DNA.vcf b/tests/test-cases/TEST-DNA.vcf index fa9c232..7a8d1a0 100644 --- a/tests/test-cases/TEST-DNA.vcf +++ b/tests/test-cases/TEST-DNA.vcf @@ -10,7 +10,7 @@ ##contig= #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT 03.vcf TEST_DNA 2 . A G . PASS KMER=15 GT:DP:COV:GT_CONF ./.:2:1,1:2.05 -TEST_DNA 4 . A G,T . MIN_GT KMER=15 GT:DP:COV:GT_CONF ./.:4:1,2,1:3.77 +TEST_DNA 4 . A G,T . MIN_FRS KMER=15 GT:DP:COV:GT_CONF ./.:4:1,2,1:3.77 TEST_DNA 6 . AAA GGT,GTA,ATA . PASS KMER=15 GT:DP:COV:GT_CONF ./.:4:1,1,1,1:2.76 TEST_DNA 12 . C T . PASS KMER=15 GT:DP:COV:GT_CONF 1/1:50:0,50:200.58 TEST_DNA 14 . C T,G . PASS KMER=15 GT:DP:COV:GT_CONF 2/2:45:0,2,43:155.58 diff --git a/tests/unit/test_functions.py b/tests/unit/test_functions.py index 92b5ec0..6415e55 100644 --- a/tests/unit/test_functions.py +++ b/tests/unit/test_functions.py @@ -1407,22 +1407,22 @@ def test_vcf_to_df(): None, ], "FILTER": [ - "PASS", - "MIN_GT", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", - "PASS", + ["PASS"], + ["MIN_FRS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], + ["PASS"], ], "INFO": [ {"KMER": 15}, diff --git a/tests/unit/test_instantiation.py b/tests/unit/test_instantiation.py index 1765793..8b075db 100644 --- a/tests/unit/test_instantiation.py +++ b/tests/unit/test_instantiation.py @@ -2554,9 +2554,9 @@ def test_instanciate_vcf(): for i in range(15): if i == 1: - assert vcf.records[i].filter == "MIN_GT" + assert vcf.records[i].filter == ["MIN_FRS"] else: - assert vcf.records[i].filter == "PASS" + assert vcf.records[i].filter == ["PASS"] # GT gt = [record.values["GT"] for record in vcf.records]