Slow5.jl

Introduction

Slow5.jl is a Julia wrapper library for the C slow5lib. The library currently provides high level functions for reading slow5 files used for storing nanopore sequencing results. The underlying slow5lib has richer API that provides more flexibility and also supports writing to slow5 files. High level API for those functions is not implemented here for now, but you may have some success using them via the CBinding interface accessible through Slow5.slow5lib.

Examples:

Iterating over all reads in a slow5 file:

using Slow5

file = slow5_open("example.slow5", "r")

for read in file
    println(read.id)
end

slow5_close(file)

Accessing specific reads:

using Slow5

file = slow5_open("example.slow5", "r")

# Load the index (it will be created if missing)
slow5_idx_load(file)

read = slow5_get("25c01294-b7cc-4665-98dc-d71488daea0a", file)
println(read.id)
signal = read.raw_signal

slow5_close(file)

API

Types

Read

Slow5.ReadType
Read

A structure that holds the information for a single nanopore read.

Fields:

  • id::String - Unique id of the read
  • read_group::Int - Read group
  • digitisation::Float64 - The number of quantisation levels - required to convert the signal to pico ampere
  • offset::Float64 - Offset value - required to convert the signal to pico ampere
  • range::Float64 - Range value - required to convert to pico ampere
  • sampling_rate::Float64 - The sampling rate at which the signal was acquired
  • len_raw_signal::Int - Number of values in the raw signal
  • raw_signal::Array{Int16} - An array of current intensity readings of the signal for the read

Implements: id, read_group, digitisation, offset, range, sampling_rate, len_raw_signal, raw_signal

Slow5.idMethod
id(read::Read)::String

Get the id of a Read.

Slow5File

Slow5.Slow5FileType
Slow5File

A structure holding a pointer to an opened slow5 file.

Base.iterateMethod
Base.iterate(file::Slow5File)

An iterator over a slow5 file. Returns one read at a time from the file or nothing when the reads are exhausted.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_idx_load(slow5_file)

for read in file
    println(read.id)
end

slow5_close(slow5_file)

slow5_open

Slow5.slow5_openMethod
slow5_open(file::String, mode::String)::Slow5File

Open a slow5 file (ASCII or binary) pointed by the path in the argument file. An open file should be closed at the end using the slow5_close() function.

Parameters:

  • file: a path to the slow5 file to be opened.
  • mode: "r" for reading, "w" for writing, or "a" for appending.

Returns an instance of a Slow5File struct, containing a pointer to the opened file.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_close(slow5_file)

slow5_close

Slow5.slow5_closeMethod
slow5_close(file)

Close an open slow5 file. May throw an error if the operation was unsuccessful.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_close(slow5_file)

slow5_idx_load

Slow5.slow5_idx_loadMethod
slow5_idx_load(file::Slow5File)

Loads the index for a slow5 file. If the index doesn't exist it would first create it (writing it to disk) and then load it. The function may throw an error if loading the index failed.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_idx_load(slow5_file)
slow5_close(slow5_file)

slow5_get

Slow5.slow5_getMethod
slow5_get(read_id::String, file::Slow5File)::Read

Get the read with the given id from the slow5 file. Returns an instance of the Read struct.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_idx_load(slow5_file)

read = slow5_get("ae0dcabb-df3d-4fec-ae5b-314e9cdfbd8d", slow5_file)

println(read.id)

slow5_close(slow5_file)

slow5_get_next

Slow5.slow5_get_nextMethod
slow5_get_next(file::Slow5File)::Union{Read, Nothing}

Get the next read from the slow5 file. Returns an instance of the Read struct.

Example:

slow5_file = slow5_open("path/to/data.slow5", "r")
slow5_idx_load(slow5_file)

read = slow5_get_next(slow5_file)

println(read.id)

slow5_close(slow5_file)