Description
Issue Description
I have installed the pod5 package via pip and were attempting to use it via a custom Python script as referenced in this issue:
https://github.com/nanoporetech/pod5-file-format/issues/100
to edit the sample_id field. The error is:
Exception has occurred: FrozenInstanceError
cannot assign to field 'sample_id'
File "/data/TS_data_analysis/jgribble/abrf_methylation/pod5_rename/pod5_rename_test.py", line 12, in
read.run_info.sample_id = str('NA24385_MGI_Lib1_New_flowcell')
^^^^^^^^^^^^^^^^^^^^^^^
dataclasses.FrozenInstanceError: cannot assign to field 'sample_id'
To my understanding, this appears that the following code block does not create a mutable RunInfo attribute? Is this intended or should users be able to edit RunInfo fields using this package?
import pod5
# New output file for edited data
with pod5.Writer("output.pod5") as writer:
# Read all records
with pod5.Reader("input.pod5") as reader:
# Iterate over immutable ReadRecords
for record in reader:
# Convert to mutable Read
read = record.to_read()
# Edit the value
read.run_info.sample_id = str('NA24385_MGI_Lib1_New_flowcell')
Specifications
- Pod5 Version: 0.3.6
- Python Version: 3.11
- Platform: conda env on Linux (Ubuntu 20.04)