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
- type Activity
- type Client
- func (c *Client) Activities(ctx context.Context, moleculeID, targetID string, limit int) ([]*Activity, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) Molecule(ctx context.Context, id string) (*Molecule, error)
- func (c *Client) SearchMolecules(ctx context.Context, q string, limit int) ([]*Molecule, error)
- func (c *Client) SearchTargets(ctx context.Context, q string, limit int) ([]*Target, error)
- func (c *Client) SetRetries(n int)
- func (c *Client) Target(ctx context.Context, id string) (*Target, error)
- type Config
- type Domain
- type Molecule
- type MoleculeProps
- type MoleculeStructs
- type PageMeta
- type Target
Constants ¶
const BaseURL = "https://www.ebi.ac.uk/chembl/api/data"
BaseURL is the root every request is built from.
const DefaultUserAgent = "chembl-cli/0.1.0 (github.com/tamnd/chembl-cli)"
DefaultUserAgent identifies the client to ChEMBL.
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 ¶
Client talks to the ChEMBL REST API over HTTP.
func NewClientWithConfig ¶
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 ¶
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) SearchMolecules ¶
SearchMolecules searches molecules by name or SMILES query.
func (*Client) SearchTargets ¶
SearchTargets searches targets by name query.
func (*Client) SetRetries ¶
SetRetries updates the number of retries (useful in tests).
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) 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 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.