gonetics

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: GPL-3.0 Imports: 24 Imported by: 9

README

Gonetics

Gonetics is a bioinformatics library for the Go programming language (golang). It provides native data structures for handling genetic data and methods for handling common file formats such as BAM, GTF, BED, BigWig, and Wig. The documentation is available here.

Tools

Executables are available here.

Tool Description
bamCheckBin check bin records of a bam file
bamGenome print the genome (sequence table) of a bam file
bamToBigWig convert bam to bigWig (estimate fragment length if required)
bamView print contents of a bam file
bigWigEditChromNames edit chromosome names of a bigWig file (i.e. replace chr1 by just 1)
bigWigExtract extract regions from a bigWig file and save them as table or bigWig file
bigWigExtractChroms extract a subset of the chromosomes from a bigWig file
bigWigGenome print the genome (sequence table) of a bigWig file
bigWigHistogram compute a histogram of the values in a bigWig file
bigWigNil read bigWig and output it to a new file
bigWigMap apply a function to a set of bigWig files
bigWigPositive simple peak finding (i.e. every region with a value above a threshold)
bigWigQuantileNormalize quantile normalize a bigWig file to a reference
bigWigQuery retrieve data from a bigWig file
bigWigQuerySequence retrieve sequences from a bigWig file
bigWigStatistics compute summary statistics of a bigWig file
chromHmmTablesToBigWig convert chromHmm output (posteriors / binariezed bams) to bigWig
countKmers count kmers in a set of DNA sequences
drawGenomicRegions draw random genomic regions
fastaExtract extract regions from a fasta file
fastaUnresolvedRegions identify regions that are not resolved (i.e. stretches of 'NNNN...')
gtfToBed convert GTF files to Bed6 format
memeExtract extract PWM/PPM motifs from MEME/DREME xml files
observedOverExpectedCpG compute CpG scores as defined by Gardiner-Garden and Frommer (1987)
pwmScanSequences scan sequences for PWM hits
pwmScanRegions scan regions for multiple PWMs
segmentationDifferential extract differential regions from multiple chromatin segmentations

GRanges

Create a GRanges object with three ranges on the first chromosome:

  seqnames := []string{"chr1", "chr1", "chr1"}
  from     := []int{100000266, 100000271, 100000383}
  to       := []int{100000291, 100000296, 100000408}
  strand   := []byte{'+', '+', '-'}

  granges  := NewGRanges(seqnames, from, to, strand)
  fmt.Println(granges)
  seqnames                 ranges strand
1     chr1 [100000266, 100000291)      +
2     chr1 [100000271, 100000296)      +
3     chr1 [100000383, 100000408)      -

Add some meta data to the GRanges object:

  granges.AddMeta("data", []float64{1.0, 2.0, 3.0})
  seqnames                 ranges strand |          data
1     chr1 [100000266, 100000291)      + |      1.000000
2     chr1 [100000271, 100000296)      + |      2.000000
3     chr1 [100000383, 100000408)      - |      3.000000

Find overlaps of two GRanges objects:

  rSubjects := NewGRanges(
    []string{"chr4", "chr4", "chr4", "chr4"},
    []int{100, 200, 300, 400},
    []int{150, 250, 350, 450},
    []byte{})
  rQuery := NewGRanges(
    []string{"chr1", "chr4", "chr4", "chr4", "chr4", "chr4"},
    []int{100, 110, 190, 340, 390, 450},
    []int{150, 120, 220, 360, 400, 500},
    []byte{})

  queryHits, subjectHits := FindOverlaps(rQuery, rSubjects)
  queryHits: [1 2 3 4 5]
subjectHits: [0 1 2 3 3]

Genes

Download gene list from UCSC and export it to file:

  genes := ImportGenesFromUCSC("hg19", "ensGene")
  genes.WriteTable("hg19.knownGene.txt", true, false)
  fmt.Println(genes)
                 names seqnames          transcripts                  cds strand
     1 ENST00000456328     chr1 [   11868,    14409) [   14409,    14409)      +
     2 ENST00000515242     chr1 [   11871,    14412) [   14412,    14412)      +
     3 ENST00000518655     chr1 [   11873,    14409) [   14409,    14409)      +
     4 ENST00000450305     chr1 [   12009,    13670) [   13670,    13670)      +
     5 ENST00000423562     chr1 [   14362,    29370) [   29370,    29370)      -
                   ...      ...                  ...                  ...       
204936 ENST00000420810     chrY [28695571, 28695890) [28695890, 28695890)      +
204937 ENST00000456738     chrY [28732788, 28737748) [28737748, 28737748)      -
204938 ENST00000435945     chrY [28740997, 28780799) [28780799, 28780799)      -
204939 ENST00000435741     chrY [28772666, 28773306) [28773306, 28773306)      -
204940 ENST00000431853     chrY [59001390, 59001635) [59001635, 59001635)      +

Import expression data from a GTF file:

  genes.ImportGTF("genesExpr_test.gtf.gz", "transcript_id", "FPKM", false)
                 names seqnames          transcripts                  cds strand |          expr
     1 ENST00000456328     chr1 [   11868,    14409) [   14409,    14409)      + |      0.073685
     2 ENST00000515242     chr1 [   11871,    14412) [   14412,    14412)      + |      0.000000
     3 ENST00000518655     chr1 [   11873,    14409) [   14409,    14409)      + |      0.000000
     4 ENST00000450305     chr1 [   12009,    13670) [   13670,    13670)      + |      0.000000
     5 ENST00000423562     chr1 [   14362,    29370) [   29370,    29370)      - |     10.413931
                   ...      ...                  ...                  ...        |           ...
204936 ENST00000420810     chrY [28695571, 28695890) [28695890, 28695890)      + |      0.000000
204937 ENST00000456738     chrY [28732788, 28737748) [28737748, 28737748)      - |      0.000000
204938 ENST00000435945     chrY [28740997, 28780799) [28780799, 28780799)      - |      0.000000
204939 ENST00000435741     chrY [28772666, 28773306) [28773306, 28773306)      - |      0.000000
204940 ENST00000431853     chrY [59001390, 59001635) [59001635, 59001635)      + |      0.000000

Peaks

Import peaks from a MACS xls file:

  peaks := ImportXlsPeaks("peaks_test.xls")
   seqnames             ranges strand |  abs_summit     pileup -log10(pvalue) fold_enrichment -log10(qvalue)
 1       2L [   5757,    6001)      * |        5865  33.000000      19.809300        6.851880      17.722200
 2       2L [  47233,   47441)      * |       47354  36.000000      19.648200        6.263150      17.566200
 3       2L [  66379,   67591)      * |       66957 252.000000     350.151250       50.986050     346.525450
 4       2L [  72305,   72838)      * |       72525 170.000000     208.558240       34.460930     205.734390
 5       2L [  72999,   73218)      * |       73130  25.000000      12.711700        5.239670      10.700880
        ...                ...        |         ...        ...            ...             ...            ...
12       2R [3646319, 3646794)      * |     3646442  37.000000      23.176910        7.455710      21.063850
13       2R [3666770, 3668041)      * |     3667119 215.000000     279.229060       41.551060     276.108090
14       2R [3668231, 3668441)      * |     3668363  22.000000       9.943110        4.476950       7.976070
15       2R [3670063, 3670393)      * |     3670180  38.000000      19.474590        5.901360      17.393440
16       2R [3670470, 3670927)      * |     3670719 227.000000     305.243350       45.831180     301.974760

Track

Import ChIP-seq reads from bed files and create a track with the normalized signal:

  fmt.Fprintf(os.Stderr, "Parsing reads (treatment) ...\n")
  treatment1 := GRanges{}
  treatment1.ImportBed6("SRR094207.bed")
  treatment2 := GRanges{}
  treatment2.ImportBed6("SRR094208.bed")
  fmt.Fprintf(os.Stderr, "Parsing reads (control)   ...\n")
  control1   := GRanges{}
  control1.ImportBed6("SRR094215.bed")
  control2   := GRanges{}
  control2.ImportBed6("SRR094216.bed")

  genome  := Genome{}
  genome.Import("Data/hg19.genome")
  d       := 200 // d=200 (see *_peaks.xls)
  binsize := 100 // binsize of the track
  pcounts := 1   // pseudocounts
  track := NormalizedTrack("H3K4me3",
    []GRanges{treatment1, treatment2}, []GRanges{control1, control2},
    genome, d, binsize, pcounts, pcounts, false)

Export track to wig or bigWig:

  track.WriteWiggle("track.wig", "track description")
  track.WriteBigWig("track.bw",  "track description")

BigWig Files

BigWig files contain data in a binary format optimized for fast random access. In addition to the raw data, bigWig files typically contain several zoom levels for which the data has been summarized. The BigWigReader class allows to query data and it automatically selects an appropriate zoom level for the given binsize:

  reader, err := NewBigWigReader("test.bw")
  if err != nil {
    log.Fatal(err)
  }
  // query details
  seqname := "chr4" // (regular expression)
  from    := 11774000
  to      := 11778000
  binsize := 20

  for record := range reader.Query(seqname, from, to, binsize) {
    if record.Error != nil {
      log.Fatalf("reading bigWig failed: %v", record.Error)
    }
    fmt.Println(record)
  }

Documentation

Index

Constants

View Source
const BIGWIG_MAGIC = 0x888FFC26
View Source
const BbiMaxZoomLevels = 10 /* Max number of zoom levels */
View Source
const BbiResIncrement = 4 /* Amount to reduce at each zoom level */
View Source
const BbiTypeBedGraph = 1
View Source
const BbiTypeFixed = 3
View Source
const BbiTypeVariable = 2
View Source
const CIRTREE_MAGIC = 0x78ca8c91
View Source
const IDX_MAGIC = 0x2468ace0

Variables

View Source
var ErrFraglenEstimate = fmt.Errorf("estimating fragment length failed")

Functions

func BinDiscreteMax

func BinDiscreteMax(sum, sumSquares, min, max, n float64) float64

func BinDiscreteMean

func BinDiscreteMean(sum, sumSquares, min, max, n float64) float64

func BinDiscreteMin

func BinDiscreteMin(sum, sumSquares, min, max, n float64) float64

func BinMax

func BinMax(sum, sumSquares, min, max, n float64) float64

func BinMean

func BinMean(sum, sumSquares, min, max, n float64) float64

func BinMin

func BinMin(sum, sumSquares, min, max, n float64) float64

func BinVariance

func BinVariance(sum, sumSquares, min, max, n float64) float64

func CrosscorrelateReads

func CrosscorrelateReads(reads ReadChannel, genome Genome, maxDelay, binSize int) ([]int, []float64, int, uint64, error)

Compute crosscorrelation between reads on the forward and reverse strand.

func EstimateFragmentLength

func EstimateFragmentLength(reads ReadChannel, genome Genome, maxDelay, binSize int, fraglenRange [2]int) (int, []int, []float64, uint64, error)

func FindNearest

func FindNearest(query, subject GRanges, k int) ([]int, []int, []int)

