index

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IndexFileName = "atb_index.sqlite"

Variables

This section is empty.

Functions

func Build

func Build(dataDir string, logf func(string, ...any)) error

Build creates or rebuilds the SQLite index from parquet files in dataDir.

func Exists

func Exists(dataDir string) bool

Exists checks if the index file exists in dataDir.

Types

type DB

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

DB wraps a read-only SQLite connection to the index.

func Open

func Open(dataDir string) (*DB, error)

Open opens the index database. Returns error if it doesn't exist.

func (*DB) Close

func (d *DB) Close() error

Close closes the database connection.

func (*DB) InfoRow

func (d *DB) InfoRow(sampleAccession string) (map[string]string, error)

InfoRow returns all indexed columns for a single sample as a map.

func (*DB) MLSTForSample

func (d *DB) MLSTForSample(sampleAccession string) (map[string]string, error)

MLSTForSample returns MLST fields for a single sample, or nil if not indexed.

func (*DB) Query

func (d *DB) Query(params QueryParams) ([]map[string]string, error)

Query runs a filtered query returning result rows as map[string]string.

func (*DB) QueryStats

func (d *DB) QueryStats(species string, hqOnly bool) (Stats, error)

QueryStats returns summary statistics, optionally filtered by species and/or HQ. Stats always exclude samples that aren't published on OSF (asm_fasta_on_osf == 0), so the four numbers match what users see in the published release tables.

func (*DB) SpeciesList

func (d *DB) SpeciesList(limit int) ([]SpeciesCount, error)

SpeciesList returns species sorted by descending sample count. Only samples with an assembly actually published on OSF (asm_fasta_on_osf == 1) are counted, matching the published-release semantics used by atb summarise.

type QueryParams

type QueryParams struct {
	Species          string
	SpeciesLike      string
	Genus            string
	HQOnly           bool
	MinCompleteness  float64
	MaxContamination float64
	MinN50           int64
	Dataset          string
	HasAssembly      bool
	Samples          []string
	Columns          []string
	SortBy           string
	SortDesc         bool
	Limit            int
	Offset           int
	SequenceType     string // filter by mlst_st
	Scheme           string // filter by mlst_scheme
	MLSTStatus       string // filter by mlst_status
	MLSTOnly         bool   // exclude samples with no MLST scheme (empty or "-")
}

QueryParams controls what the Query method returns.

type SpeciesCount

type SpeciesCount struct {
	Species string
	Count   int
}

SpeciesCount holds a species name and its sample count.

type Stats

type Stats struct {
	Total      int
	HQCount    int
	TopSpecies []SpeciesCount
	Datasets   map[string]int
}

Stats holds summary statistics for the database.

Jump to

Keyboard shortcuts

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