Skip to content

POD5 API Repack Reference

Tools to assist repacking pod5 data into other pod5 files

Repacker

Repacker()

Wrapper class around native pod5 tools to repack data

currently_open_file_reader_count property

currently_open_file_reader_count: int

Returns the number of open file readers held by this repacker

is_complete property

is_complete: bool

Find if the requested repack operations are complete

reads_completed property

reads_completed: int

Find the number of reads written to files

reads_requested property

reads_requested: int

Find the number of requested reads to be written

add_all_reads_to_output

add_all_reads_to_output(output_ref: Pod5RepackerOutput, reader: Reader) -> None

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

Parameters:

Name Type Description Default
output_ref Pod5RepackerOutput

The repacker handle reference returned from add_output

required
reader Reader

The Pod5 file reader to copy reads from

required

add_output

add_output(
    output_file: Writer, check_duplicate_read_ids: bool = True
) -> Pod5RepackerOutput

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:

Name Type Description Default
output_file Writer

The output file writer to use

required
check_duplicate_read_ids bool

Check the output for duplicate read ids, and raise an error if found.

True

Returns:

Name Type Description
repacker_object Pod5RepackerOutput

Use this as output_ref in calls to add_selected_reads_to_output or add_reads_to_output

add_selected_reads_to_output

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

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

Parameters:

Name Type Description Default
output_ref Pod5RepackerOutput

The repacker handle reference returned from add_output

required
reader Reader

The Pod5 file reader to copy reads from

required
selected_read_ids Collection[str]

A Collection of read_ids as strings

required

Raises:

Type Description
RuntimeError

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

finish

finish() -> None

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

set_output_finished

set_output_finished(output) -> None

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