fasta

package
v5.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 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)

ParseFai parses an FAI file.

func ParseFasta

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

ParseFasta sequentially parses a FASTA file.

If fai is given, the sequences can be pre-allocated to reduce pressure on the garbage collector. If toUpper is true, the contents are converetd to upper case. If toN is true, ambiguity codes are normalized.

func ToElfasta

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

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

func ToN

func ToN(base byte) byte

ToN can be used to normalize ambiguity codes in FASTA references.

func ToUpperAndN

func ToUpperAndN(base byte) byte

ToUpperAndN can be used to normalize ambiguity codes in FASTA references, and convert all codes to upper case.

Types

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 an .elfasta file.

func OpenElfasta

func OpenElfasta(filename string) (result *MappedFasta)

OpenElfasta opens a .elfasta file.

func (*MappedFasta) Close

func (fasta *MappedFasta) Close()

Close closes the .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