For every query region find the k nearest subject regions including all overlapping regions.

func FindOverlaps

func FindOverlaps(query, subject GRanges) ([]int, []int)

func IsBamFile

func IsBamFile(filename string) (bool, error)

func IsBigWigFile

func IsBigWigFile(filename string) (bool, error)

func NewEndPointList

func NewEndPointList() endPointList

func ObservedOverExpectedCpG

func ObservedOverExpectedCpG(sequence []byte) float64

Gardiner-Garden and Frommer, J. Mol. Biol. (1987) 196 (2), 261-282:

observed * length / (number of C * number of G)

func ParseCigar

func ParseCigar(cigar BamCigar) <-chan CigarBlock

func TrackAutocorrelation

func TrackAutocorrelation(track Track, from, to int, normalize bool) (x []int, y []float64, err error)

Compute the sample autocorrelation. If [normalize] is true the result is normalized by mean and variance. The arguments [from] and [to] specify the range of the delay in basepairs.

func TrackCrosscorrelation

func TrackCrosscorrelation(track1, track2 Track, from, to int, normalize bool) (x []int, y []float64, err error)

Compute the sample cross-correlation between track1 and track2. If [normalize] is true the result is normalized by mean and variance. The arguments [from] and [to] specify the range of the delay in basepairs.

Types

type Alphabet

type Alphabet interface {
	Bases(i byte) ([]byte, error)
	Matching(i byte) ([]byte, error)
	Code(i byte) (byte, error)
	Decode(i byte) (byte, error)
	IsAmbiguous(i byte) (bool, error)
	IsWildcard(i byte) (bool, error)
	Length() int
	LengthUnambiguous() int
	String() string
}

type AmbiguousNucleotideAlphabet

type AmbiguousNucleotideAlphabet struct {
}

func (AmbiguousNucleotideAlphabet) Bases

func (AmbiguousNucleotideAlphabet) Code

func (AmbiguousNucleotideAlphabet) Complement

func (AmbiguousNucleotideAlphabet) Complement(i byte) (byte, error)

func (AmbiguousNucleotideAlphabet) ComplementCoded

func (AmbiguousNucleotideAlphabet) ComplementCoded(i byte) (byte, error)

func (AmbiguousNucleotideAlphabet) Decode

func (AmbiguousNucleotideAlphabet) IsAmbiguous

func (AmbiguousNucleotideAlphabet) IsAmbiguous(i byte) (bool, error)

func (AmbiguousNucleotideAlphabet) IsWildcard

func (AmbiguousNucleotideAlphabet) IsWildcard(i byte) (bool, error)

func (AmbiguousNucleotideAlphabet) Length

func (AmbiguousNucleotideAlphabet) LengthUnambiguous

func (AmbiguousNucleotideAlphabet) LengthUnambiguous() int

func (AmbiguousNucleotideAlphabet) Matching

func (AmbiguousNucleotideAlphabet) Matching(i byte) ([]byte, error)

func (AmbiguousNucleotideAlphabet) String

type BData

type BData struct {
	KeySize       uint32
	ValueSize     uint32
	ItemsPerBlock uint32
	ItemCount     uint64

	Keys   [][]byte
	Values [][]byte

	PtrKeys   []int64
	PtrValues []int64
}

func NewBData

func NewBData() *BData

func (*BData) Add

func (data *BData) Add(key, value []byte) error

func (*BData) Read

func (data *BData) Read(file io.ReadSeeker, order binary.ByteOrder) error

func (*BData) Write

func (data *BData) Write(file io.WriteSeeker, order binary.ByteOrder) error

type BTree

type BTree struct {
	KeySize       uint32
	ValueSize     uint32
	ItemsPerBlock uint32
	ItemCount     uint64
	Root          BVertex
}

func NewBTree

func NewBTree(data *BData) *BTree

func (*BTree) Write

func (tree *BTree) Write(file io.WriteSeeker, order binary.ByteOrder) error

type BVertex

type BVertex struct {
	IsLeaf   uint8
	Keys     [][]byte
	Values   [][]byte
	Children []BVertex
}

func (*BVertex) BuildTree

func (vertex *BVertex) BuildTree(data *BData, from, to uint64, level int) (uint64, error)

type BamAuxiliary

type BamAuxiliary struct {
	Tag   [2]byte
	Value interface{}
}

func (*BamAuxiliary) Read

func (aux *BamAuxiliary) Read(reader io.Reader) (int, error)

func (*BamAuxiliary) String

func (aux *BamAuxiliary) String() string

type BamBlock

type BamBlock struct {
	RefID        int32
	Position     int32
	Bin          uint16
	MapQ         uint8
	RNLength     uint8
	Flag         BamFlag
	NCigarOp     uint16
	LSeq         int32
	NextRefID    int32
	NextPosition int32
	TLength      int32
	ReadName     string
	Cigar        BamCigar
	Seq          BamSeq
	Qual         BamQual
	Auxiliary    []BamAuxiliary
}

type BamCigar

type BamCigar []uint32

func (BamCigar) AlignmentLength

func (cigar BamCigar) AlignmentLength() int

func (BamCigar) String

func (cigar BamCigar) String() string

type BamCoverageConfig

type BamCoverageConfig struct {
	Logger                  *log.Logger
	BinningMethod           string
	BinSize                 int
	BinOverlap              int
	NormalizeTrack          string
	ShiftReads              [2]int
	PairedAsSingleEnd       bool
	PairedEndStrandSpecific bool
	LogScale                bool
	Pseudocounts            [2]float64
	EstimateFraglen         bool
	FraglenRange            [2]int
	FraglenBinSize          int
	FilterChroms            []string
	FilterMapQ              int
	FilterReadLengths       [2]int
	FilterDuplicates        bool
	FilterStrand            byte
	FilterPairedEnd         bool
	FilterSingleEnd         bool
	SmoothenControl         bool
	SmoothenSizes           []int
	SmoothenMin             float64
}

func BamCoverageDefaultConfig

func BamCoverageDefaultConfig() BamCoverageConfig

type BamFile

type BamFile struct {
	BamReader
	// contains filtered or unexported fields
}

func OpenBamFile

func OpenBamFile(filename string, args ...interface{}) (*BamFile, error)

func (*BamFile) Close

func (obj *BamFile) Close() error

type BamFlag

type BamFlag uint16

func (BamFlag) Bit

func (flag BamFlag) Bit(i uint) bool

func (BamFlag) Duplicate

func (flag BamFlag) Duplicate() bool

func (BamFlag) FirstInPair

func (flag BamFlag) FirstInPair() bool

func (BamFlag) MateReverseStrand

func (flag BamFlag) MateReverseStrand() bool

func (BamFlag) MateUnmapped

func (flag BamFlag) MateUnmapped() bool

func (BamFlag) NotPassingFilters

func (flag BamFlag) NotPassingFilters() bool

func (BamFlag) ReadMappedProperPaired

func (flag BamFlag) ReadMappedProperPaired() bool

func (BamFlag) ReadPaired

func (flag BamFlag) ReadPaired() bool

func (BamFlag) ReverseStrand

func (flag BamFlag) ReverseStrand() bool

func (BamFlag) SecondInPair

func (flag BamFlag) SecondInPair() bool

func (BamFlag) SecondaryAlignment

func (flag BamFlag) SecondaryAlignment() bool

func (BamFlag) Unmapped

func (flag BamFlag) Unmapped() bool

type BamHeader

type BamHeader struct {
	TextLength int32
	Text       string
	NRef       int32
}

type BamQual

type BamQual []byte

func (BamQual) String

func (qual BamQual) String() string

type BamReader

type BamReader struct {
	BgzfReader
	Options BamReaderOptions
	Header  BamHeader
	Genome  Genome
}

func NewBamReader

func NewBamReader(r io.Reader, args ...interface{}) (*BamReader, error)

func (*BamReader) Read

func (reader *BamReader) Read() <-chan *BamReaderType2

Read single or paired end reads

func (*BamReader) ReadPairedEnd

func (reader *BamReader) ReadPairedEnd() <-chan *BamReaderType2

func (*BamReader) ReadSimple

func (reader *BamReader) ReadSimple(joinPairs, pairedEndStrandSpecific bool) ReadChannel

Simplified reader of single and paired-end reads. All reads that are not mapped are dropped. For paired end reads, if [joinPairs] is true then the range gives the position and length of the entire fragment. If any of the two reads is marked as duplicate, then the result is marked as duplicate. The mapping quality of the result is the minimum quality of the two reads. Any paired end reads that are not properly paired are ignored

func (*BamReader) ReadSingleEnd

func (reader *BamReader) ReadSingleEnd() <-chan *BamReaderType1

type BamReaderOptions

type BamReaderOptions struct {
	ReadName      bool
	ReadCigar     bool
	ReadSequence  bool
	ReadAuxiliary bool
	ReadQual      bool
}

type BamReaderType1

type BamReaderType1 struct {
	BamBlock
	Error error
}

type BamReaderType2

type BamReaderType2 struct {
	Block1 BamBlock
	Block2 BamBlock
	Error  error
}

type BamSeq

type BamSeq []byte

func (BamSeq) String

func (seq BamSeq) String() string

type BbiBlockDecoder

type BbiBlockDecoder interface {
	Decode() BbiBlockDecoderIterator
}

type BbiBlockDecoderIterator

type BbiBlockDecoderIterator interface {
	Get() *BbiBlockDecoderType
	Ok() bool
	Next()
}

type BbiBlockDecoderType

type BbiBlockDecoderType struct {
	BbiSummaryRecord
}

type BbiBlockEncoder

type BbiBlockEncoder interface {
	Encode(chromid int, sequence []float64, binSize int) BbiBlockEncoderIterator
}

type BbiBlockEncoderIterator

type BbiBlockEncoderIterator interface {
	Get() *BbiBlockEncoderType
	Ok() bool
	Next()
}

type BbiBlockEncoderType

type BbiBlockEncoderType struct {
	From  int
	To    int
	Block []byte
}

type BbiDataHeader

type BbiDataHeader struct {
	ChromId   uint32
	Start     uint32
	End       uint32
	Step      uint32
	Span      uint32
	Type      byte
	Reserved  byte
	ItemCount uint16
}

func (*BbiDataHeader) ReadBuffer

func (header *BbiDataHeader) ReadBuffer(buffer []byte, order binary.ByteOrder)

func (*BbiDataHeader) WriteBuffer

func (header *BbiDataHeader) WriteBuffer(buffer []byte, order binary.ByteOrder)

type BbiFile

type BbiFile struct {
	Header    BbiHeader
	ChromData BData
	Index     RTree
	IndexZoom []RTree
	Order     binary.ByteOrder
}

func NewBbiFile

func NewBbiFile() *BbiFile

func (*BbiFile) Create

func (bwf *BbiFile) Create(writer io.WriteSeeker) error

func (*BbiFile) Open

func (bwf *BbiFile) Open(reader_ io.ReadSeeker) error

func (*BbiFile) Query

