chembl

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package chembl is the library behind the chembl command line: the HTTP client, request shaping, and the typed data models for the ChEMBL REST API (https://www.ebi.ac.uk/chembl/api/data).

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

View Source
const BaseURL = "https://www.ebi.ac.uk/chembl/api/data"

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "chembl-cli/0.1.0 (github.com/tamnd/chembl-cli)"

DefaultUserAgent identifies the client to ChEMBL.

View Source
const Host = "www.ebi.ac.uk"

Host is the EBI ChEMBL web host.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	ActivityID   int    `json:"activity_id" kit:"id"`
	AssayID      string `json:"assay_chembl_id"`
	MoleculeID   string `json:"molecule_chembl_id"`
	TargetID     string `json:"target_chembl_id"`
	TargetName   string `json:"target_pref_name" kit:"body"`
	ActivityType string `json:"activity_type"`
	Value        string `json:"value"`
	Units        string `json:"units"`
}

Activity is a single bioactivity measurement from ChEMBL.

type Client

type Client struct {
	HTTP *http.Client
	// contains filtered or unexported fields
}

Client talks to the ChEMBL REST API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with DefaultConfig.

func NewClientWithConfig

func NewClientWithConfig(cfg Config) *Client

NewClientWithConfig returns a Client built from the provided Config.

func (*Client) Activities

func (c *Client) Activities(ctx context.Context, moleculeID, targetID string, limit int) ([]*Activity, error)

Activities fetches bioactivities filtered by molecule or target ChEMBL ID. At least one of moleculeID or targetID must be non-empty.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's config. The caller owns nothing extra; the body is read fully and closed here.

func (*Client) Molecule

func (c *Client) Molecule(ctx context.Context, id string) (*Molecule, error)

Molecule fetches a single molecule by its ChEMBL ID (e.g. "CHEMBL25").

func (*Client) SearchMolecules

func (c *Client) SearchMolecules(ctx context.Context, q string, limit int) ([]*Molecule, error)

SearchMolecules searches molecules by name or SMILES query.

func (*Client) SearchTargets

func (c *Client) SearchTargets(ctx context.Context, q string, limit int) ([]*Target, error)

SearchTargets searches targets by name query.

func (*Client) SetRetries

func (c *Client) SetRetries(n int)

SetRetries updates the number of retries (useful in tests).

func (*Client) Target

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

Target fetches a single target by its ChEMBL ID.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds the tunable knobs for a Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for calling the ChEMBL API.

type Domain

type Domain struct{}

Domain is the ChEMBL driver.

func (Domain) Classify

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

Classify turns any accepted input into the canonical (type, id).

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 Molecule

type Molecule struct {
	ID        string `json:"molecule_chembl_id" kit:"id"`
	Name      string `json:"pref_name"`
	MaxPhase  string `json:"max_phase,omitempty"`
	Type      string `json:"molecule_type"`
	Formula   string `json:"formula,omitempty"`
	MolWeight string `json:"mol_weight,omitempty"`
	SMILES    string `json:"smiles,omitempty" kit:"body"`
}

Molecule is the flat output record for a ChEMBL molecule.

type MoleculeProps

type MoleculeProps struct {
	Formula   string `json:"full_molformula"`
	MolWeight string `json:"full_mwt"`
}

MoleculeProps holds physico-chemical properties for a molecule.

type MoleculeStructs

type MoleculeStructs struct {
	SMILES string `json:"canonical_smiles"`
}

MoleculeStructs holds structural representations.

type PageMeta

type PageMeta struct {
	TotalCount int `json:"total_count"`
	Limit      int `json:"limit"`
	Offset     int `json:"offset"`
}

PageMeta holds pagination metadata from a list response.

type Target

type Target struct {
	ID       string `json:"target_chembl_id" kit:"id"`
	Name     string `json:"pref_name" kit:"body"`
	Type     string `json:"target_type"`
	Organism string `json:"organism"`
	TaxID    int    `json:"tax_id,omitempty"`
}

Target is a ChEMBL biological target.

Jump to

Keyboard shortcuts

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