Documentation
¶
Overview ¶
Package gff3idx provides two backends for querying GFF3 features: an in-memory index (MemQuerier) and a persistent mmap-based binary index. Both implement the Querier interface.
In-memory usage:
q := gff3idx.Wrap(records)
feat, _ := q.ByID("gene00001")
Binary index usage:
gff3idx.Build(records, "genes.gff3idx")
idx, _ := gff3idx.Open("genes.gff3idx")
feat, _ := idx.ByID("gene00001")
Index ¶
- Constants
- func Build(records []*gff3.Record, outPath string) error
- func ByteOrder() binary.ByteOrder
- func NextPow2(n uint32) uint32
- type EntryRecord
- type Feature
- type GeneChildren
- type GeneRecord
- type HashSlot
- type Header
- type MemQuerier
- type Querier
- type Reader
- func (r *Reader) ByID(id string) (*Feature, bool)
- func (r *Reader) ChildrenOf(geneID string) (*GeneChildren, bool)
- func (r *Reader) ChrCount() uint32
- func (r *Reader) Close() error
- func (r *Reader) EntryCount() uint32
- func (r *Reader) GeneCount() uint32
- func (r *Reader) InRange(chr string, minStart, maxEnd int) []SpatialFeat
- type SpatialFeat
- type SpatialFeatureRec
- type SpatialHeader
Constants ¶
const ( Magic = "GFFI" Version = 1 )
const EntryRecordSize = 40
const GeneRecordSize = 24
const HashSlotSize = 16
const HeaderSize = 64
const SpatialFeatureRecSize = 24
const SpatialHeaderSize = 16
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EntryRecord ¶
type Feature ¶
type Feature struct {
SeqID string
Source string
Type string
Start int
End int
Score string
Strand string
Phase int
}
Feature represents a single GFF3 feature returned from a query.
type GeneChildren ¶
type GeneChildren struct {
Transcripts []string // mRNA IDs
CDSs []string // CDS feature IDs
Exons []string // exon feature IDs
}
GeneChildren holds the IDs of a gene's child features, grouped by type.
type GeneRecord ¶
type MemQuerier ¶
type MemQuerier struct {
// contains filtered or unexported fields
}
MemQuerier is an in-memory index built from parsed GFF3 records. It implements Querier with zero build cost — just wrap your records and start querying.
Memory cost is approximately the same as the underlying []*Record slice plus index overhead (maps for ID, gene hierarchy, and spatial).
func Wrap ¶
func Wrap(records []*gff3.Record) *MemQuerier
Wrap builds an in-memory Querier from parsed GFF3 records.
Records without an ID attribute are skipped. Discontiguous features (same ID on multiple lines) have their coordinate extents merged.
func (*MemQuerier) ChildrenOf ¶
func (m *MemQuerier) ChildrenOf(geneID string) (*GeneChildren, bool)
func (*MemQuerier) InRange ¶
func (m *MemQuerier) InRange(chr string, minStart, maxEnd int) []SpatialFeat
type Querier ¶
type Querier interface {
// ByID looks up a feature by its ID attribute.
// Returns nil, false if not found.
ByID(id string) (*Feature, bool)
// ChildrenOf returns the gene's child features grouped by type:
// transcripts (mRNA), CDSs, and exons.
// Traverses the two-level hierarchy gene → mRNA → (CDS, exon).
ChildrenOf(geneID string) (*GeneChildren, bool)
// InRange returns all features that overlap the given genomic interval.
// Returns nil if chromosome not found.
InRange(chr string, minStart, maxEnd int) []SpatialFeat
}
Querier is the common interface for both in-memory and binary index backends.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a Querier backed by a memory-mapped binary index file. Created by Open(), must be Closed() to release resources.
func Open ¶
Open mmaps a binary index file and returns a queryable Reader. The Reader implements Querier. Close() must be called to release the mmap region and file handle.
The index file is validated on open (magic, version, bounds checks).
func (*Reader) ChildrenOf ¶
func (r *Reader) ChildrenOf(geneID string) (*GeneChildren, bool)
func (*Reader) EntryCount ¶
type SpatialFeat ¶
SpatialFeat is a lightweight feature record returned by InRange queries.