func (bwf *BbiFile) Query(reader io.ReadSeeker, chromId, from, to, binSize int) <-chan BbiQueryType

func (*BbiFile) ReadIndex

func (bwf *BbiFile) ReadIndex(reader_ io.ReadSeeker) error

func (*BbiFile) ReadZoomIndex

func (bwf *BbiFile) ReadZoomIndex(reader_ io.ReadSeeker, i int) error

func (*BbiFile) WriteChromList

func (bwf *BbiFile) WriteChromList(writer io.WriteSeeker) error

func (*BbiFile) WriteIndex

func (bwf *BbiFile) WriteIndex(writer io.WriteSeeker) error

func (*BbiFile) WriteIndexZoom

func (bwf *BbiFile) WriteIndexZoom(writer io.WriteSeeker, i int) error

type BbiHeader

type BbiHeader struct {
	Magic             uint32
	Version           uint16
	ZoomLevels        uint16
	CtOffset          uint64
	DataOffset        uint64
	IndexOffset       uint64
	FieldCould        uint16
	DefinedFieldCount uint16
	SqlOffset         uint64
	SummaryOffset     uint64
	UncompressBufSize uint32
	ExtensionOffset   uint64
	NBasesCovered     uint64
	MinVal            float64
	MaxVal            float64
	SumData           float64
	SumSquares        float64
	ZoomHeaders       []BbiHeaderZoom
	NBlocks           uint64
	// offset positions
	PtrCtOffset          int64
	PtrDataOffset        int64
	PtrIndexOffset       int64
	PtrSqlOffset         int64
	PtrSummaryOffset     int64
	PtrUncompressBufSize int64
	PtrExtensionOffset   int64
}

func NewBbiHeader

func NewBbiHeader() *BbiHeader

func (*BbiHeader) Read

func (header *BbiHeader) Read(file io.ReadSeeker, magic uint32) (binary.ByteOrder, error)

func (*BbiHeader) SummaryAddValue

func (header *BbiHeader) SummaryAddValue(x float64, n int)

func (*BbiHeader) Write

func (header *BbiHeader) Write(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeader) WriteNBlocks

func (header *BbiHeader) WriteNBlocks(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeader) WriteOffsets

func (header *BbiHeader) WriteOffsets(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeader) WriteSummary

func (header *BbiHeader) WriteSummary(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeader) WriteUncompressBufSize

func (header *BbiHeader) WriteUncompressBufSize(file io.WriteSeeker, order binary.ByteOrder) error

type BbiHeaderZoom

type BbiHeaderZoom struct {
	ReductionLevel uint32
	Reserved       uint32
	DataOffset     uint64
	IndexOffset    uint64
	NBlocks        uint32
	PtrDataOffset  int64
	PtrIndexOffset int64
}

func (*BbiHeaderZoom) Read

func (zoomHeader *BbiHeaderZoom) Read(file io.ReadSeeker, order binary.ByteOrder) error

func (*BbiHeaderZoom) Write

func (zoomHeader *BbiHeaderZoom) Write(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeaderZoom) WriteNBlocks

func (zoomHeader *BbiHeaderZoom) WriteNBlocks(file io.WriteSeeker, order binary.ByteOrder) error

func (*BbiHeaderZoom) WriteOffsets

func (zoomHeader *BbiHeaderZoom) WriteOffsets(file io.WriteSeeker, order binary.ByteOrder) error

type BbiQueryType

type BbiQueryType struct {
	BbiSummaryRecord
	DataType byte
	Quit     func()
	Error    error
}

func NewBbiQueryType

func NewBbiQueryType(quit func()) BbiQueryType

type BbiRawBlockDecoder

type BbiRawBlockDecoder struct {
	Header BbiDataHeader
	Buffer []byte
	// contains filtered or unexported fields
}

func NewBbiRawBlockDecoder

func NewBbiRawBlockDecoder(buffer []byte, order binary.ByteOrder) (*BbiRawBlockDecoder, error)

func (*BbiRawBlockDecoder) Decode

func (*BbiRawBlockDecoder) GetDataType

func (reader *BbiRawBlockDecoder) GetDataType() byte

type BbiRawBlockDecoderIterator

type BbiRawBlockDecoderIterator struct {
	*BbiRawBlockDecoder
	// contains filtered or unexported fields
}

func (*BbiRawBlockDecoderIterator) Get

func (*BbiRawBlockDecoderIterator) Next

func (it *BbiRawBlockDecoderIterator) Next()

func (*BbiRawBlockDecoderIterator) Ok

type BbiRawBlockEncoder

type BbiRawBlockEncoder struct {
	ItemsPerSlot int
	// contains filtered or unexported fields
}

func NewBbiRawBlockEncoder

func NewBbiRawBlockEncoder(itemsPerSlot int, fixedStep bool, order binary.ByteOrder) (*BbiRawBlockEncoder, error)

func (*BbiRawBlockEncoder) Encode

func (encoder *BbiRawBlockEncoder) Encode(chromid int, sequence []float64, binSize int) BbiBlockEncoderIterator

type BbiRawBlockEncoderIterator

type BbiRawBlockEncoderIterator struct {
	*BbiRawBlockEncoder
	// contains filtered or unexported fields
}

func (*BbiRawBlockEncoderIterator) Get

func (*BbiRawBlockEncoderIterator) Next

func (it *BbiRawBlockEncoderIterator) Next()

func (*BbiRawBlockEncoderIterator) Ok

type BbiSummaryRecord

type BbiSummaryRecord struct {
	ChromId int
	From    int
	To      int
	BbiSummaryStatistics
}

func NewBbiSummaryRecord

func NewBbiSummaryRecord() BbiSummaryRecord

func (*BbiSummaryRecord) AddRecord

func (record *BbiSummaryRecord) AddRecord(x BbiSummaryRecord)

func (*BbiSummaryRecord) Reset

func (record *BbiSummaryRecord) Reset()

type BbiSummaryStatistics

type BbiSummaryStatistics struct {
	Valid      float64
	Min        float64
	Max        float64
	Sum        float64
	SumSquares float64
}

func (*BbiSummaryStatistics) Add

func (*BbiSummaryStatistics) AddValue

func (obj *BbiSummaryStatistics) AddValue(x float64)

func (*BbiSummaryStatistics) Reset

func (obj *BbiSummaryStatistics) Reset()

type BbiZoomBlockDecoder

type BbiZoomBlockDecoder struct {
	Buffer []byte
	// contains filtered or unexported fields
}

func NewBbiZoomBlockDecoder

func NewBbiZoomBlockDecoder(buffer []byte, order binary.ByteOrder) *BbiZoomBlockDecoder

func (*BbiZoomBlockDecoder) Decode

type BbiZoomBlockDecoderIterator

type BbiZoomBlockDecoderIterator struct {
	*BbiZoomBlockDecoder
	// contains filtered or unexported fields
}

func (*BbiZoomBlockDecoderIterator) Get

func (*BbiZoomBlockDecoderIterator) Next

func (it *BbiZoomBlockDecoderIterator) Next()

func (*BbiZoomBlockDecoderIterator) Ok

type BbiZoomBlockEncoder

type BbiZoomBlockEncoder struct {
	ItemsPerSlot int
	// contains filtered or unexported fields
}

func NewBbiZoomBlockEncoder

func NewBbiZoomBlockEncoder(itemsPerSlot, reductionLevel int, order binary.ByteOrder) (*BbiZoomBlockEncoder, error)

func (*BbiZoomBlockEncoder) Encode

func (encoder *BbiZoomBlockEncoder) Encode(chromid int, sequence []float64, binSize int) BbiBlockEncoderIterator

type BbiZoomBlockEncoderIterator

type BbiZoomBlockEncoderIterator struct {
	*BbiZoomBlockEncoder
	// contains filtered or unexported fields
}

func (*BbiZoomBlockEncoderIterator) Get

func (*BbiZoomBlockEncoderIterator) Next

func (it *BbiZoomBlockEncoderIterator) Next()

func (*BbiZoomBlockEncoderIterator) Ok

type BbiZoomBlockEncoderType

type BbiZoomBlockEncoderType struct {
	From  int
	To    int
	Block []byte
}

type BbiZoomRecord

type BbiZoomRecord struct {
	ChromId    uint32
	Start      uint32
	End        uint32
	Valid      uint32
	Min        float32
	Max        float32
	Sum        float32
	SumSquares float32
}

func (*BbiZoomRecord) AddValue

func (record *BbiZoomRecord) AddValue(x float64)

func (*BbiZoomRecord) Read

func (record *BbiZoomRecord) Read(reader io.Reader, order binary.ByteOrder) error

func (BbiZoomRecord) Write

func (record BbiZoomRecord) Write(writer io.Writer, order binary.ByteOrder) error

type BgzfExtra

type BgzfExtra struct {
	SI1   uint8
	SI2   uint8
	SLen  uint16
	BSize uint16
}

type BgzfReader

type BgzfReader struct {
	gzip.Reader
}

func NewBgzfReader

func NewBgzfReader(r io.Reader) (*BgzfReader, error)

func (*BgzfReader) GetExtra

func (reader *BgzfReader) GetExtra() (*BgzfExtra, error)

type BigWigFile

type BigWigFile struct {
	io.ReadSeeker
	// contains filtered or unexported fields
}

func OpenBigWigFile

func OpenBigWigFile(filename string) (*BigWigFile, error)

func (*BigWigFile) Close

func (reader *BigWigFile) Close() error

type BigWigParameters

type BigWigParameters struct {
	BlockSize       int
	ItemsPerSlot    int
	ReductionLevels []int
}

func DefaultBigWigParameters

func DefaultBigWigParameters() BigWigParameters

type BigWigReader

type BigWigReader struct {
	Reader io.ReadSeeker
	Bwf    BbiFile
	Genome Genome
}

func NewBigWigReader

func NewBigWigReader(reader io.ReadSeeker) (*BigWigReader, error)

func (*BigWigReader) GetBinSize

func (reader *BigWigReader) GetBinSize() (int, error)

func (*BigWigReader) Query

func (reader *BigWigReader) Query(seqRegex string, from, to, binSize int) <-chan BbiQueryType

func (*BigWigReader) QuerySequence

func (reader *BigWigReader) QuerySequence(seqregex string, f BinSummaryStatistics, binSize, binOverlap int, init float64) ([]float64, int, error)

func (*BigWigReader) QuerySlice

func (reader *BigWigReader) QuerySlice(seqregex string, from, to int, f BinSummaryStatistics, binSize, binOverlap int, init float64) ([]float64, int, error)

func (*BigWigReader) ReadBlocks

func (reader *BigWigReader) ReadBlocks() <-chan BigWigReaderType

type BigWigReaderType

type BigWigReaderType struct {
	Block []byte
	Error error
}

type BigWigWriter

type BigWigWriter struct {
	Writer     io.WriteSeeker
	Bwf        BbiFile
	Genome     Genome
	Parameters BigWigParameters

	Leaves map[int][]*RVertex
	// contains filtered or unexported fields
}

