fasta

package
v4.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Overview

Package fasta is a library for parsing and representing FASTA files, and creating and reading elfasta files.

Index

Constants

This section is empty.

Variables

View Source
var ElfastaMagic = []byte{0x31, 0xFA, 0x57, 0xA1} // 31FA57A1 => ELFASTA1

ElfastaMagic is the magic byte sequence that every .elfasta file starts with.

Functions

func ParseFai

func ParseFai(filename string) (fai map[string]FaiReference, err error)

ParseFai parses an FAI file.

func ParseFasta

func ParseFasta(filename string, fai map[string]FaiReference, toUpper, toN bool) (fasta map[string][]byte, err error)

ParseFasta sequentially parses a FASTA file.

If fai is given, the sequences can be pre-allocated to reduce pressure on the garbage collector.

func ToElfasta

func ToElfasta(fasta map[string][]byte, filename string) (err error)

ToElfasta stores fasta data into an elprep-defined mmappable .elfasta file.

Types

type ConcurrentFasta

type ConcurrentFasta map[string]*ConcurrentFastaEntry

ConcurrentFasta represents a FASTA file that can be parsed concurrently.

func OpenConcurrentFasta

func OpenConcurrentFasta(filename, fai string, toUpper, toN bool) (fasta ConcurrentFasta, err error)

OpenConcurrentFasta prepares the FASTA representation for concurrent parsing. The fai parameter must be passed.

func (ConcurrentFasta) Seq

func (fasta ConcurrentFasta) Seq(contig string) []byte

Seq fetches a sequence for the given contig from the FASTA file representation. This method blocks if the contig has not been parsed yet.

type ConcurrentFastaEntry

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

ConcurrentFastaEntry represents an entry in a FASTA file.

type FaiReference

type FaiReference struct {
	Length    int32
	Offset    int64
	LineBases int32
	LineWidth int32
}

FaiReference represents an entry in an FAI file.

type MappedFasta

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

MappedFasta represents the contents of a .elfasta file.

func OpenElfasta

func OpenElfasta(filename string) (*MappedFasta, error)

OpenElfasta opens a .elfasta file.

func (*MappedFasta) Close

func (fasta *MappedFasta) Close() (err error)

Close closes a .elfasta file.

func (*MappedFasta) Seq

func (fasta *MappedFasta) Seq(contig string) []byte

Seq fetches a sequence for the given contig from the .elfasta file.

Jump to

Keyboard shortcuts

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