internal

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package internal provides shared code for BAI and tabix index implementations.

Index

Constants

View Source
const (
	// TileWidth is the length of the interval tiling used
	// in BAI and tabix indexes.
	TileWidth = 0x4000

	// StatsDummyBin is the bin number of the reference
	// statistics bin used in BAI and tabix indexes.
	StatsDummyBin = 0x924a
)

Variables

This section is empty.

Functions

func BinFor

func BinFor(beg, end int) uint32

BinFor returns the bin number for given an interval covering [beg,end) (zero-based, half-close-half-open).

func IsValidIndexPos

func IsValidIndexPos(i int) bool

IsValidIndexPos returns a boolean indicating whether the given position is in the valid range for BAM/SAM.

func OverlappingBinsFor

func OverlappingBinsFor(beg, end int) []uint32

OverlappingBinsFor returns the bin numbers for all bins overlapping an interval covering [beg,end) (zero-based, half-close-half-open).

func WriteIndex

func WriteIndex(w io.Writer, idx *Index, typ string) error

WriteIndex writes the Index to the given io.Writer.

Types

type Bin

type Bin struct {
	Bin    uint32
	Chunks []bgzf.Chunk
}

Bin is an index bin.

type Index

type Index struct {
	Refs       []RefIndex
	Unmapped   *uint64
	IsSorted   bool
	LastRecord int
}

Index is a coordinate based index.

func ReadIndex

func ReadIndex(r io.Reader, n int32, typ string) (Index, error)

ReadIndex reads the Index from the given io.Reader.

func (*Index) Add

func (i *Index) Add(r Record, bin uint32, c bgzf.Chunk, placed, mapped bool) error

Add records the SAM record as having being located at the given chunk.

func (*Index) Chunks

func (i *Index) Chunks(rid, beg, end int) ([]bgzf.Chunk, error)

Chunks returns a []bgzf.Chunk that corresponds to the given genomic interval.

func (*Index) MergeChunks

func (i *Index) MergeChunks(s func([]bgzf.Chunk) []bgzf.Chunk)

MergeChunks applies the given MergeStrategy to all bins in the Index.

type Record

type Record interface {
	RefID() int
	Start() int
	End() int
}

Record wraps types that may be indexed by an Index.

type RefIndex

type RefIndex struct {
	Bins      []Bin
	Stats     *ReferenceStats
	Intervals []bgzf.Offset
}

RefIndex is the index of a single reference.

type ReferenceStats

type ReferenceStats struct {
	// Chunk is the span of the indexed BGZF
	// holding alignments to the reference.
	Chunk bgzf.Chunk

	// Mapped is the count of mapped reads.
	Mapped uint64

	// Unmapped is the count of unmapped reads.
	Unmapped uint64
}

ReferenceStats holds mapping statistics for a genomic reference.

Jump to

Keyboard shortcuts

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