func NewBigWigWriter

func NewBigWigWriter(writer io.WriteSeeker, genome Genome, parameters BigWigParameters) (*BigWigWriter, error)

func (*BigWigWriter) Close

func (bww *BigWigWriter) Close() error

func (*BigWigWriter) StartZoomData

func (bww *BigWigWriter) StartZoomData(i int) error

func (*BigWigWriter) Write

func (bww *BigWigWriter) Write(seqname string, sequence []float64, binSize int) error

func (*BigWigWriter) WriteIndex

func (bww *BigWigWriter) WriteIndex() error

func (*BigWigWriter) WriteIndexZoom

func (bww *BigWigWriter) WriteIndexZoom(i int) error

func (*BigWigWriter) WriteZoom

func (bww *BigWigWriter) WriteZoom(seqname string, sequence []float64, binSize, reductionLevel, i int) error

type BigWigWriterType

type BigWigWriterType struct {
	Seqname  string
	Sequence []float64
}

type BinSummaryStatistics

type BinSummaryStatistics func(sum, sumSquares, min, max, n float64) float64

func BinSummaryStatisticsFromString

func BinSummaryStatisticsFromString(str string) BinSummaryStatistics

type CigarBlock

type CigarBlock struct {
	N    int
	Type byte
}

type ComplementableAlphabet

type ComplementableAlphabet interface {
	Bases(i byte) ([]byte, error)
	Matching(i byte) ([]byte, error)
	Code(i byte) (byte, error)
	Decode(i byte) (byte, error)
	Complement(i byte) (byte, error)
	ComplementCoded(i byte) (byte, error)
	IsAmbiguous(i byte) (bool, error)
	IsWildcard(i byte) (bool, error)
	Length() int
	LengthUnambiguous() int
	String() string
}

type GPeaks

type GPeaks struct {
	GRanges
}

func ImportXlsPeaks

func ImportXlsPeaks(filename string) (GPeaks, error)

func NewGPeaks

func NewGPeaks(seqnames []string, from, to, absSummit []int, pileup, pvalue, foldEnrichment, qvalue []float64) GPeaks

func ReadXlsPeaks

func ReadXlsPeaks(r io.Reader) (GPeaks, error)

func (GPeaks) AbsSummit

func (p GPeaks) AbsSummit() []int

func (GPeaks) FoldEnrichment

func (p GPeaks) FoldEnrichment() []float64

func (GPeaks) Pileup

func (p GPeaks) Pileup() []float64

func (GPeaks) Pvalue

func (p GPeaks) Pvalue() []float64

func (GPeaks) Qvalue

func (p GPeaks) Qvalue() []float64

type GRange

type GRange struct {
	Seqname string
	Range   Range
	Strand  byte
}

type GRanges

type GRanges struct {
	Seqnames []string
	Ranges   []Range
	Strand   []byte
	Meta
}

func ImportCpGIslandsFromTable

func ImportCpGIslandsFromTable(filename string) (GRanges, error)

func ImportCpGIslandsFromUCSC

func ImportCpGIslandsFromUCSC(genome string) GRanges

func NewEmptyGRanges

func NewEmptyGRanges(n int) GRanges

func NewGRanges

func NewGRanges(seqnames []string, from, to []int, strand []byte) GRanges

func Promoters

func Promoters(genes Genes, offset1, offset2 int) (GRanges, error)

Generate a GRanges object where each range is a window around the transcription start site (TSS) of a gene. The arguments offset1, and offset2 determine the size of the window starting from the TSS in 5' and 3' direction respectively. Genomic bounds are not checked. (This is required by the GRanges ImportTrack() method!)

func RandomGRanges

func RandomGRanges(n, wsize int, genome Genome, useStrand bool) GRanges

Generate a GRanges object where each genomic range is generated at random. Each chromosome is weighted by its length.

func ReadCpGIslandsFromTable

func ReadCpGIslandsFromTable(r io.ReadSeeker) (GRanges, error)

func (GRanges) Append

func (r1 GRanges) Append(r2 GRanges) GRanges

func (GRanges) AsReadChannel

func (obj GRanges) AsReadChannel() ReadChannel

Convert GRanges object to ReadChannel

func (*GRanges) Clone

func (r *GRanges) Clone() GRanges

func (GRanges) ExportBed3

func (granges GRanges) ExportBed3(filename string, compress bool) error

func (GRanges) ExportBed6

func (granges GRanges) ExportBed6(filename string, compress bool) error

func (GRanges) ExportBed9

func (granges GRanges) ExportBed9(filename string, compress bool) error

func (GRanges) ExportBedGraph

func (granges GRanges) ExportBedGraph(filename string, compress bool) error

func (GRanges) ExportGTF

func (granges GRanges) ExportGTF(filename string) error

func (GRanges) ExportTable

func (granges GRanges) ExportTable(filename string, header, strand, compress bool, args ...interface{}) error

func (GRanges) FilterGenome

func (r GRanges) FilterGenome(genome Genome) GRanges

Remove all entries that are not in the given genome.

func (GRanges) FilterStrand

func (r GRanges) FilterStrand(s byte) GRanges

func (GRanges) Genes

func (granges GRanges) Genes() Genes

func (*GRanges) ImportBamPairedEnd

func (granges *GRanges) ImportBamPairedEnd(filename string, args ...interface{}) error

func (*GRanges) ImportBamSingleEnd

func (granges *GRanges) ImportBamSingleEnd(filename string, args ...interface{}) error

func (*GRanges) ImportBed

func (g *GRanges) ImportBed(filename string, columns int) error

func (*GRanges) ImportBed3

func (g *GRanges) ImportBed3(filename string) error

func (*GRanges) ImportBed6

func (g *GRanges) ImportBed6(filename string) error

func (*GRanges) ImportBed9

func (g *GRanges) ImportBed9(filename string) error

func (*GRanges) ImportBedGraph

func (g *GRanges) ImportBedGraph(filename string) error

func (*GRanges) ImportBigWig

func (r *GRanges) ImportBigWig(filename string, name string, s BinSummaryStatistics, binSize, binOverlap int, init float64, revNegStrand bool) error

func (*GRanges) ImportGTF

func (granges *GRanges) ImportGTF(filename string, optNames, optTypes []string, optDef []interface{}) error

func (*GRanges) ImportTable

func (granges *GRanges) ImportTable(filename string, names, types []string) error

func (*GRanges) ImportTableAll

func (granges *GRanges) ImportTableAll(filename string) error

func (*GRanges) ImportTrack

func (r *GRanges) ImportTrack(track Track, revNegStrand bool) error

Add data from a track to the GRanges object. The data will be contained in a meta-data column with the same name as the track. It is required that each range has the same length.

func (GRanges) Intersection

func (r GRanges) Intersection(s GRanges) GRanges

func (GRanges) KeepOverlapsWith

func (r GRanges) KeepOverlapsWith(subject GRanges) GRanges

func (GRanges) Length

func (r GRanges) Length() int

func (GRanges) Merge

func (obj GRanges) Merge(granges ...GRanges) GRanges

func (GRanges) ObservedOverExpectedCpG

func (regions GRanges) ObservedOverExpectedCpG(genomicSequence StringSet) ([]float64, error)

func (GRanges) PrintPretty

func (granges GRanges) PrintPretty(n int, args ...interface{}) string

func (GRanges) PrintTable

func (granges GRanges) PrintTable(header, strand bool, args ...interface{}) string

func (GRanges) RandomPermutation

func (r GRanges) RandomPermutation() GRanges

func (*GRanges) ReadBamPairedEnd

func (granges *GRanges) ReadBamPairedEnd(r io.Reader, args ...interface{}) error

func (*GRanges) ReadBamSingleEnd

func (granges *GRanges) ReadBamSingleEnd(r io.Reader, args ...interface{}) error

func (*GRanges) ReadBed

func (g *GRanges) ReadBed(reader io.Reader, columns int) error

func (*GRanges) ReadBed3

func (g *GRanges) ReadBed3(r io.Reader) error

Import GRanges from a Bed file with 3 columns.

func (*GRanges) ReadBed6

func (g *GRanges) ReadBed6(r io.Reader) error

Import GRanges from a Bed file with 6 columns.

func (*GRanges) ReadBed9

func (g *GRanges) ReadBed9(r io.Reader) error

func (*GRanges) ReadBedGraph

func (g *GRanges) ReadBedGraph(r io.Reader) error

func (*GRanges) ReadBigWig

func (r *GRanges) ReadBigWig(bwr *BigWigReader, name string, f BinSummaryStatistics, binSize, binOverlap int, init float64, revNegStrand bool) error

func (*GRanges) ReadGTF

func (granges *GRanges) ReadGTF(r io.Reader, optNames, optTypes []string, defaults []interface{}) error

Parse expression data from a GTF file (gene transfer format). The data is added as a meta column named "expr" to the gene list. Parameters:

geneIdName: Name of the optional field containing the gene id
exprIdName: Name of the optional field containing the expression data
genes: List of query genes

func (*GRanges) ReadTable

func (granges *GRanges) ReadTable(s io.ReadSeeker, names, types []string) error

func (*GRanges) ReadTableAll

func (granges *GRanges) ReadTableAll(s io.ReadSeeker) error

func (GRanges) Remove

func (r GRanges) Remove(indices []int) GRanges

func (GRanges) RemoveOverlapsWith

func (r GRanges) RemoveOverlapsWith(subject GRanges) GRanges

func (GRanges) Row

func (r GRanges) Row(i int) GRangesRow

func (GRanges) SetLengths

func (r GRanges) SetLengths(n int) GRanges

Set length of each range to the given value. Ranges with no strand information are not changed.

func (GRanges) Slice

func (r GRanges) Slice(ifrom, ito int) GRanges

func (GRanges) Sort

func (r GRanges) Sort(name string, reverse bool) (GRanges, error)

func (GRanges) String

func (granges GRanges) String() string

func (GRanges) Subset

func (r GRanges) Subset(indices []int) GRanges

func (GRanges) WriteBed3

func (granges GRanges) WriteBed3(w io.Writer) error

Export GRanges object as bed file with three columns.

func (GRanges) WriteBed6

func (granges GRanges) WriteBed6(w io.Writer) error

func (GRanges) WriteBed9

func (granges GRanges) WriteBed9(w io.Writer) error

func (GRanges) WriteBedGraph

func (granges GRanges) WriteBedGraph(w io.Writer) error

func (GRanges) WriteGTF

func (granges GRanges) WriteGTF(w_ io.Writer) error

Export GRanges as GTF file. Required GTF fields should be provided as meta columns named sources, features, scores, and frames. All other meta columns are exported as optional fields.

func (GRanges) WritePretty

func (granges GRanges) WritePretty(writer io.Writer, n int, args ...interface{}) error

func (GRanges) WriteTable

func (granges GRanges) WriteTable(writer io.Writer, header, strand bool, args ...interface{}) error

Export GRanges as a table. The first line contains the header of the table.

