Documentation
¶
Overview ¶
Package opentargets is the library behind the opentargets command line: the HTTP client, GraphQL request shaping, and typed data models for the Open Targets Platform — a disease-target association database covering 60,000+ drug targets and 30,000+ diseases.
The Client posts GraphQL queries to the public API at api.platform.opentargets.org. No API key is required.
Index ¶
- Constants
- type Association
- type Client
- func (c *Client) DiseaseTargets(ctx context.Context, efoID string, limit int) ([]*Association, error)
- func (c *Client) GetDisease(ctx context.Context, efoID string) (*Disease, error)
- func (c *Client) GetTarget(ctx context.Context, ensemblID string) (*Target, error)
- func (c *Client) SearchTargets(ctx context.Context, q string, limit int) ([]*SearchResult, int, error)
- func (c *Client) TargetDiseases(ctx context.Context, ensemblID string, limit int) ([]*Association, error)
- type Disease
- type Domain
- type SearchResult
- type Target
Constants ¶
const DefaultUserAgent = "opentargets/dev (+https://github.com/tamnd/opentargets-cli)"
DefaultUserAgent identifies the client to the Open Targets API.
const Host = "api.platform.opentargets.org"
Host is the API hostname and the host the URI driver in domain.go claims.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Association ¶
type Association struct {
TargetID string `json:"target_id,omitempty"`
TargetSymbol string `json:"target_symbol,omitempty"`
DiseaseID string `json:"disease_id,omitempty"`
DiseaseName string `json:"disease_name,omitempty"`
Score float64 `json:"score"`
}
Association is a scored target-disease association.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// BaseURL may be overridden in tests.
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 Open Targets GraphQL API.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: 30s timeout, 300ms pacing, three retries on transient errors.
func (*Client) DiseaseTargets ¶
func (c *Client) DiseaseTargets(ctx context.Context, efoID string, limit int) ([]*Association, error)
DiseaseTargets returns the top targets associated with a disease, ordered by association score. limit ≤ 0 defaults to 10.
func (*Client) GetDisease ¶
GetDisease fetches a single disease by EFO ID (e.g. "EFO_0000311").
func (*Client) GetTarget ¶
GetTarget fetches a single target by Ensembl ID (e.g. "ENSG00000141510").
func (*Client) SearchTargets ¶
func (c *Client) SearchTargets(ctx context.Context, q string, limit int) ([]*SearchResult, int, error)
SearchTargets searches targets by keyword and returns matching results plus the total hit count. limit ≤ 0 defaults to 10.
func (*Client) TargetDiseases ¶
func (c *Client) TargetDiseases(ctx context.Context, ensemblID string, limit int) ([]*Association, error)
TargetDiseases returns the top diseases associated with a target, ordered by association score. limit ≤ 0 defaults to 10.
type Disease ¶
type Disease struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
Disease is one disease/phenotype from Open Targets.
type Domain ¶
type Domain struct{}
Domain is the Open Targets 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). Any non-empty string is accepted as a target id by default; EFO IDs are classified as diseases.
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 SearchResult ¶
SearchResult is a single hit from a keyword search.