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.Read — TypeReadA structure that holds the information for a single nanopore read.
Fields:
id::String - Unique id of the readread_group::Int - Read groupdigitisation::Float64 - The number of quantisation levels - required to convert the signal to pico ampereoffset::Float64 - Offset value - required to convert the signal to pico ampererange::Float64 - Range value - required to convert to pico amperesampling_rate::Float64 - The sampling rate at which the signal was acquiredlen_raw_signal::Int - Number of values in the raw signalraw_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.id — Methodid(read::Read)::StringGet the id of a Read.
Slow5.read_group — Methodread_group(read::Read)::IntGet the read_group of a Read.
Slow5.digitisation — Methoddigitisation(read::Read)::Float64Get the digitisation of a Read.
Slow5.offset — Methodoffset(read::Read)::Float64Get the offset of a Read.
Slow5.range — Methodrange(read::Read)::Float64Get the range of a Read.
Slow5.sampling_rate — Methodsampling_rate(read::Read)::Float64Get the sampling_rate of a Read.
Slow5.len_raw_signal — Methodlen_raw_signal(read::Read)::IntGet the len_raw_signal of a Read.
Slow5.raw_signal — Methodraw_signal(read::Read)::Array{Int16}Get the raw_signal of a Read.
Slow5File
Slow5.Slow5File — TypeSlow5FileA structure holding a pointer to an opened slow5 file.
Base.iterate — MethodBase.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_open — Methodslow5_open(file::String, mode::String)::Slow5FileOpen 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_close — Methodslow5_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_load — Methodslow5_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_get — Methodslow5_get(read_id::String, file::Slow5File)::ReadGet 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_next — Methodslow5_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)