Documentation
¶
Overview ¶
Package uniref is the library behind the uniref command line: the HTTP client, request shaping, and the typed data models for the UniRef REST API (UniProt Reference Clusters, 381M protein cluster records).
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) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetCluster(ctx context.Context, id string) (*Cluster, error)
- func (c *Client) GetMembers(ctx context.Context, id string, limit int) ([]*Member, error)
- func (c *Client) Search(ctx context.Context, query string, limit int) ([]*Cluster, error)
- type Cluster
- type Config
- type Domain
- type Member
Constants ¶
const BaseURL = "https://" + Host + "/uniref"
BaseURL is the root every UniRef request is built from.
const DefaultUserAgent = "uniref-cli/0.1.0 (github.com/tamnd/uniref-cli)"
DefaultUserAgent identifies the client to UniRef servers.
const Host = "rest.uniprot.org"
Host is the site this client talks to.
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 UniRef REST API over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from cfg.
func (*Client) Get ¶
Get fetches the URL and returns the response body. It paces and retries according to the client's settings.
func (*Client) GetCluster ¶
GetCluster fetches a single cluster by ID (e.g. "UniRef50_P04637").
func (*Client) GetMembers ¶
GetMembers fetches members of a cluster by ID.
type Cluster ¶
type Cluster struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
EntryType string `json:"entry_type"`
MemberCount int `json:"member_count"`
TaxonName string `json:"taxon_name,omitempty"`
TaxonID int `json:"taxon_id,omitempty"`
Updated string `json:"updated,omitempty"`
RepName string `json:"representative_name,omitempty"`
RepProtein string `json:"representative_protein,omitempty"`
RepAccession string `json:"representative_accession,omitempty"`
SeqLength int `json:"seq_length,omitempty"`
MolWeight int `json:"mol_weight,omitempty"`
}
Cluster is a flattened, output-friendly UniRef cluster record.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable client parameters.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the uniref 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 (type, id). Inputs matching UniRef(50|90|100)_... pattern map to type "cluster".
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 Member ¶
type Member struct {
ID string `json:"id" kit:"id"` // memberId
Type string `json:"type"`
Organism string `json:"organism,omitempty"`
Protein string `json:"protein,omitempty"`
Accession string `json:"accession,omitempty"`
UniRef50 string `json:"uniref50,omitempty"`
UniRef90 string `json:"uniref90,omitempty"`
UniRef100 string `json:"uniref100,omitempty"`
}
Member is a single member entry within a UniRef cluster.