Skip to content

Commit 22f665e

Browse files
committed
packaging dep and IcfMetadata.__eq__
Adding packaing dependency to pyproject.toml Adding comparisons to IcfMedtadata
1 parent d851fc3 commit 22f665e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bio2zarr/vcf2zarr/icf.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def fromdict(d):
4141
return VcfFieldSummary(**d)
4242

4343

44-
@dataclasses.dataclass
44+
@dataclasses.dataclass(order=True)
4545
class VcfField:
4646
category: str
4747
name: str
@@ -116,24 +116,24 @@ class VcfPartition:
116116
)
117117

118118

119-
@dataclasses.dataclass
119+
@dataclasses.dataclass(order=True)
120120
class Contig:
121121
id: str
122122
length: int = None
123123

124124

125-
@dataclasses.dataclass
125+
@dataclasses.dataclass(order=True)
126126
class Sample:
127127
id: str
128128

129129

130-
@dataclasses.dataclass
130+
@dataclasses.dataclass(order=True)
131131
class Filter:
132132
id: str
133133
description: str = ""
134134

135135

136-
@dataclasses.dataclass
136+
@dataclasses.dataclass(order=True)
137137
class IcfMetadata(core.JsonDataclass):
138138
samples: list
139139
contigs: list
@@ -192,6 +192,14 @@ def fromdict(d):
192192
d["contigs"] = [Contig(**cd) for cd in d["contigs"]]
193193
return IcfMetadata(**d)
194194

195+
def __eq__(self, other):
196+
if not isinstance(other, IcfMetadata):
197+
return NotImplemented
198+
return (sorted(self.samples) == sorted(other.samples) and
199+
sorted(self.contigs) == sorted(other.contigs) and
200+
sorted(self.filters) == sorted(self.filters) and
201+
sorted(self.fields) == sorted(self.fields))
202+
195203

196204
def fixed_vcf_field_definitions():
197205
def make_field_def(name, vcf_type, vcf_number):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies = [
2323
# colouredlogs pulls in humanfriendly",
2424
"cyvcf2",
2525
"bed_reader",
26+
"packaging",
2627
]
2728
requires-python = ">=3.9"
2829
classifiers = [

0 commit comments

Comments
 (0)