Documentation
¶
Overview ¶
Package biosample is the library behind the biosample command line: the HTTP client, request shaping, and the typed data models for NCBI BioSample.
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 Client
- func (c *Client) FetchSamples(ctx context.Context, ids []string) ([]*Sample, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetSample(ctx context.Context, uid string) (*Sample, 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) ([]*Sample, int, error)
- type Config
- type Domain
- type Sample
Constants ¶
const DefaultUserAgent = "biosample-cli/dev (+https://github.com/tamnd/biosample-cli)"
DefaultUserAgent identifies the client to NCBI.
const Host = "eutils.ncbi.nlm.nih.gov"
Host is the NCBI eUtils host, used for Locate / URI resolution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 BioSample API over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client using the given config.
func (*Client) FetchSamples ¶
FetchSamples fetches esummary for a batch of BioSample UIDs and returns Sample records.
type Config ¶
type Config struct {
BaseURL string
APIKey string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config carries the tunable parameters for the BioSample 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 BioSample 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). All-digit strings are BioSample UIDs. Anything else is an error.
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.
type Sample ¶
type Sample struct {
ID string `json:"id" kit:"id"` // BioSample UID (numeric)
Accession string `json:"accession"`
Title string `json:"title"`
Organism string `json:"organism,omitempty"`
TaxID string `json:"tax_id,omitempty"`
Organization string `json:"organization,omitempty"`
Status string `json:"status,omitempty"`
PublicationDate string `json:"publication_date,omitempty"`
SubmissionDate string `json:"submission_date,omitempty"`
}
Sample is a single NCBI BioSample record.