type GRangesRow

type GRangesRow struct {
	GRange
	MetaRow
}

func NewGRangesRow

func NewGRangesRow(granges GRanges, i int) GRangesRow

func (GRangesRow) String

func (r GRangesRow) String() string

type GappedNucleotideAlphabet

type GappedNucleotideAlphabet struct {
}

func (GappedNucleotideAlphabet) Bases

func (GappedNucleotideAlphabet) Bases(i byte) ([]byte, error)

func (GappedNucleotideAlphabet) Code

func (GappedNucleotideAlphabet) Complement

func (GappedNucleotideAlphabet) Complement(i byte) (byte, error)

func (GappedNucleotideAlphabet) ComplementCoded

func (GappedNucleotideAlphabet) ComplementCoded(i byte) (byte, error)

func (GappedNucleotideAlphabet) Decode

func (GappedNucleotideAlphabet) Decode(i byte) (byte, error)

func (GappedNucleotideAlphabet) IsAmbiguous

func (GappedNucleotideAlphabet) IsAmbiguous(i byte) (bool, error)

func (GappedNucleotideAlphabet) IsWildcard

func (GappedNucleotideAlphabet) IsWildcard(i byte) (bool, error)

func (GappedNucleotideAlphabet) Length

func (GappedNucleotideAlphabet) Length() int

func (GappedNucleotideAlphabet) LengthUnambiguous

func (GappedNucleotideAlphabet) LengthUnambiguous() int

func (GappedNucleotideAlphabet) Matching

func (GappedNucleotideAlphabet) Matching(i byte) ([]byte, error)

func (GappedNucleotideAlphabet) String

type GenericMutableTrack

type GenericMutableTrack struct {
	MutableTrack
}

func (GenericMutableTrack) AddRead

func (track GenericMutableTrack) AddRead(read Read, d int) error

Add a single read to the track by incrementing the value of each bin that overlaps with the read. Single end reads are extended in 3' direction to have a length of [d]. This is the same as the macs2 `extsize' parameter. Reads are not extended if [d] is zero. The function returns an error if the read's position is out of range

func (GenericMutableTrack) AddReadMeanOverlap

func (track GenericMutableTrack) AddReadMeanOverlap(read Read, d int) error

Add a single read to the track by adding the fraction of overlap between the read and each bin. Single end reads are extended in 3' direction to have a length of [d]. This is the same as the macs2 `extsize' parameter. Reads are not extended if [d] is zero. The function returns an error if the read's position is out of range

func (GenericMutableTrack) AddReadOverlap

func (track GenericMutableTrack) AddReadOverlap(read Read, d int) error

Add a single read to the track by adding the number of overlapping nucleotides between the read and each bin. Single end reads are extended in 3' direction to have a length of [d]. This is the same as the macs2 `extsize' parameter. Reads are not extended if [d] is zero. The function returns an error if the read's position is out of range

func (GenericMutableTrack) AddReads

func (track GenericMutableTrack) AddReads(reads ReadChannel, d int, method string) int

Add reads to track. All single end reads are extended in 3' direction to have a length of [d]. This is the same as the macs2 `extsize' parameter. Reads are not extended if [d] is zero. If [method] is "default", the value of each bin that overlaps the read is incremented. If [method] is "overlap", each bin that overlaps the read is incremented by the number of overlapping nucleotides. If [method] is "mean overlap", each bin that overlaps the read is incremented by the fraction of overlapping nucleotides within the bin. The function returns an error if the read's position is out of range

func (GenericMutableTrack) ImportSegmentation

func (track GenericMutableTrack) ImportSegmentation(bedFilename string, defState string) ([]string, error)

func (GenericMutableTrack) Map

func (track1 GenericMutableTrack) Map(track2 Track, f func(string, int, float64) float64) error

Apply a function f to the sequences of track2. The function is given as arguments the name of the sequence, the position, and the value at that position. The return value is stored in track1 if it is not nil.

func (GenericMutableTrack) MapList

func (track GenericMutableTrack) MapList(tracks []Track, f func(string, int, ...float64) float64) error

func (GenericMutableTrack) Normalize

func (track GenericMutableTrack) Normalize(treatment, control Track, c1, c2 float64, logScale bool) error

Combine treatment and control from a ChIP-seq experiment into a single track. At each genomic location, the number of binned reads from the treatment experiment is divided by the number of control reads. To avoid division by zero, a pseudocount is added to both treatment and control. The parameter d determines the extension of reads.

func (GenericMutableTrack) QuantileNormalize

func (track GenericMutableTrack) QuantileNormalize(trackRef Track) error

Quantile normalize track to reference

func (GenericMutableTrack) QuantileNormalizeToCounts

func (track GenericMutableTrack) QuantileNormalizeToCounts(x []float64, y []int) error

func (GenericMutableTrack) Smoothen

func (track GenericMutableTrack) Smoothen(minCounts float64, windowSizes []int) error

Smoothen track data with an adaptive window method. For each region the smallest window size among windowSizes is selected which contains at least minCounts counts. If the minimum number of counts is not reached, the larges window size is selected.

func (GenericMutableTrack) WindowMap

func (track1 GenericMutableTrack) WindowMap(track2 Track, windowSize int, f func(string, int, ...float64) float64) error

Apply a window function f to the sequences of track2. The function is given as arguments the name of the sequence, the position, and the value at that position. The return value is stored in track1 if it is not nil.

func (GenericMutableTrack) WindowMapList

func (track GenericMutableTrack) WindowMapList(tracks []Track, windowSize int, f func(string, int, ...[]float64) float64) error

type GenericTrack

type GenericTrack struct {
	Track
}

func (GenericTrack) CumulativeHistogram

func (track GenericTrack) CumulativeHistogram(from, to float64, bins int) TrackHistogram

func (GenericTrack) ExportBed

func (track GenericTrack) ExportBed(filename string, compress bool) error

func (GenericTrack) ExportBigWig

func (track GenericTrack) ExportBigWig(filename string, args ...interface{}) error

func (GenericTrack) ExportSegmentation

func (track GenericTrack) ExportSegmentation(bedFilename, bedName, bedDescription string, compress bool, stateNames []string, rgbMap map[string]string, scores []Track) error

func (GenericTrack) GRanges

func (track GenericTrack) GRanges(name string) (GRanges, error)

func (GenericTrack) Histogram

func (track GenericTrack) Histogram(from, to float64, bins int) TrackHistogram

func (GenericTrack) Reduce

func (track GenericTrack) Reduce(f func(string, int, float64, float64) float64, x0 float64) map[string]float64

func (GenericTrack) SummaryStatistics

func (track GenericTrack) SummaryStatistics() TrackSummaryStatistics

func (GenericTrack) WriteBed

func (track GenericTrack) WriteBed(w io.Writer) error

func (GenericTrack) WriteBigWig

func (track GenericTrack) WriteBigWig(writer io.WriteSeeker, args ...interface{}) error

type Genes

type Genes struct {
	GRanges
	// pointer to some meta columns
	Names []string
	Cds   []Range
	// contains filtered or unexported fields
}

Container for genes. Tx contains the transcription start and end positions. Cds specifies the coding regions.

func ImportGenesFromUCSC

func ImportGenesFromUCSC(genome, table string) (Genes, error)

func NewGenes

func NewGenes(names, seqnames []string, txFrom, txTo, cdsFrom, cdsTo []int, strand []byte) Genes

func ReadUCSCGenes

func ReadUCSCGenes(filename string) (Genes, error)

Import genes from UCSC text files. The format is a whitespace separated table with columns: Name, Seqname, TranscriptStart, TranscriptEnd, CodingStart, CodingEnd, and Strand.

func (*Genes) Clone

func (g *Genes) Clone() Genes

func (Genes) ExportTable

func (genes Genes) ExportTable(filename string, header, strand, compress bool, args ...interface{}) error

func (Genes) FilterGenome

func (obj Genes) FilterGenome(genome Genome) Genes

func (Genes) FindGene

func (g Genes) FindGene(name string) (int, bool)

Returns the index of a gene.

func (*Genes) ImportCufflinksFPKMTracking

func (genes *Genes) ImportCufflinksFPKMTracking(filename string, verbose bool) error

func (*Genes) ImportGTFExpr

func (genes *Genes) ImportGTFExpr(filename string, geneIdName, exprIdName string) error

func (Genes) Intersection

func (obj Genes) Intersection(subject Genes) Genes

func (Genes) KeepOverlapsWith

func (obj Genes) KeepOverlapsWith(subject Genes) Genes

func (Genes) PrintPretty

func (genes Genes) PrintPretty(n int) string

func (Genes) PrintTable

func (genes Genes) PrintTable(header, strand bool, args ...interface{}) string

func (*Genes) ReadCufflinksFPKMTracking

func (genes *Genes) ReadCufflinksFPKMTracking(r io.Reader, verbose bool) error

Import expression data from cufflinks. The data is added to the gene list as a meta column named "expr".

func (*Genes) ReadGTFExpr

func (genes *Genes) ReadGTFExpr(r io.Reader, geneIdName, exprIdName string) error

Parse expression data from a GTF file (gene transfer format). The data is added as a meta column named "expr" to the gene list. Parameters:

geneIdName: Name of the optional field containing the gene id
exprIdName: Name of the optional field containing the expression data
genes: List of query genes

func (Genes) Remove

func (obj Genes) Remove(indices []int) Genes

func (Genes) RemoveOverlapsWith

func (obj Genes) RemoveOverlapsWith(subject Genes) Genes

func (Genes) Slice

func (obj Genes) Slice(ifrom, ito int) Genes

func (Genes) Sort

func (obj Genes) Sort(name string, reverse bool) (Genes, error)

func (Genes) String

func (genes Genes) String() string

func (Genes) Subset

func (obj Genes) Subset(indices []int) Genes

func (Genes) WritePretty

func (genes Genes) WritePretty(writer io.Writer, n int) error

func (Genes) WriteTable

func (genes Genes) WriteTable(writer io.Writer, header bool, args ...interface{}) error

type Genome

type Genome struct {
	Seqnames []string
	Lengths  []int
}

Structure containing chromosome sizes.

func BamImportGenome

func BamImportGenome(filename string) (Genome, error)

func BamReadGenome

func BamReadGenome(reader io.Reader) (Genome, error)

func BigWigImportGenome

func BigWigImportGenome(filename string) (Genome, error)

func BigWigReadGenome

func BigWigReadGenome(reader io.ReadSeeker) (Genome, error)

func NewGenome

func NewGenome(seqnames []string, lengths []int) Genome

func (*Genome) AddSequence

func (genome *Genome) AddSequence(seqname string, length int) (int, error)

func (Genome) Clone

func (genome Genome) Clone() Genome

func (Genome) Equals

func (genome Genome) Equals(g Genome) bool

func (Genome) Filter

func (genome Genome) Filter(f func(name string, length int) bool) Genome

func (Genome) GetIdx

func (genome Genome) GetIdx(seqname string) (int, error)

func (*Genome) Import

