Documentation
¶
Overview ¶
Package ncbiassembly is the library behind the ncbiassembly command line: the HTTP client, request shaping, and the typed data models for the NCBI Assembly database (3.6M+ genome assemblies).
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Search and summary calls follow the standard eUtils two-step: esearch returns a list of numeric UIDs, esummary turns them into records.
Index ¶
- Constants
- type Assembly
- type Client
- func (c *Client) FetchAssemblies(ctx context.Context, ids []string) ([]*Assembly, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetAssembly(ctx context.Context, uid string) (*Assembly, error)
- func (c *Client) Search(ctx context.Context, query string, limit, start int) ([]string, int, error)
- func (c *Client) SearchAndFetch(ctx context.Context, query string, limit, start int) ([]*Assembly, int, error)
- type Config
- type Domain
Constants ¶
const DefaultUserAgent = "ncbiassembly-cli/dev (+https://github.com/tamnd/ncbiassembly-cli)"
DefaultUserAgent identifies the client to NCBI.
const Host = "www.ncbi.nlm.nih.gov"
Host is the NCBI Assembly web host, used for Locate / URI resolution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assembly ¶
type Assembly struct {
ID string `json:"id" kit:"id"` // numeric UID
Accession string `json:"accession,omitempty"`
Name string `json:"name,omitempty"`
Organism string `json:"organism,omitempty"`
SpeciesName string `json:"species,omitempty"`
TaxID string `json:"tax_id,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
WGS string `json:"wgs,omitempty"`
BioSample string `json:"biosample,omitempty"`
}
Assembly is a single NCBI Assembly record.
type Client ¶
type Client struct {
HTTP *http.Client
// exported shims so domain.go newClient can set them like the scaffold does
UserAgent string
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the NCBI eUtils Assembly API over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client using the given config.
func (*Client) FetchAssemblies ¶
FetchAssemblies fetches esummary for a batch of Assembly UIDs and returns Assembly records.
func (*Client) GetAssembly ¶
GetAssembly fetches a single Assembly record by numeric UID.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config carries the tunable parameters for the Assembly client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the free-tier NCBI eUtils API (3 req/s without a key).
type Domain ¶
type Domain struct{}
Domain is the NCBI Assembly driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). Non-empty strings are accepted and returned as assembly IDs.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.