repack

Tools to assist repacking pod5 data into other pod5 files

class Repacker[source]

Bases: object

Wrapper class around native pod5 tools to repack data

__init__()[source]
add_all_reads_to_output(output_ref: Pod5RepackerOutput, reader: Reader) None[source]

Copy the every read from the given Reader into the Repacker output reference which was returned by add_output()

Parameters:
  • output_ref (lib_pod5.pod5_format_pybind.Pod5RepackerOutput) – The repacker handle reference returned from add_output()

  • reader (Reader) – The Pod5 file reader to copy reads from

add_output(output_file: Writer, check_duplicate_read_ids: bool = True) Pod5RepackerOutput[source]

Add an output file writer to the repacker, so it can have read data repacked into it.

Once a user has added an output, it can be passed as an output to add_selected_reads_to_output() or add_reads_to_output()

Parameters:
  • output_file (writer.Writer) – The output file writer to use

  • check_duplicate_read_ids (bool) – Check the output for duplicate read ids, and raise an error if found.

Returns:

repacker_object – Use this as “output_ref” in calls to add_selected_reads_to_output() or add_reads_to_output()

Return type:

p5b.Pod5RepackerOutput

add_selected_reads_to_output(output_ref: Pod5RepackerOutput, reader: Reader, selected_read_ids: Collection[str])[source]

Copy the selected read_ids from the given Reader into the Repacker output reference which was returned by add_output()

Parameters:
  • output_ref (lib_pod5.pod5_format_pybind.Pod5RepackerOutput) – The repacker handle reference returned from add_output()

  • reader (Reader) – The Pod5 file reader to copy reads from

  • selected_read_ids (Collection[str]) – A Collection of read_ids as strings

Raises:

RuntimeError – If any of the selected_read_ids were not found in the source file

property currently_open_file_reader_count: int

Returns the number of open file readers held by this repacker

finish() None[source]

Call finish on the underlying c_api repacker instance to write the footer completing the file and freeing resources

property is_complete: bool

Find if the requested repack operations are complete

property reads_completed: int

Find the number of reads written to files

property reads_requested: int

Find the number of requested reads to be written

set_output_finished(output) None[source]

Tell the repacker a specific output is complete and can be finalised.