func (genome *Genome) Import(filename string) error

func (Genome) Length

func (genome Genome) Length() int

Number of chromosomes in the structure.

func (*Genome) Read

func (genome *Genome) Read(r io.Reader) error

Import chromosome sizes from a UCSC text file. The format is a whitespace separated table where the first column is the name of the chromosome and the second column the chromosome length.

func (Genome) SeqLength

func (genome Genome) SeqLength(seqname string) (int, error)

Length of the given chromosome. Returns an error if the chromosome is not found.

func (Genome) String

func (genome Genome) String() string

func (Genome) SumLengths

func (genome Genome) SumLengths() int

type GenomeRng

type GenomeRng struct {
	Weights []float64
	Genome  Genome
	MaxLen  int
}

func NewGenomeRng

func NewGenomeRng(genome Genome) GenomeRng

func (GenomeRng) Draw

func (rng GenomeRng) Draw(wsize int) (int, int)

type Kmer

type Kmer string

func (Kmer) Matches

func (obj Kmer) Matches(b Kmer, alphabet ComplementableAlphabet) bool

type KmerCatalogue

type KmerCatalogue struct {
	KmerEquivalenceRelation
	// contains filtered or unexported fields
}

func NewKmerCatalogue

func NewKmerCatalogue(n, m int, comp, rev, rc bool, maxAmbiguous []int, al ComplementableAlphabet) (*KmerCatalogue, error)

func (*KmerCatalogue) AddKmerClass

func (obj *KmerCatalogue) AddKmerClass(kmer KmerClass)

func (*KmerCatalogue) CatalogueSize

func (obj *KmerCatalogue) CatalogueSize() int

func (*KmerCatalogue) Clone

func (obj *KmerCatalogue) Clone() *KmerCatalogue

func (*KmerCatalogue) GetKmerClass

func (obj *KmerCatalogue) GetKmerClass(kmer string) KmerClass

func (*KmerCatalogue) GetKmerClassFromId

func (obj *KmerCatalogue) GetKmerClassFromId(k, id int) KmerClass

func (*KmerCatalogue) GetKmerClassIfPresent

func (obj *KmerCatalogue) GetKmerClassIfPresent(kmer string) (KmerClass, bool)

type KmerCatalogueIterator

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

func NewKmerCatalogueIterator

func NewKmerCatalogueIterator(catalogue KmerCatalogue) KmerCatalogueIterator

func (KmerCatalogueIterator) Get

func (obj KmerCatalogueIterator) Get() KmerClass

func (*KmerCatalogueIterator) Next

func (obj *KmerCatalogueIterator) Next()

func (KmerCatalogueIterator) Ok

func (obj KmerCatalogueIterator) Ok() bool

type KmerClass

type KmerClass struct {
	KmerClassId
	// list of equivalent K-mers
	Elements []string
}

func NewKmerClass

func NewKmerClass(k, i int, elements []string) KmerClass

func (KmerClass) CountAmbiguous

func (obj KmerClass) CountAmbiguous(alphabet ComplementableAlphabet) int

func (KmerClass) CountWildcard

func (obj KmerClass) CountWildcard(alphabet ComplementableAlphabet) int

func (KmerClass) Equals

func (obj KmerClass) Equals(b KmerClass) bool

func (KmerClass) Less

func (obj KmerClass) Less(b KmerClass) bool

func (KmerClass) Matches

func (obj KmerClass) Matches(b KmerClass, alphabet ComplementableAlphabet) bool

func (KmerClass) String

func (obj KmerClass) String() string

type KmerClassId

type KmerClassId struct {
	K int
	I int
}

func (KmerClassId) Equals

func (a KmerClassId) Equals(b KmerClassId) bool

func (KmerClassId) Less

func (a KmerClassId) Less(b KmerClassId) bool

type KmerClassList

type KmerClassList []KmerClass

func (KmerClassList) Clone

func (obj KmerClassList) Clone() KmerClassList

func (KmerClassList) Equals

func (obj KmerClassList) Equals(b KmerClassList) bool

func (KmerClassList) Len

func (obj KmerClassList) Len() int

func (KmerClassList) Less

func (obj KmerClassList) Less(i, j int) bool

func (KmerClassList) Sort

func (obj KmerClassList) Sort()

func (KmerClassList) Swap

func (obj KmerClassList) Swap(i, j int)

func (KmerClassList) Union

func (obj KmerClassList) Union(b ...KmerClassList) KmerClassList

type KmerClassSet

type KmerClassSet map[KmerClassId][]string

func (KmerClassSet) AsList

func (obj KmerClassSet) AsList() KmerClassList

type KmerCounter

type KmerCounter struct {
	KmerCatalogue
	// contains filtered or unexported fields
}

func NewKmerCounter

func NewKmerCounter(n, m int, comp, rev, rc bool, maxAmbiguous []int, al ComplementableAlphabet, kmers ...KmerClass) (*KmerCounter, error)

func (*KmerCounter) Clone

func (obj *KmerCounter) Clone() *KmerCounter

func (*KmerCounter) CountKmers

func (obj *KmerCounter) CountKmers(sequence []byte) KmerCounts

func (*KmerCounter) Freeze

func (obj *KmerCounter) Freeze()

func (*KmerCounter) IdentifyKmers

func (obj *KmerCounter) IdentifyKmers(sequence []byte) KmerCounts

type KmerCounts

type KmerCounts struct {
	// this is a sorted list of k-mers and might contain more entries than
	// the counts map
	Kmers  KmerClassList
	Counts map[KmerClassId]int
}

func (KmerCounts) At

func (obj KmerCounts) At(i int) int

func (KmerCounts) GetCount

func (obj KmerCounts) GetCount(kmer KmerClass) int

func (KmerCounts) GetKmer

func (obj KmerCounts) GetKmer(i int) KmerClass

func (KmerCounts) Iterate

func (obj KmerCounts) Iterate() KmerCountsIterator

func (KmerCounts) Len

func (obj KmerCounts) Len() int

func (KmerCounts) N

func (obj KmerCounts) N() int

func (*KmerCounts) SetKmers

func (obj *KmerCounts) SetKmers(kmers KmerClassList)

type KmerCountsIterator

type KmerCountsIterator struct {
	KmerCounts
	// contains filtered or unexported fields
}

func (KmerCountsIterator) GetCount

func (obj KmerCountsIterator) GetCount() int

func (KmerCountsIterator) GetIndex

func (obj KmerCountsIterator) GetIndex() int

func (KmerCountsIterator) GetKmer

func (obj KmerCountsIterator) GetKmer() KmerClass

func (*KmerCountsIterator) Next

func (obj *KmerCountsIterator) Next()

func (KmerCountsIterator) Ok

func (obj KmerCountsIterator) Ok() bool

type KmerCountsList

type KmerCountsList struct {
	Kmers  KmerClassList
	Counts []map[KmerClassId]int
}

func NewKmerCountsList

func NewKmerCountsList(counts ...KmerCounts) KmerCountsList

func (KmerCountsList) Append

func (obj KmerCountsList) Append(args ...KmerCounts) KmerCountsList

func (KmerCountsList) At

func (obj KmerCountsList) At(i int) KmerCounts

func (KmerCountsList) Len

func (obj KmerCountsList) Len() int

func (*KmerCountsList) SetKmers

func (obj *KmerCountsList) SetKmers(kmers KmerClassList)

func (*KmerCountsList) Slice

func (obj *KmerCountsList) Slice(i, j int) KmerCountsList

type KmerCylinderIterator

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

func NewKmerCylinderIterator

func NewKmerCylinderIterator(k int, maxAmbiguous int, alphabet ComplementableAlphabet, j int, a_ string) KmerCylinderIterator

func (KmerCylinderIterator) Get

func (obj KmerCylinderIterator) Get() string

func (*KmerCylinderIterator) Next

func (obj *KmerCylinderIterator) Next()

func (KmerCylinderIterator) Ok

func (obj KmerCylinderIterator) Ok() bool

type KmerEquivalence

type KmerEquivalence struct {
	N, M         int // min and max kmer size
	Complement   bool
	Reverse      bool
	Revcomp      bool
	MaxAmbiguous []int // maximum number of ambiguous letters
	Alphabet     ComplementableAlphabet
}

func NewKmerEquivalence

func NewKmerEquivalence(n, m int, comp, rev, rc bool, maxAmbiguous []int, al ComplementableAlphabet) (KmerEquivalence, error)

func (KmerEquivalence) Equals

func (a KmerEquivalence) Equals(b KmerEquivalence) bool

type KmerEquivalenceRelation

type KmerEquivalenceRelation struct {
	KmerEquivalence
	// contains filtered or unexported fields
}

func NewKmerEquivalenceRelation

func NewKmerEquivalenceRelation(n, m int, comp, rev, rc bool, maxAmbiguous []int, al ComplementableAlphabet) (KmerEquivalenceRelation, error)

func (KmerEquivalenceRelation) EquivalenceClass

func (obj KmerEquivalenceRelation) EquivalenceClass(kmer string) KmerClass

type KmerGraph

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

func NewKmerGraph

func NewKmerGraph(kmers KmerClassList, rel KmerEquivalenceRelation) KmerGraph

func NewKmerGraphFromCatalogue

func NewKmerGraphFromCatalogue(catalogue *KmerCatalogue) KmerGraph

func (KmerGraph) GetNode

func (obj KmerGraph) GetNode(kmer string) *KmerGraphNode

func (KmerGraph) RelatedKmers

func (obj KmerGraph) RelatedKmers(kmer string) KmerClassList

type KmerGraphNode

type KmerGraphNode struct {
	Kmer      KmerClass
	ClusterId uint64
	Rank      int
	// less specific k-mers
	Infra []*KmerGraphNode
	// more specific k-mers
	Supra []*KmerGraphNode
	// k-mers of same length with wildcards at equivalent positions
	Intra []*KmerGraphNode
}

type KmerInstantiationIterator

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

func NewKmerInstantiationIterator

func NewKmerInstantiationIterator(alphabet ComplementableAlphabet, a_ string, partial bool) KmerInstantiationIterator

func (KmerInstantiationIterator) Get

func (*KmerInstantiationIterator) Next

func (obj *KmerInstantiationIterator) Next()

func (KmerInstantiationIterator) Ok

type KmerIterator

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

func NewKmerIterator

func NewKmerIterator(k int, maxAmbiguous int, alphabet ComplementableAlphabet) KmerIterator

func (KmerIterator) Get

func (obj KmerIterator) Get() string

func (*KmerIterator) Next

func (obj *KmerIterator) Next()

func (KmerIterator) Ok

func (obj KmerIterator) Ok() bool

type LazyTrack

type LazyTrack struct {
	Name       string
	BinSize    int
	BinOverlap int
	Bwr        BigWigReader
	BinSumStat BinSummaryStatistics
	Init       float64
}

func NewLazyTrack

func NewLazyTrack(reader io.ReadSeeker, name string, f BinSummaryStatistics, binSize, binOverlap int, init float64) (LazyTrack, error)

