api_utils

Utility functions for the pod5-format API

exception Pod5ApiException[source]

Bases: Exception

Generic Pod5 API Exception

deprecation_warning(deprecated: str, alternate: str) None[source]

Issue a FutureWarning warning that deprecated has been deprecated in favour of alternate.

Parameters:
  • deprecated (str) – The module path to the deprecated item

  • alternate (str) – The module path to the alternate item

format_read_ids(read_ids: Union[ndarray[Any, dtype[uint8]], FixedSizeBinaryArray]) List[str][source]

Convert a packed array of read_ids and convert them to a list of strings.

Parameters:

read_ids (numpy.ndarray[uint8], pa.lib.FixedSizeBinaryArray) – Packed read_ids from a numpy.ndarray or read directly from pod5 file

Returns:

read_ids – A list of converted read_ids as strings

Return type:

list[str]

pack_read_ids(read_ids: Collection[str], invalid_ok: bool = False) ndarray[Any, dtype[uint8]][source]

Convert a Collection of read_id strings to a numpy.ndarray in preparation for writing to pod5 files.

Parameters:

read_ids (Collection[str]) – Collection of well-formatted read_id strings

Returns:

packed_read_ids – Repacked read_ids ready for writing to pod5 files.

Return type:

numpy.ndarray[uint8]

safe_close(obj: Any, attr: str) None[source]

Try to close() an object’s attribute ignoring any exceptions raised. This is used to safely handle closing potentially unassigned attributes while calling close() in __del__()