twobit

package
v0.0.0-...-d92f75b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2016 License: AGPL-3.0, BSD-3-Clause Imports: 5 Imported by: 0

README

===============================================================================
twobit - Read/Write 2bit files
===============================================================================

-------------------------------------------------------------------------------
About
-------------------------------------------------------------------------------

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

-------------------------------------------------------------------------------
Install
-------------------------------------------------------------------------------

Fetch from github::

    $ go get install github.com/aebruno/twobit

-------------------------------------------------------------------------------
Usage
-------------------------------------------------------------------------------

TODO

-------------------------------------------------------------------------------
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'
View Source
const BASE_C = 'C'
View Source
const BASE_G = 'G'
View Source
const BASE_N = 'N'
View Source
const BASE_T = 'T'
View Source
const SIG = 0x1A412743

Variables

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

Functions

func Pack

func Pack(s string) ([]byte, error)

Packs DNA sequence string into an array of bytes. 4 bases per byte.

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

Return count of block

func (*Block) Length

func (b *Block) Length() int

Return length of block

func (*Block) Start

func (b *Block) Start() int

Return start of block

type Reader

type Reader twoBit

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

Returns the count of sequences in the 2bit file

func (*Reader) Length

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

Returns the length for sequence with name

func (*Reader) LengthNoN

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

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

func (*Reader) NBlocks

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

Return blocks of Ns in sequence with name

func (*Reader) Names

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

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)

Read sequence from start to end.

func (*Reader) Version

func (r *Reader) Version() int

Returns the version of the 2bit file

type Writer

type Writer twoBit

func NewWriter

func NewWriter() *Writer

New Writer

func (*Writer) Add

func (w *Writer) Add(name, seq string) error

Add sequence

func (*Writer) WriteTo

func (w *Writer) WriteTo(out io.Writer) error

Write sequences in 2bit format to out

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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