slow5

package
v0.31.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package slow5 contains slow5 parsers and writers.

Right now, only parsing slow5 files is supported. Support for writing and blow5 coming soon.

slow5 is a file format alternative to fast5, which is the file format outputted by Oxford Nanopore sequencing devices. fast5 uses hdf5, which is a complex file format that can only be read and written with a single software library built in 1998. On the other hand, slow5 uses a .tsv file format, which is easy to both parse and write.

slow5 files contain both general metadata about the sequencing run and raw signal reads from the sequencing run. This raw signal can be used directly or basecalled and used for alignment.

More information on slow5 can be found here: https://github.com/hasindu2008/slow5tools

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewParser

func NewParser(r io.Reader, maxLineSize int) (*Parser, []Header, error)

NewParser parsers a slow5 file.

Example
package main

import (
	"fmt"
	"os"

	"github.com/bebop/poly/io/slow5"
)

func main() {
	// example.slow5 is a file I generated using slow5tools from nanopore fast5
	// run where I was testing using nanopore for doing COVID testing. It
	// contains real nanopore data.
	file, _ := os.Open("data/example.slow5")
	// Set maxLineSize to 64kb. If you expect longer reads,
	// make maxLineSize longer!
	const maxLineSize = 2 * 32 * 1024
	parser, _, _ := slow5.NewParser(file, maxLineSize)

	var outputReads []slow5.Read
	for {
		read, err := parser.ParseNext()
		if err != nil {
			// Break at EOF
			break
		}
		outputReads = append(outputReads, read)
	}

	fmt.Println(outputReads[0].RawSignal[0:10])
}
Output:

[430 472 463 467 454 465 463 450 450 449]

func Write

func Write(headers []Header, reads <-chan Read, output io.Writer) error

Write writes a list of headers and a channel of reads to an output.

Types

type Header struct {
	ReadGroupID        uint32
	Slow5Version       string
	Attributes         map[string]string
	EndReasonHeaderMap map[string]int
}

Header contains metadata about the sequencing run in general.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is a flexible parser that provides ample control over reading slow5 sequences. It is initialized with NewParser.

func (*Parser) ParseNext

func (parser *Parser) ParseNext() (Read, error)

ParseNext parses the next read from a parser.

type Read

type Read struct {
	ReadID       string
	ReadGroupID  uint32
	Digitisation float64
	Offset       float64
	Range        float64
	SamplingRate float64
	LenRawSignal uint64
	RawSignal    []int16

	// Auxiliary fields
	ChannelNumber string
	MedianBefore  float64
	ReadNumber    int32
	StartMux      uint8
	StartTime     uint64
	EndReason     string // enum{unknown,partial,mux_change,unblock_mux_change,data_service_unblock_mux_change,signal_positive,signal_negative}

	Error error // in case there is an error while parsing!
}

Read contains metadata and raw signal strengths for a single nanopore read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL