Skip to content

Commit

Permalink
pre-commit passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ACEnglish committed Feb 24, 2025
1 parent c691ecf commit 945112d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
10 changes: 5 additions & 5 deletions bio2zarr/vcf2zarr/icf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ def __eq__(self, other):
if not isinstance(other, IcfMetadata):
return NotImplemented
return (
self.samples == other.samples and
self.contigs == other.contigs and
self.filters == other.filters and
sorted(self.fields) == sorted(other.fields)
)
self.samples == other.samples
and self.contigs == other.contigs
and self.filters == other.filters
and sorted(self.fields) == sorted(other.fields)
)


def fixed_vcf_field_definitions():
Expand Down
19 changes: 8 additions & 11 deletions tests/test_vcf_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,16 @@ def test_missing_filter(tmp_path):
with pytest.raises(ValueError, match="Filter 'q10' was not defined in the header"):
vcf2zarr.convert([path], zarr_path)


class TestOutOfOrderFields:
data_paths = ["tests/data/vcf/out_of_order_fields/input1.bcf",
"tests/data/vcf/out_of_order_fields/input2.bcf"]
# Mixing on purpose
data_path1 = "tests/data/vcf/out_of_order_fields/input2.bcf"
data_path2 = "tests/data/vcf/out_of_order_fields/input1.bcf"

@pytest.fixture(scope="class")
def ds(self, tmp_path_factory):
out = tmp_path_factory.mktemp("data") / "ooo_example.vcf.zarr"
vcf2zarr.convert(self.data_paths, out)
vcf2zarr.convert([self.data_path1, self.data_path2], out)
return sg.load_dataset(out)

def test_filters(self, ds):
Expand All @@ -1127,7 +1129,7 @@ def test_source(self, ds):

def test_contigs(self, ds):
nt.assert_array_equal(ds["contig_id"], ["chr20", "chr21"])
nt.assert_array_equal(ds['contig_length'], [64444167., 46709983.])
nt.assert_array_equal(ds["contig_length"], [64444167.0, 46709983.0])
nt.assert_array_equal(ds["variant_contig"], [0, 1, 1])

def test_position(self, ds):
Expand All @@ -1139,19 +1141,14 @@ def test_length(self, ds):
def test_info_fields(self, ds):
nt.assert_array_equal(
ds["variant_QNAME"],
['cluster19_000000F', '.', 'cluster19_000000F'],
["cluster19_000000F", ".", "cluster19_000000F"],
)
nt.assert_array_equal(ds["variant_QSTART"], [25698928, 25698928, -1])

def test_allele(self, ds):
fill = constants.STR_FILL
nt.assert_array_equal(
ds["variant_allele"].values.tolist(),
[
['TTCCATTCCAC', 'T'],
['C', 'CTCCAT'],
['G', 'A']
]
[["TTCCATTCCAC", "T"], ["C", "CTCCAT"], ["G", "A"]],
)
assert ds["variant_allele"].dtype == "O"

Expand Down

0 comments on commit 945112d

Please sign in to comment.