Skip to content

Commit 717cce9

Browse files
committed
Removed attribute for all objects. Updated tests.
1 parent fba4255 commit 717cce9

File tree

11 files changed

+12
-89
lines changed

11 files changed

+12
-89
lines changed

seqspec/Assay.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class SeqProtocol(BaseModel):
1414
name: str
1515
modality: str
1616

17-
def to_dict(self):
18-
return self.model_dump()
19-
2017
def update_from(self, patch: Union["SeqProtocol", "SeqProtocolInput"]) -> None:
2118
if isinstance(patch, SeqProtocolInput):
2219
for field in patch.model_fields_set:
@@ -68,9 +65,6 @@ class SeqKit(BaseModel):
6865
name: Optional[str]
6966
modality: str
7067

71-
def to_dict(self):
72-
return self.model_dump()
73-
7468
def update_from(self, patch: Union["SeqKit", "SeqKitInput"]) -> None:
7569
if isinstance(patch, SeqKitInput):
7670
for field in patch.model_fields_set:
@@ -118,9 +112,6 @@ class LibProtocol(BaseModel):
118112
name: str
119113
modality: str
120114

121-
def to_dict(self):
122-
return self.model_dump()
123-
124115
def update_from(self, patch: Union["LibProtocol", "LibProtocolInput"]) -> None:
125116
if isinstance(patch, LibProtocolInput):
126117
for field in patch.model_fields_set:
@@ -170,9 +161,6 @@ class LibKit(BaseModel):
170161
name: Optional[str]
171162
modality: str
172163

173-
def to_dict(self):
174-
return self.model_dump()
175-
176164
def update_from(self, patch: Union["LibKit", "LibKitInput"]) -> None:
177165
if isinstance(patch, LibKitInput):
178166
for field in patch.model_fields_set:
@@ -254,15 +242,8 @@ def __repr__(self) -> str:
254242
Regions:
255243
{"\n".join(rgns)}
256244
"""
257-
# return str(self.model_dump())
258245
return s
259246

260-
def to_dict(self):
261-
return self.model_dump()
262-
263-
def to_JSON(self):
264-
return self.model_dump_json(indent=4)
265-
266247
def to_YAML(self, fname: Optional[str] = None):
267248
yaml_str = yaml.dump(self.model_dump(), sort_keys=False)
268249
if fname is None:

seqspec/File.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ def __repr__(self) -> str:
1717
s = f"""{self.file_id}"""
1818
return s
1919

20-
def to_dict(self):
21-
return self.model_dump()
22-
2320
def update_file_id(self, file_id: str):
2421
self.file_id = file_id
2522

seqspec/Read.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def __repr__(self) -> str:
2525
# return str(self.model_dump())
2626
return s
2727

28-
def to_dict(self):
29-
return self.model_dump()
30-
3128
def update_read_by_id(
3229
self,
3330
read_id=None,

seqspec/Region.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ def get_onlist(self) -> Optional[Onlist]:
208208
"""Get the onlist associated with this region."""
209209
return self.onlist
210210

211-
# update_from removed per new approach
212-
213211
def get_leaves(self, leaves: Optional[List["Region"]] = None) -> List["Region"]:
214212
# print(leaves)
215213
if leaves is None:

seqspec/seqspec_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def check_schema(spec: Assay, errors=[], idx=0):
144144
with open(schema_fn, "r") as stream:
145145
schema = yaml.load(stream, Loader=yaml.Loader)
146146
validator = Draft4Validator(schema)
147-
for idx, error in enumerate(validator.iter_errors(spec.to_dict()), 1):
147+
for idx, error in enumerate(validator.iter_errors(spec.model_dump()), 1):
148148
err_elements = [repr(index) for index in error.path]
149149
err_path = f"spec[{']['.join(err_elements)}]"
150150
errobj = {

seqspec/seqspec_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def seqspec_to_token(spec):
179179
specs_regions = {}
180180
modalities = spec.list_modalities()
181181
for modality in modalities:
182-
regions = [i.to_dict() for i in spec.get_libspec(modality).get_leaves()]
182+
regions = [i.model_dump() for i in spec.get_libspec(modality).get_leaves()]
183183
specs_regions[modality] = regions
184184

185185
# Convert to tokenized matrix

seqspec/seqspec_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def format_json_files(
270270
for items in zip(*files.values()):
271271
if k == "all":
272272
for key, item in zip(files.keys(), items):
273-
d = item.to_dict()
273+
d = item.model_dump()
274274
if item.urltype == "local" and fp:
275275
d["url"] = str(spec_fn.parent / d["url"])
276276
x.append(d)

seqspec/seqspec_info.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def seqspec_info_meta(spec: Assay) -> Dict:
152152
Returns:
153153
Dictionary containing meta information
154154
"""
155-
sd = spec.to_dict()
155+
sd = spec.model_dump()
156156
del sd["library_spec"]
157157
del sd["sequence_spec"]
158158
del sd["modalities"]
@@ -173,7 +173,8 @@ def seqspec_info_library_spec(spec: Assay) -> Dict:
173173
for m in modalities:
174174
libspec = spec.get_libspec(m)
175175
leaves = libspec.get_leaves()
176-
result[m] = leaves if leaves else []
176+
r = leaves if leaves else []
177+
result[m] = [i.model_dump() for i in r]
177178
return {"library_spec": result}
178179

