Documentation
¶
Overview ¶
Package ensembl is the library behind the ensembl command line: the HTTP client, request shaping, and the typed data models for the Ensembl REST API (genomics/genetics).
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.
Index ¶
- Constants
- type Client
- func (c *Client) Gene(ctx context.Context, species, symbol string) (*Gene, error)
- func (c *Client) GeneByID(ctx context.Context, id string) (*Gene, error)
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) Region(ctx context.Context, species, region, feature string) ([]*Gene, error)
- func (c *Client) SpeciesList(ctx context.Context) ([]*Species, error)
- func (c *Client) Variant(ctx context.Context, species, variantID string) (*VariantRecode, error)
- type Config
- type Domain
- type Gene
- type Species
- type VariantRecode
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "ensembl-cli/0.1.0 (github.com/tamnd/ensembl-cli)"
DefaultUserAgent identifies the client to the Ensembl REST API.
const Host = "rest.ensembl.org"
Host is the Ensembl REST API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
BaseURL string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the Ensembl REST API over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from a Config struct.
func (*Client) Gene ¶
Gene looks up a gene by symbol for the given species. species defaults to "human" if empty.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings.
func (*Client) Region ¶
Region returns genes overlapping a chromosomal region for the given species. region format: "chr:start-end" e.g. "17:43044292-43125482" feature defaults to "gene" if empty.
func (*Client) SpeciesList ¶
SpeciesList returns all species supported by the Ensembl REST API.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the Ensembl REST API.
type Domain ¶
type Domain struct{}
Domain is the ensembl 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). Gene symbols (BRCA1, TP53) map to type "gene". Ensembl IDs (ENSG...) map to type "gene". rs IDs map to type "variant".
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 Gene ¶
type Gene struct {
ID string `json:"id" kit:"id"`
Symbol string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Chromosome string `json:"chromosome"`
Start int `json:"start"`
End int `json:"end"`
Strand int `json:"strand"`
Biotype string `json:"biotype,omitempty"`
Species string `json:"species,omitempty"`
AssemblyName string `json:"assembly_name,omitempty"`
}
Gene represents a gene record from the Ensembl REST API.
type Species ¶
type Species struct {
Name string `json:"name" kit:"id"`
DisplayName string `json:"display_name"`
Assembly string `json:"assembly"`
TaxonomyID int `json:"taxonomy_id"`
Division string `json:"division,omitempty"`
}
Species represents a species supported by the Ensembl REST API.
type VariantRecode ¶
type VariantRecode struct {
Input string `json:"input" kit:"id"`
HGVSG []string `json:"hgvsg,omitempty"`
HGVSC []string `json:"hgvsc,omitempty"`
HGVSP []string `json:"hgvsp,omitempty"`
VCF []string `json:"vcf,omitempty"`
SPDI []string `json:"spdi,omitempty"`
}
VariantRecode holds the recoded forms of a variant (rs ID to HGVS/VCF/SPDI).