Documentation
¶
Index ¶
- Constants
- func BuildIndexes(dataDir string, logFn func(string, ...any)) error
- func BuildPartitions(dataDir string, logFn func(string, ...any)) error
- func IndexPath(dataDir, genus string) string
- func PartitionPath(dataDir, genus string) string
- func PartitionsForSpeciesPattern(dataDir, pattern string) []string
- type Filters
- type Result
Constants ¶
const AMRFileName = "amrfinderplus.parquet"
AMRFileName is the single merged parquet file containing all AMR data.
const PartitionDir = "amr"
PartitionDir is the subdirectory under the data dir where genus partitions live.
const PartitionThreshold = 10_000
PartitionThreshold is the minimum number of rows a genus must have to get its own partition file. Genera below this threshold are grouped into _other.parquet.
Variables ¶
This section is empty.
Functions ¶
func BuildIndexes ¶
BuildIndexes reads each .parquet file in the partition directory and builds a corresponding .sqlite index. Builds run in parallel (one goroutine per file, bounded by NumCPU).
func BuildPartitions ¶
BuildPartitions reads the monolithic amrfinderplus.parquet and writes per-genus partition files into <dataDir>/amr/. Uses a streaming two-pass approach:
- First pass: count rows per genus (reads only Genus column equivalent).
- Second pass: stream rows into per-genus writers, routing small genera to _other.
logFn is called with progress messages (pass nil to suppress output).
func IndexPath ¶
IndexPath returns the path to a genus SQLite index if it exists. Lookup is case-insensitive so GTDB letter clades match files stored under their exact source-case filename (e.g. --genus legionella_c hits Legionella_C.sqlite).
func PartitionPath ¶
PartitionPath returns the path to a genus partition file if it exists. Returns empty string if the partition doesn't exist. Lookup is case- insensitive so that GTDB letter clades (e.g. Legionella_C) match files stored under their exact source-case filename.
func PartitionsForSpeciesPattern ¶ added in v0.19.0
PartitionsForSpeciesPattern returns the partition names that can hold rows whose species matches pattern, genus partitions first and the _other sweep file last. Returns nil when the pattern cannot narrow the search or no partitions are built, in which case the caller scans the monolithic file.
Types ¶
type Filters ¶
type Filters struct {
// Samples restricts results to a specific set of sample accessions.
// Nil or empty means no restriction.
Samples map[string]struct{}
// Class filters by drug class (case-insensitive substring match). Empty means all.
Class string
// GenePattern filters by gene symbol. Supports % wildcards. Empty means all.
GenePattern string
// MinCoverage is the minimum coverage percentage (0 = no minimum).
MinCoverage float64
// MinIdentity is the minimum identity percentage (0 = no minimum).
MinIdentity float64
// ElementType restricts to a specific element type ("AMR", "STRESS", "VIRULENCE"). Empty means all.
ElementType string
// Genera restricts results to specific bacterial genera (case-insensitive).
// Nil or empty means all genera (full scan).
Genera []string
// Species restricts results to specific full species names, e.g. "Escherichia coli"
// (case-insensitive exact match against the row's Species field).
// Nil or empty means no species-level restriction.
Species []string
// SpeciesLike restricts results to species matching a wildcard pattern,
// e.g. "Campylobacter_D jej%". % matches any sequence of characters and _
// is literal. Empty means no pattern restriction.
SpeciesLike string
// Limit caps the number of returned results. 0 means no limit.
Limit int
}
Filters controls which AMR rows are returned by Query.
type Result ¶
type Result struct {
SampleAccession string `json:"Name"`
ProteinID string `json:"Protein id"`
ContigID string `json:"Contig id"`
Start int64 `json:"Start"`
Stop int64 `json:"Stop"`
Strand string `json:"Strand"`
GeneSymbol string `json:"Element symbol"`
ElementName string `json:"Element name"`
Scope string `json:"Scope"`
ElementType string `json:"Type"`
ElementSubtype string `json:"Subtype"`
Class string `json:"Class"`
Subclass string `json:"Subclass"`
Method string `json:"Method"`
TargetLength int64 `json:"Target length"`
ReferenceSequenceLength int64 `json:"Reference sequence length"`
Coverage float64 `json:"% Coverage of reference"`
Identity float64 `json:"% Identity to reference"`
AlignmentLength int64 `json:"Alignment length"`
ClosestReferenceAccession string `json:"Closest reference accession"`
ClosestReferenceName string `json:"Closest reference name"`
HMMAccession string `json:"HMM accession"`
HMMDescription string `json:"HMM description"`
HierarchyNode string `json:"Hierarchy node"`
Genus string `json:"genus"`
Species string `json:"species"`
}
Result is a single AMR gene hit associated with a sample. The JSON tags preserve the AMRFinderPlus v4.2.5 column names verbatim so MCP output and the original TSV use identical headers.