func (LazyTrack) Clone

func (track LazyTrack) Clone() LazyTrack

func (LazyTrack) CloneTrack

func (track LazyTrack) CloneTrack() Track

func (*LazyTrack) FilterGenome

func (track *LazyTrack) FilterGenome(f func(name string, length int) bool)

func (LazyTrack) GetBinSize

func (track LazyTrack) GetBinSize() int

func (LazyTrack) GetGenome

func (track LazyTrack) GetGenome() Genome

func (LazyTrack) GetName

func (track LazyTrack) GetName() string

func (LazyTrack) GetSeqNames

func (track LazyTrack) GetSeqNames() []string

func (LazyTrack) GetSequence

func (track LazyTrack) GetSequence(query string) (TrackSequence, error)

func (LazyTrack) GetSlice

func (track LazyTrack) GetSlice(r GRangesRow) ([]float64, error)

func (*LazyTrack) ReadBigWig

func (track *LazyTrack) ReadBigWig(reader io.ReadSeeker, name string, f BinSummaryStatistics, binSize, binOverlap int, init float64) error

type LazyTrackFile

type LazyTrackFile struct {
	LazyTrack
	// contains filtered or unexported fields
}

func (*LazyTrackFile) Close

func (obj *LazyTrackFile) Close() error

func (*LazyTrackFile) ImportBigWig

func (obj *LazyTrackFile) ImportBigWig(filename, name string, s BinSummaryStatistics, binSize, binOverlap int, init float64) error

type Meta

type Meta struct {
	MetaName []string
	MetaData []interface{}
	// contains filtered or unexported fields
}

func NewMeta

func NewMeta(names []string, data []interface{}) Meta

func (*Meta) AddMeta

func (m *Meta) AddMeta(name string, meta interface{})

func (Meta) Append

func (meta1 Meta) Append(meta2 Meta) Meta

func (*Meta) Clone

func (m *Meta) Clone() Meta

Deep copy the Meta object.

func (*Meta) DeleteMeta

func (m *Meta) DeleteMeta(name string)

func (Meta) GetMeta

func (m Meta) GetMeta(name string) interface{}

func (Meta) GetMetaFloat

func (m Meta) GetMetaFloat(name string) []float64

func (Meta) GetMetaInt

func (m Meta) GetMetaInt(name string) []int

func (Meta) GetMetaRange

func (m Meta) GetMetaRange(name string) []Range

func (Meta) GetMetaStr

func (m Meta) GetMetaStr(name string) []string

func (Meta) Length

func (m Meta) Length() int

Returns the number of rows.

func (Meta) Merge

func (meta Meta) Merge(indices []int) Meta

Return a new Meta object where a given set of rows has been merged. The argument indices should assign the same target index to all rows that should be merged, i.e. indices := []int{0, 1, 1, 2, 3} would merge rows 1 and 2 but leave all rows 0, 3 and 4 as they are. Rows are merged by replacing one-dimensional slices by two-dimensional slices. The Reduce{String,Float64,Int} methods may be used afterwards to apply a function to the merged data. A Meta object that already contains two-dimensional slices cannot be merged.

func (Meta) MetaLength

func (m Meta) MetaLength() int

Returns the number of columns.

func (*Meta) PrintPretty

func (meta *Meta) PrintPretty(n int, args ...interface{}) string

func (*Meta) PrintTable

func (meta *Meta) PrintTable(header bool, args ...interface{}) string

func (*Meta) ReadTable

func (meta *Meta) ReadTable(r io.Reader, names, types []string) error

func (*Meta) ReduceFloat

func (meta *Meta) ReduceFloat(name, nameNew string, f func([]float64) float64)

Reduce a column with a two-dimensional float64 slice by applying the given function f. If nameNew != "" the old meta column is kept.

func (*Meta) ReduceInt

func (meta *Meta) ReduceInt(name, nameNew string, f func([]int) int)

Reduce a column with a two-dimensional int slice by applying the given function f. If nameNew != "" the old meta column is kept.

func (*Meta) ReduceString

func (meta *Meta) ReduceString(name, nameNew string, f func([]string) string)

Reduce a column with a two-dimensional string slice by applying the given function f. If nameNew != "" the old meta column is kept.

func (Meta) Remove

func (meta Meta) Remove(indices []int) Meta

func (*Meta) RenameMeta

func (m *Meta) RenameMeta(nameOld, nameNew string)

func (Meta) Row

func (m Meta) Row(i int) MetaRow

func (Meta) Slice

func (meta Meta) Slice(ifrom, ito int) Meta

Return a new Meta object containing rows given by the range [ifrom, ito).

func (*Meta) Sort

func (meta *Meta) Sort(name string, reverse bool) (Meta, error)

func (*Meta) String

func (meta *Meta) String() string

func (Meta) Subset

func (meta Meta) Subset(indices []int) Meta

Return a new Meta object with a subset of the rows from this object.

func (Meta) WritePretty

func (meta Meta) WritePretty(writer io.Writer, n int, args ...interface{}) error

func (Meta) WriteTable

func (meta Meta) WriteTable(writer io.Writer, header bool, args ...interface{}) error

type MetaRow

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

func NewMetaRow

func NewMetaRow(m Meta, i int) MetaRow

func (MetaRow) GetMeta

func (m MetaRow) GetMeta(name string) interface{}

func (MetaRow) GetMetaFloat

func (m MetaRow) GetMetaFloat(name string) (float64, error)

func (MetaRow) GetMetaInt

func (m MetaRow) GetMetaInt(name string) (int, error)

func (MetaRow) GetMetaStr

func (m MetaRow) GetMetaStr(name string) (string, error)

type MutableTrack

type MutableTrack interface {
	Track
	GetMutableSequence(seqname string) (TrackMutableSequence, error)
	CloneMutableTrack() MutableTrack
}

type NucleotideAlphabet

type NucleotideAlphabet struct {
}

func (NucleotideAlphabet) Bases

func (NucleotideAlphabet) Bases(i byte) ([]byte, error)

func (NucleotideAlphabet) Code

func (NucleotideAlphabet) Code(i byte) (byte, error)

func (NucleotideAlphabet) Complement

func (NucleotideAlphabet) Complement(i byte) (byte, error)

func (NucleotideAlphabet) ComplementCoded

func (NucleotideAlphabet) ComplementCoded(i byte) (byte, error)

func (NucleotideAlphabet) Decode

func (NucleotideAlphabet) Decode(i byte) (byte, error)

func (NucleotideAlphabet) IsAmbiguous

func (NucleotideAlphabet) IsAmbiguous(i byte) (bool, error)

func (NucleotideAlphabet) IsWildcard

func (NucleotideAlphabet) IsWildcard(i byte) (bool, error)

func (NucleotideAlphabet) Length

func (NucleotideAlphabet) Length() int

func (NucleotideAlphabet) LengthUnambiguous

func (NucleotideAlphabet) LengthUnambiguous() int

func (NucleotideAlphabet) Matching

func (NucleotideAlphabet) Matching(i byte) ([]byte, error)

func (NucleotideAlphabet) String

func (NucleotideAlphabet) String() string

type OptionBinOverlap

type OptionBinOverlap struct {
	Value int
}

type OptionBinSize

type OptionBinSize struct {
	Value int
}

type OptionBinningMethod

type OptionBinningMethod struct {
	Value string
}

type OptionEstimateFraglen

type OptionEstimateFraglen struct {
	Value bool
}

type OptionFilterChroms

type OptionFilterChroms struct {
	Value []string
}

type OptionFilterDuplicates

type OptionFilterDuplicates struct {
	Value bool
}

type OptionFilterMapQ

type OptionFilterMapQ struct {
	Value int
}

type OptionFilterPairedEnd

type OptionFilterPairedEnd struct {
	Value bool
}

type OptionFilterReadLengths

type OptionFilterReadLengths struct {
	Value [2]int
}

type OptionFilterSingleEnd

type OptionFilterSingleEnd struct {
	Value bool
}

type OptionFilterStrand

type OptionFilterStrand struct {
	Value byte
}

type OptionFraglenBinSize

type OptionFraglenBinSize struct {
	Value int
}

type OptionFraglenRange

type OptionFraglenRange struct {
	Value [2]int
}

type OptionLogScale

type OptionLogScale struct {
	Value bool
}

type OptionLogger

type OptionLogger struct {
	Value *log.Logger
}

type OptionNormalizeTrack

type OptionNormalizeTrack struct {
	Value string
}

type OptionPairedAsSingleEnd

type OptionPairedAsSingleEnd struct {
	Value bool
}

type OptionPairedEndStrandSpecific

type OptionPairedEndStrandSpecific struct {
	Value bool
}

type OptionPrintScientific

type OptionPrintScientific struct {
	Value bool
}

type OptionPseudocounts

type OptionPseudocounts struct {
	Value [2]float64
}

type OptionShiftReads

type OptionShiftReads struct {
	Value [2]int
}

type OptionSmoothenControl

type OptionSmoothenControl struct {
	Value bool
}

type OptionSmoothenMin

type OptionSmoothenMin struct {
	Value float64
}

type OptionSmoothenSizes

type OptionSmoothenSizes struct {
	Value []int
}

type OrderedStringSet

type OrderedStringSet struct {
	Sequences StringSet
	Seqnames  []string
}

Structure containing genomic sequences.

func EmptyOrderedStringSet

func EmptyOrderedStringSet() OrderedStringSet

func NewOrderedStringSet

func NewOrderedStringSet(seqnames []string, sequences [][]byte) OrderedStringSet

func (OrderedStringSet) ExportFasta

func (obj OrderedStringSet) ExportFasta(filename string, compress bool) error

func (OrderedStringSet) GetSlice

func (obj OrderedStringSet) GetSlice(name string, r Range) ([]byte, error)

func (*OrderedStringSet) ImportFasta

func (obj *OrderedStringSet) ImportFasta(filename string) error

func (*OrderedStringSet) ReadFasta

func (obj *OrderedStringSet) ReadFasta(reader io.Reader) error

func (OrderedStringSet) Scan

func (obj OrderedStringSet) Scan(query []byte) GRanges

func (OrderedStringSet) WriteFasta

func (obj OrderedStringSet) WriteFasta(writer io.Writer) error

type PWM

type PWM struct {
	TFMatrix
}

func (PWM) MaxScore

func (t PWM) MaxScore(sequence []byte, revcomp bool) float64

Compute the maximum PWM score in the sequence.

func (PWM) MeanScore

func (t PWM) MeanScore(sequence []byte, revcomp bool) float64

Compute the mean of PWM scores along the sequence.

func (PWM) Scores

func (t PWM) Scores(sequence []byte, revcomp bool) []float64

Compute the PWM score for every position in the sequence.

type RTree

type RTree struct {
	BlockSize     uint32
	NItems        uint64
	ChrIdxStart   uint32
	BaseStart     uint32
	ChrIdxEnd     uint32
	BaseEnd       uint32
	IdxSize       uint64
	NItemsPerSlot uint32
	Root          *RVertex
	PtrIdxSize    int64
}

