Skip to content

POD5 API Writer Reference

Tools for writing POD5 data

PoreType module-attribute

PoreType = str

The name of a Pore

SignalType module-attribute

SignalType: TypeAlias = SignalType

The type of compression applied to a signal SignalType::{UncompressedSignal, VbzSignal}

Writer

Writer(
    path: PathOrStr,
    software_name: str = DEFAULT_SOFTWARE_NAME,
    signal_compression_type: SignalType = VbzSignal,
)

Pod5 File Writer

Open a pod5 file for Writing.

Parameters:

Name Type Description Default
path (PathLike, str)

The path to the pod5 file to create

required
software_name str

The name of the application used to create this pod5 file

DEFAULT_SOFTWARE_NAME
signal_compression_type SignalType

The type of compression to use in the file. Defaults to Vbz.

VbzSignal

path property

path: Path

Return the path to the pod5 file

signal_compression_type property

signal_compression_type: SignalType

Return the signal compression type used by this file

software_name property

software_name: str

Return the software name used to open this file

add

add(obj: Union[EndReason, PoreType, RunInfo]) -> int

Add a EndReason, PoreType, or RunInfo object to the Pod5 file (if it doesn't already exist) and return the index of this object in the Pod5 file.

Parameters:

Name Type Description Default
obj Union[EndReason, PoreType, RunInfo]

Object to find in this Pod5 file, adding it if it doesn't exist already

required

Returns:

Name Type Description
index int

The index of the object in the Pod5 file

add_read

add_read(read: Union[Read, CompressedRead]) -> None

Add a record to the open POD5 file with either compressed or uncompressed signal data depending on the given type of Read.

Parameters:

Name Type Description Default
read Union[Read, CompressedRead]

POD5 Read or CompressedRead object to add as a record to the POD5 file.

required

add_reads

add_reads(reads: Sequence[Union[Read, CompressedRead]]) -> None

Add Read objects (with uncompressed signal data) as records in the open POD5 file.

Parameters:

Name Type Description Default
reads Sequence[Union[Read, CompressedRead]

Sequence of Read or CompressedRead objects to be added to this POD5 file

required

close

close() -> None

Close the FileWriter handle

contains

contains(obj: Union[EndReason, RunInfo]) -> bool

Test if this Pod5 file contains the given object.

Parameters:

Name Type Description Default
obj Union[EndReason, RunInfo]

Object to find in this Pod5 file

required

Returns:

Type Description
bool

True if obj has already been added to this file

find

find(obj: Union[EndReason, RunInfo]) -> int

Returns the index of obj in this Pod5 file raising a KeyError if it is missing.

Parameters:

Name Type Description Default
obj Union[EndReason, RunInfo]

Obj instance to find in this Pod5 file

required

Returns:

Type Description
int

The index of the object in this Pod5 file

Raises:

Type Description
KeyError

If the object is not in this file

map_to_tuples

map_to_tuples(info_map: Any) -> List[Tuple[str, str]]

Convert a fast5 property map (e.g. context_tags and tracking_id) to a tuple or string pairs to pass to pod5 C API

timestamp_to_int

timestamp_to_int(time_stamp: Union[datetime, int]) -> int

Convert a datetime timestamp to an integer if it's not already an integer