Writing
The pod5 package provides the functionality to write POD5 files. Although most users will only need to read files produced by Oxford Nanopore sequencers there are certainly use cases where writing one's own POD5 files in necessary.
It is strongly recommended that users first look at the available Tools that are installed along with the API. These tools can be used to manipulate existing datasets in a variety of ways.
New tools may be added to support our users and if you have a suggestion for a new tool please submit a request on the GitHub issues page.
Creating a POD5 File
To create a new POD5 file and open it for writing use the Writer. Using the context manager as shown
in this exmaple will ensure that the new file is closed correctly and that all resources are freed. Once closed no more data can be appended to a POD5 file. The pod5 merge tool can be used to merge pod5 files.
Note that the Writer.add_read method takes the mutable Read and not the immutable ReadRecord classes.
Example
Below is an example of how one may add reads to a new POD5 file using the Writer and its Writer.add_read method.
import pod5 as p5
# Example container classes for read information
pore = p5.Pore(channel=123, well=3, pore_type="pore_type")
calibration = p5.Calibration(offset=0.1, scale=1.1)
end_reason = p5.EndReason(name=p5.EndReasonEnum.SIGNAL_POSITIVE, forced=False)
run_info = p5.RunInfo(
acquisition_id = ...
acquisition_start_time = ...
adc_max = ...
...
)
signal = ... # some signal data
read = p5.Read(
read_id=UUID("0000173c-bf67-44e7-9a9c-1ad0bc728e74"),
end_reason=end_reason,
calibration=calibration,
pore=pore,
run_info=run_info,
...
signal=signal,
sample_count=len(signal),
pre_compressed_signal=False,
)
with p5.Writer("example.pod5") as writer:
# Write the read and all its metadata
writer.add_read(read)