func NewRTree

func NewRTree() *RTree

func (*RTree) BuildTree

func (tree *RTree) BuildTree(leaves []*RVertex) error

func (*RTree) IsNil

func (tree *RTree) IsNil() bool

func (*RTree) Read

func (tree *RTree) Read(file io.ReadSeeker, order binary.ByteOrder) error

func (*RTree) Write

func (tree *RTree) Write(file io.WriteSeeker, order binary.ByteOrder) error

func (*RTree) WriteSize

func (tree *RTree) WriteSize(file io.WriteSeeker, order binary.ByteOrder) error

type RTreeTraverser

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

func NewRTreeTraverser

func NewRTreeTraverser(tree *RTree, chromId, from, to int) RTreeTraverser

func (*RTreeTraverser) Get

func (traverser *RTreeTraverser) Get() *RTreeTraverserType

func (*RTreeTraverser) Next

func (traverser *RTreeTraverser) Next()

func (*RTreeTraverser) Ok

func (traverser *RTreeTraverser) Ok() bool

type RTreeTraverserType

type RTreeTraverserType struct {
	Vertex *RVertex
	Idx    int
}

type RVertex

type RVertex struct {
	IsLeaf      uint8
	NChildren   uint16
	ChrIdxStart []uint32
	BaseStart   []uint32
	ChrIdxEnd   []uint32
	BaseEnd     []uint32
	DataOffset  []uint64
	Sizes       []uint64
	Children    []*RVertex
	// positions of DataOffset and Sizes values in file
	PtrDataOffset []int64
	PtrSizes      []int64
}

func (*RVertex) Read

func (vertex *RVertex) Read(file io.ReadSeeker, order binary.ByteOrder) error

func (*RVertex) ReadBlock

func (vertex *RVertex) ReadBlock(reader io.ReadSeeker, bwf *BbiFile, i int) ([]byte, error)

func (*RVertex) Write

func (vertex *RVertex) Write(file io.WriteSeeker, order binary.ByteOrder) error

func (*RVertex) WriteBlock

func (vertex *RVertex) WriteBlock(writer io.WriteSeeker, bwf *BbiFile, i int, block []byte) error

type RVertexGenerator

type RVertexGenerator struct {
	BlockSize    int
	ItemsPerSlot int
	// contains filtered or unexported fields
}

func NewRVertexGenerator

func NewRVertexGenerator(blockSize, itemsPerSlot int, order binary.ByteOrder) (*RVertexGenerator, error)

func (*RVertexGenerator) Generate

func (generator *RVertexGenerator) Generate(idx int, sequence []float64, binSize, reductionLevel int, fixedStep bool) <-chan RVertexGeneratorType

type RVertexGeneratorType

type RVertexGeneratorType struct {
	Vertex *RVertex
	Blocks [][]byte
}

type RVertexIndexPair

type RVertexIndexPair struct {
	Vertex *RVertex
	Index  int
}

type RVertexStack

type RVertexStack []RVertexIndexPair

func (*RVertexStack) Length

func (stack *RVertexStack) Length() int

func (*RVertexStack) Pop

func (stack *RVertexStack) Pop() (*RVertex, int)

func (*RVertexStack) Push

func (stack *RVertexStack) Push(v *RVertex, i int)

type Range

type Range struct {
	From, To int
}

func NewRange

func NewRange(from, to int) Range

Range object used to identify a genomic subsequence. By convention the first position in a sequence is numbered 0. The arguments from, to are interpreted as the interval [from, to).

func (Range) Intersection

func (r Range) Intersection(s Range) Range

func (Range) String

func (r Range) String() string

type Read

type Read struct {
	GRange
	MapQ      int
	Duplicate bool
	PairedEnd bool
}

Structure containing information about a read. For paired-end sequencing the range may cover the whole fragment instead of a single read

type ReadChannel

type ReadChannel <-chan Read

type SimpleTrack

type SimpleTrack struct {
	Name    string
	Genome  Genome
	Data    TMapType
	BinSize int
}

A track is a container for experimental data mapped to genomic locations. The data is binned in order to reduce memory usage. The first position in a sequence is numbered 0.

func AllocSimpleTrack

func AllocSimpleTrack(name string, genome Genome, binSize int) SimpleTrack

func BamCoverage

func BamCoverage(filenameTrack string, filenamesTreatment, filenamesControl []string, fraglenTreatment, fraglenControl []int, options ...interface{}) (SimpleTrack, []fraglenEstimate, []fraglenEstimate, error)

func EmptySimpleTrack

func EmptySimpleTrack(name string) SimpleTrack

func NewSimpleTrack

func NewSimpleTrack(name string, sequences [][]float64, genome Genome, binSize int) (SimpleTrack, error)

func (SimpleTrack) Clone

func (track SimpleTrack) Clone() SimpleTrack

func (SimpleTrack) CloneMutableTrack

func (track SimpleTrack) CloneMutableTrack() MutableTrack

func (SimpleTrack) CloneTrack

func (track SimpleTrack) CloneTrack() Track

func (SimpleTrack) ExportBigWig

func (track SimpleTrack) ExportBigWig(filename string, args ...interface{}) error

func (*SimpleTrack) FilterGenome

func (track *SimpleTrack) FilterGenome(f func(name string, length int) bool)

func (SimpleTrack) GetBinSize

func (track SimpleTrack) GetBinSize() int

func (SimpleTrack) GetGenome

func (track SimpleTrack) GetGenome() Genome

func (SimpleTrack) GetMutableSequence

func (track SimpleTrack) GetMutableSequence(query string) (TrackMutableSequence, error)

func (SimpleTrack) GetName

func (track SimpleTrack) GetName() string

func (SimpleTrack) GetSeqNames

func (track SimpleTrack) GetSeqNames() []string

func (SimpleTrack) GetSequence

func (track SimpleTrack) GetSequence(query string) (TrackSequence, error)

func (SimpleTrack) GetSlice

func (track SimpleTrack) GetSlice(r GRangesRow) ([]float64, error)

func (*SimpleTrack) ImportBedGrah

func (track *SimpleTrack) ImportBedGrah(filename string) error

func (*SimpleTrack) ImportBigWig

func (track *SimpleTrack) ImportBigWig(filename string, name string, s BinSummaryStatistics, binSize, binOverlap int, init float64) error

func (*SimpleTrack) ImportWiggle

func (track *SimpleTrack) ImportWiggle(filename string) error

func (SimpleTrack) Index

func (track SimpleTrack) Index(position int) int

func (*SimpleTrack) ReadBedGraph

func (track *SimpleTrack) ReadBedGraph(reader io.Reader) error

Import data from wiggle files.

func (*SimpleTrack) ReadBigWig

func (track *SimpleTrack) ReadBigWig(reader io.ReadSeeker, name string, f BinSummaryStatistics, binSize, binOverlap int, init float64) error

func (*SimpleTrack) ReadWiggle

func (track *SimpleTrack) ReadWiggle(reader io.Reader) error

Import data from wiggle files.

func (SimpleTrack) ShallowClone

func (track SimpleTrack) ShallowClone() SimpleTrack

func (SimpleTrack) WriteBigWig

func (track SimpleTrack) WriteBigWig(writer io.WriteSeeker, args ...interface{}) error

func (SimpleTrack) WriteWiggle

func (track SimpleTrack) WriteWiggle(filename, description string) error

Export the track to wiggle format. For sparse tracks (more than half of the values are zero), variable step formatting is used.

type StringSet

type StringSet map[string][]byte

Structure containing genomic sequences.

func EmptyStringSet

func EmptyStringSet() StringSet

func NewStringSet

func NewStringSet(seqnames []string, sequences [][]byte) StringSet

func (StringSet) ExportFasta

func (s StringSet) ExportFasta(filename string, compress bool) error

func (StringSet) GetSlice

func (s StringSet) GetSlice(name string, r Range) ([]byte, error)

func (StringSet) ImportFasta

func (s StringSet) ImportFasta(filename string) error

func (StringSet) ReadFasta

func (s StringSet) ReadFasta(reader io.Reader) error

func (StringSet) Scan

func (s StringSet) Scan(query []byte) GRanges

func (StringSet) WriteFasta

func (s StringSet) WriteFasta(writer io.Writer) error

type TFMatrix

type TFMatrix struct {
	Values [][]float64
}

func EmptyTFMatrix

func EmptyTFMatrix() TFMatrix

func NewTFMatrix

func NewTFMatrix(values [][]float64, alphabet Alphabet) TFMatrix

func (TFMatrix) Get

func (t TFMatrix) Get(c byte, j int) float64

func (TFMatrix) GetRow

func (t TFMatrix) GetRow(c byte) []float64

func (*TFMatrix) ImportMatrix

func (t *TFMatrix) ImportMatrix(filename string) error

Read a PWM matrix from file.

func (TFMatrix) Length

func (t TFMatrix) Length() int

func (*TFMatrix) ReadMatrix

func (t *TFMatrix) ReadMatrix(reader io.Reader) error

Read a PWM matrix.

func (TFMatrix) RevComp

func (t TFMatrix) RevComp() TFMatrix

func (TFMatrix) Score

func (t TFMatrix) Score(sequence []byte, revcomp bool, x0 float64, f func(float64, float64) float64) (float64, error)

Generic function for evaluating a motif on a sequence.

func (*TFMatrix) WriteJaspar

func (t *TFMatrix) WriteJaspar(writer io.Writer) error

func (*TFMatrix) WriteMatrix

func (t *TFMatrix) WriteMatrix(writer io.Writer) error

type TMapType

type TMapType map[string][]float64

type Track

type Track interface {
	GetName() string
	GetBinSize() int
	GetSequence(seqname string) (TrackSequence, error)
	GetGenome() Genome
	GetSeqNames() []string
	GetSlice(r GRangesRow) ([]float64, error)
	CloneTrack() Track
}

type TrackHistogram

type TrackHistogram struct {
	Name string
	X    []float64
	Y    []float64
}

func (TrackHistogram) String

func (histogram TrackHistogram) String() string

type TrackMutableSequence

type TrackMutableSequence struct {
	TrackSequence
}

type TrackSequence

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

func (TrackSequence) At

func (obj TrackSequence) At(i int) float64

func (TrackSequence) AtBin

func (obj TrackSequence) AtBin(i int) float64

func (TrackSequence) GetBinSize

func (obj TrackSequence) GetBinSize() int

func (TrackSequence) NBins

func (obj TrackSequence) NBins() int

func (TrackSequence) Set

func (obj TrackSequence) Set(i int, v float64)

func (TrackSequence) SetBin

func (obj TrackSequence) SetBin(i int, v float64)

type TrackSummaryStatistics

type TrackSummaryStatistics struct {
	Name string
	Mean float64
	Max  float64
	Min  float64
	N    int
}

func (TrackSummaryStatistics) String

func (statistics TrackSummaryStatistics) String() string

Jump to

Keyboard shortcuts

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