twobit

package module
v0.0.0-...-05260b0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: BSD-3-Clause Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mendelics/twobit

twobit is a 2bit file reader

twobit is pure Go library for reading 2bit files [1]. The 2bit file format stores DNA sequences in a compact randomly-accessible format.

Modified from github.com/aebruno/twobit.

References

[1] http://genome.ucsc.edu/FAQ/FAQformat#format7

Documentation

Overview

Package twobit implements the 2bit compact randomly-accessible file format for storing DNA sequence data.

Index

Constants

View Source
const BASE_A = 'A'

BASE_A -

View Source
const BASE_C = 'C'

BASE_C -

View Source
const BASE_G = 'G'

BASE_G -

View Source
const BASE_N = 'N'

BASE_N -

View Source
const BASE_T = 'T'

BASE_T -

View Source
const SIG = 0x1A412743

SIG -

Variables

View Source
var BYTES2NT = []byte{
	BASE_T,
	BASE_C,
	BASE_A,
	BASE_G,
}

BYTES2NT -

View Source
var NT2BYTES = []byte{}

NT2BYTES -

Functions

func Unpack

func Unpack(raw []byte, sz int) string

Unpack array of bytes to DNA string of length sz

Types

type Block

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

Block represents either blocks of Ns or masked (lower-case) blocks

func (*Block) Count

func (b *Block) Count() int

Count - Return count of block

func (*Block) Length

func (b *Block) Length() int

Length - Return length of block

func (*Block) Start

func (b *Block) Start() int

Start - Return start of block

type Reader

type Reader twoBit

Reader reads twobits

func NewReader

func NewReader(r io.ReadSeeker) (*Reader, error)

NewReader returns a new TwoBit file reader which reads from r

func (*Reader) Count

func (r *Reader) Count() int

Count - Returns the count of sequences in the 2bit file

func (*Reader) Length

func (r *Reader) Length(name string) (int, error)

Length - Returns the length for sequence with name

func (*Reader) LengthNoN

func (r *Reader) LengthNoN(name string) (int, error)

LengthNoN - Returns the length for sequence with name but does not count Ns

func (*Reader) NBlocks

func (r *Reader) NBlocks(name string) ([]*Block, error)

NBlocks - Return blocks of Ns in sequence with name

func (*Reader) Names

func (r *Reader) Names() []string

Names - Returns the names of sequences in the 2bit file

func (*Reader) Read

func (r *Reader) Read(name string) ([]byte, error)

Read entire sequence.

func (*Reader) ReadRange

func (r *Reader) ReadRange(name string, start, end int) ([]byte, error)

ReadRange - Read sequence from start to end.

func (*Reader) Version

func (r *Reader) Version() int

Version - Returns the version of the 2bit file

type Service

type Service interface {
	// Genomic Interval-based services
	GenomicInterval(chr string, start, end int) (string, error)                                                                                      // returns genomic sequence using 2-bit (from memory)
	GetGenomicIntervalWindow(chr string, start, end int, ref, alt string, windowL, windowR int) (seqRef, seqAlt string, err error)                   // returns ref and alt with window to left and right
	GetGenomicIntervalBound(chr string, start, end int, ref, alt string, intervalStart, intervalEnd int) (seqRef, seqAlt string, err error)          // returns ref and alt bound by interval (ex. interval = exon, will return exonRef and exonAlt sequences)
	GetGenomicIntervalStrand(chr string, start, end int, ref, alt string, windowL, windowR int, isPosStrand bool) (seqRef, seqAlt string, err error) // returns ref and alt with window to left and right, correct strand
}

Service includes all services

func NewDataService

func NewDataService(twobitFile string) (Service, error)

NewDataService - Open 2-bit genome reference

type Writer

type Writer twoBit

Writer writes twobits

Jump to

Keyboard shortcuts

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