Documentation
¶
Overview ¶
Package uniprot is the library behind the uniprot command line: the HTTP client, request shaping, and the typed data models for the UniProt REST API.
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) Protein(ctx context.Context, accession string) (*Protein, error)
- func (c *Client) Search(ctx context.Context, query string, opts SearchOptions) ([]*Protein, error)
- func (c *Client) Taxonomy(ctx context.Context, taxonID int) (*Taxonomy, error)
- type Config
- type Domain
- type Protein
- type SearchOptions
- type Taxonomy
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "uniprot-cli/0.1.0 (github.com/tamnd/uniprot-cli)"
DefaultUserAgent identifies the client to UniProt 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 UniProt 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.
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 uniprot 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). UniProt accessions (e.g. P04637, Q9Y2T1) → type "protein". Taxon IDs (numeric, e.g. 9606) → type "taxonomy".
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 Protein ¶
type Protein struct {
Accession string `json:"accession" kit:"id"`
EntryName string `json:"entry_name"`
ProteinName string `json:"protein_name"`
GeneName string `json:"gene_name,omitempty"`
Organism string `json:"organism"`
TaxonomyID int `json:"taxonomy_id,omitempty"`
Reviewed bool `json:"reviewed"` // Swiss-Prot vs TrEMBL
Length int `json:"length,omitempty"`
Function string `json:"function,omitempty"`
}
Protein is a flattened, output-friendly UniProt protein record.
type SearchOptions ¶
SearchOptions controls the search query.