fai

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: BSD-3-Clause Imports: 8 Imported by: 6

Documentation

Overview

Package fai implements FAI fasta sequence file index handling.

Index

Constants

This section is empty.

Variables

View Source
var ErrNonUnique = errors.New("non-unique record name")

Functions

func WriteTo added in v1.2.1

func WriteTo(w io.Writer, idx Index) error

WriteTo writes the given index to w in order of ascending start position.

Types

type File

type File struct {
	Index
	// contains filtered or unexported fields
}

File is a sequence file with an FAI index.

func NewFile

func NewFile(r io.ReaderAt, idx Index) *File

NewFile returns the sequence file for the given reader and associates it with the specified index.

func (*File) Seq

func (f *File) Seq(name string) (*Seq, error)

Seq returns a handle to the complete sequence identified by the given name.

func (*File) SeqRange

func (f *File) SeqRange(name string, start, end int) (*Seq, error)

Seq returns a handle to the sequence identified by the given name from the start position until the end position.

type Index

type Index map[string]Record

Index is an FAI index.

func NewIndex added in v1.2.1

func NewIndex(fasta io.Reader) (Index, error)

NewIndex returns a new Index constructed from the FASTA sequence in the provided io.Reader.

func ReadFrom

func ReadFrom(r io.Reader) (idx Index, err error)

ReadFrom returns an Index from the stream provided by an io.Reader or an error. If the input contains non-unique records the error is a csv.ParseError identifying the second non-unique record.

type Record

type Record struct {
	// Name is the name of the sequence.
	Name string
	// Length is the length of the sequence.
	Length int
	// Start is the starting seek offset of
	// the sequence.
	Start int64
	// BasesPerLine is the number of sequences
	// bases per line.
	BasesPerLine int
	// BytesPerLine is the number of bytes
	// used to represent each line.
	BytesPerLine int
}

Record is a single FAI index record.

func (Record) Position

func (r Record) Position(p int) int64

Position returns the seek offset of the sequence position p for the given Record.

type Seq

type Seq struct {
	Record
	// contains filtered or unexported fields
}

Seq is a handle to a sequence segment obtained from a File.

func (*Seq) Read

func (s *Seq) Read(b []byte) (int, error)

Read reads sequence data from the Seq into b.

func (*Seq) Reset

func (s *Seq) Reset()

Reset resets the position of the cursor into the sequence segment to the original start.

Jump to

Keyboard shortcuts

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