Documentation
¶
Index ¶
- Constants
- func BuildArchive(ctx context.Context, opts BuildOptions) error
- func CanonicalJSON(value any) ([]byte, error)
- func CanonicalJSONSHA256(value any) (string, error)
- func DecodeJSON(data []byte) (any, error)
- func ExtractArchive(ctx context.Context, opts ExtractOptions) error
- func FeatureNT(feature map[string]any, genome Genome) (string, bool)
- func JSONBytesCanonicalSHA256(data []byte) (string, error)
- func OpenManifestSources(path string) (FileSource, FileSource, error)
- func PrettyJSON(value any) ([]byte, error)
- func SHA256Hex(data []byte) string
- type AGCGenomeSource
- type Archive
- type ArchiveIndex
- type BuildOptions
- type ChunkIndex
- type DirSource
- type ExtractOptions
- type ExtractRequest
- type ExtractedSample
- type FieldCodec
- type FileRecord
- type FileSource
- type Genome
- type JSONChecksums
- type ListSource
- type Manifest
- type ManifestEntry
- type ManifestSource
- type OpenArchiveOptions
- type ReduceResult
- type RestoreResult
- type SampleIndex
- type SchemaIndexEntry
- type TarXZSource
Constants ¶
const ( ArchiveMagic = "BAKPACK1" ArchiveVersion = 1 )
Variables ¶
This section is empty.
Functions ¶
func BuildArchive ¶
func BuildArchive(ctx context.Context, opts BuildOptions) error
func CanonicalJSON ¶
func CanonicalJSONSHA256 ¶
func DecodeJSON ¶
func ExtractArchive ¶
func ExtractArchive(ctx context.Context, opts ExtractOptions) error
func OpenManifestSources ¶
func OpenManifestSources(path string) (FileSource, FileSource, error)
func PrettyJSON ¶
Types ¶
type AGCGenomeSource ¶
func (AGCGenomeSource) Get ¶
func (s AGCGenomeSource) Get(ctx context.Context, sample string) (FileRecord, error)
func (AGCGenomeSource) Order ¶
func (s AGCGenomeSource) Order(ctx context.Context) ([]string, error)
func (AGCGenomeSource) Records ¶
func (s AGCGenomeSource) Records(ctx context.Context) ([]FileRecord, error)
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive is an opened bakpack archive. It keeps the archive index in memory and can extract one or more samples without reopening the archive.
func OpenArchive ¶
OpenArchive opens a local or HTTP(S) bakpack archive and reads its front index. HTTP(S) archives are accessed with byte-range requests.
func (*Archive) Extract ¶
func (a *Archive) Extract(ctx context.Context, req ExtractRequest) ([]ExtractedSample, error)
Extract extracts one or more samples from the archive. Without OnSample, results are returned in the same order as req.Samples. With OnSample, results are delivered to the callback and the returned slice is nil.
func (*Archive) Index ¶
func (a *Archive) Index() ArchiveIndex
Index returns a copy of the archive index.
type ArchiveIndex ¶
type ArchiveIndex struct {
Format string `json:"format"`
Version int `json:"version"`
PayloadFormat string `json:"payload_format"`
ChunkSize int `json:"chunk_size"`
Chunks []ChunkIndex `json:"chunks"`
Samples []SampleIndex `json:"samples"`
}
func ReadArchiveIndex ¶
func ReadArchiveIndex(path string) (ArchiveIndex, error)
func ReadArchiveIndexContext ¶
func ReadArchiveIndexContext(ctx context.Context, path string, opts ...OpenArchiveOptions) (ArchiveIndex, error)
ReadArchiveIndexContext reads the front index from a local or HTTP(S) archive. HTTP(S) archives are accessed with byte-range requests.
type BuildOptions ¶
type BuildOptions struct {
Annotations FileSource
Genomes FileSource
Order []string
ChunkSize int
OutputPath string
XZThreads int
// AnnotationSpoolCompression controls temporary files made when building
// from annotation tar.xz sources whose order differs from genome order.
// Supported values are "", "gzip", "none", and "raw"; "" defaults to gzip.
AnnotationSpoolCompression string
}
type ChunkIndex ¶
type ChunkIndex struct {
ID int `json:"id"`
Offset int64 `json:"offset"`
CompressedSize int64 `json:"compressed_size"`
UncompressedSize int64 `json:"uncompressed_size"`
TopKeys []string `json:"top_keys,omitempty"`
ValueSchemas []SchemaIndexEntry `json:"value_schemas,omitempty"`
FeatureSchemas []SchemaIndexEntry `json:"feature_schemas,omitempty"`
FeatureFields []string `json:"feature_fields,omitempty"`
FieldCodecs []FieldCodec `json:"field_codecs,omitempty"`
}
type ExtractOptions ¶
type ExtractRequest ¶
type ExtractRequest struct {
// Genomes is required when Original or Genome output is requested.
Genomes FileSource
// Samples are the sample IDs to extract.
Samples []string
// Reduced returns reduced Bakta JSON.
Reduced bool
// Original reconstructs original Bakta JSON and verifies its canonical hash.
Original bool
// Genome returns matching genome FASTA.
Genome bool
// OnSample is called for each extracted sample. When nil, Extract returns
// accumulated results in the same order as Samples.
OnSample func(ExtractedSample) error
}
ExtractRequest configures extraction from an opened archive.
type ExtractedSample ¶
type ExtractedSample struct {
SampleID string
AnnotationName string
GenomeName string
ReducedJSON []byte
OriginalJSON []byte
GenomeFASTA []byte
OriginalJSONCanonicalSHA256 string
ReducedJSONCanonicalSHA256 string
}
ExtractedSample contains the bytes extracted or reconstructed for one sample.
type FieldCodec ¶
type FileRecord ¶
type FileSource ¶
type FileSource interface {
Records(context.Context) ([]FileRecord, error)
Get(context.Context, string) (FileRecord, error)
Order(context.Context) ([]string, error)
}
func OpenSource ¶
func OpenSource(path, kind, role string) (FileSource, error)
type Genome ¶
type Genome struct {
SampleID string
Filename string
Contigs []seqio.SeqRecord
// contains filtered or unexported fields
}
func (Genome) FASTABytes ¶
type JSONChecksums ¶
type JSONChecksums struct {
CanonicalSHA256 string `json:"canonical_sha256"`
}
type ListSource ¶
func (ListSource) Get ¶
func (s ListSource) Get(ctx context.Context, sample string) (FileRecord, error)
func (ListSource) Records ¶
func (s ListSource) Records(ctx context.Context) ([]FileRecord, error)
type ManifestEntry ¶
type ManifestSource ¶
func (ManifestSource) Get ¶
func (s ManifestSource) Get(ctx context.Context, sample string) (FileRecord, error)
func (ManifestSource) Records ¶
func (s ManifestSource) Records(ctx context.Context) ([]FileRecord, error)
type OpenArchiveOptions ¶
type OpenArchiveOptions struct {
// HTTPClient is used for byte-range requests when the archive path is an
// HTTP(S) URL. A nil client uses http.DefaultClient.
HTTPClient *http.Client
}
OpenArchiveOptions configures archive reads.
type ReduceResult ¶
type ReduceResult struct {
ReducedJSON []byte
Original JSONChecksums
Reduced JSONChecksums
}
func ReduceBaktaJSON ¶
func ReduceBaktaJSON(original []byte, genome Genome) (ReduceResult, error)
type RestoreResult ¶
type RestoreResult struct {
OriginalJSON []byte
Original JSONChecksums
}
func RestoreBaktaJSON ¶
func RestoreBaktaJSON(reduced []byte, genome Genome) (RestoreResult, error)
type SampleIndex ¶
type SampleIndex struct {
SampleID string `json:"sample_id"`
AnnotationName string `json:"annotation_name"`
GenomeName string `json:"genome_name"`
ChunkID int `json:"chunk_id"`
OriginalJSONCanonicalSHA256 string `json:"original_json_canonical_sha256"`
ReducedJSONCanonicalSHA256 string `json:"reduced_json_canonical_sha256"`
}
type SchemaIndexEntry ¶
type TarXZSource ¶
func (TarXZSource) Get ¶
func (s TarXZSource) Get(ctx context.Context, sample string) (FileRecord, error)
func (TarXZSource) Records ¶
func (s TarXZSource) Records(ctx context.Context) ([]FileRecord, error)