179180

tests/test_assay.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ def test_get_read(dogmaseq_dig_spec):
5050
with pytest.raises(IndexError):
5151
dogmaseq_dig_spec.get_read("non_existent_read")
5252

53-
def test_to_json(dogmaseq_dig_spec):
54-
"""
55-
Test to_JSON method
56-
"""
57-
json_output = dogmaseq_dig_spec.to_JSON()
58-
assert isinstance(json_output, str)
59-
data = json.loads(json_output)
60-
assert data["assay_id"] == "DOGMAseq-DIG"
61-
6253

6354
def test_insert_regions(temp_spec):
6455
"""

tests/test_read.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,6 @@ def test_read_set_files():
8686
assert len(read.files) == 1
8787
assert read.files[0].file_id == "file1"
8888

89-
def test_read_to_dict():
90-
"""Test to_dict method"""
91-
read = Read(
92-
read_id="test_read",
93-
name="Test Read",
94-
modality="RNA",
95-
primer_id="test_primer",
96-
min_len=100,
97-
max_len=150,
98-
strand="pos"
99-
)
100-
101-
read_dict = read.to_dict()
102-
assert read_dict["read_id"] == "test_read"
103-
assert read_dict["name"] == "Test Read"
104-
assert read_dict["modality"] == "RNA"
105-
assert read_dict["primer_id"] == "test_primer"
106-
assert read_dict["min_len"] == 100
107-
assert read_dict["max_len"] == 150
108-
assert read_dict["strand"] == "pos"
109-
assert read_dict["files"] == []
110-
11189
def test_read_update_read_by_id():
11290
"""Test update_read_by_id method"""
11391
read = Read(
@@ -275,26 +253,6 @@ def test_file_creation():
275253
assert file_obj.urltype == "local"
276254
assert file_obj.md5 == "d41d8cd98f00b204e9800998ecf8427e"
277255

278-
def test_file_to_dict():
279-
"""Test File to_dict method"""
280-
file_obj = File(
281-
file_id="file1",
282-
filename="read1.fastq.gz",
283-
filetype="fastq",
284-
filesize=1000000,
285-
url="file://read1.fastq.gz",
286-
urltype="local",
287-
md5="d41d8cd98f00b204e9800998ecf8427e"
288-
)
289-
290-
file_dict = file_obj.to_dict()
291-
assert file_dict["file_id"] == "file1"
292-
assert file_dict["filename"] == "read1.fastq.gz"
293-
assert file_dict["filetype"] == "fastq"
294-
assert file_dict["filesize"] == 1000000
295-
assert file_dict["url"] == "file://read1.fastq.gz"
296-
assert file_dict["urltype"] == "local"
297-
assert file_dict["md5"] == "d41d8cd98f00b204e9800998ecf8427e"
298256

299257

300258

0 commit comments

Comments
 (0)