opentargets

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
const DefaultUserAgent = "opentargets/dev (+https://github.com/tamnd/opentargets-cli)"

DefaultUserAgent identifies the client to the Open Targets API.

View Source
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

func (c *Client) GetDisease(ctx context.Context, efoID string) (*Disease, error)

GetDisease fetches a single disease by EFO ID (e.g. "EFO_0000311").

func (*Client) GetTarget

func (c *Client) GetTarget(ctx context.Context, ensemblID string) (*Target, error)

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

func (Domain) Classify(input string) (uriType, id string, err error)

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type SearchResult

type SearchResult struct {
	ID   string `json:"id"   kit:"id"`
	Name string `json:"name"`
}

SearchResult is a single hit from a keyword search.

type Target

type Target struct {
	ID      string `json:"id"      kit:"id"`
	Symbol  string `json:"symbol,omitempty"`
	Name    string `json:"name,omitempty"`
	Biotype string `json:"biotype,omitempty"`
}

Target is one gene/protein target from Open Targets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL