allenbrain

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: 11 Imported by: 0

Documentation

Overview

Package allenbrain is the library behind the allenbrain command line: the HTTP client, request shaping, and typed data models for the Allen Brain Atlas public API (api.brain-map.org/api/v2).

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 = "http://api.brain-map.org/api/v2"

BaseURL is the root every request is built from.

View Source
const BrainURL = "https://mouse.brain-map.org"

BrainURL is the human-facing site URL for gene pages.

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

DefaultUserAgent identifies the client to Allen Brain Atlas.

View Source
const Host = "api.brain-map.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atlas

type Atlas struct {
	ID        int    `json:"id" kit:"id"`
	Name      string `json:"name"`
	ImageType string `json:"image_type,omitempty"`
}

Atlas is one reference atlas from the Allen Brain Atlas.

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 Allen Brain Atlas API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults: a 15s timeout, a 300ms minimum gap between requests, and three retries on transient errors.

func (*Client) Atlases

func (c *Client) Atlases(ctx context.Context) ([]Atlas, error)

Atlases lists all reference atlases.

func (*Client) Datasets

func (c *Client) Datasets(ctx context.Context, limit, start int) ([]Dataset, error)

Datasets lists section datasets with pagination.

func (*Client) Genes

func (c *Client) Genes(ctx context.Context, limit, start int) ([]Gene, error)

Genes lists genes with pagination.

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 settings. The caller owns nothing extra; the body is read fully and closed here.

func (*Client) SearchGenes

func (c *Client) SearchGenes(ctx context.Context, query string, limit int) ([]Gene, error)

SearchGenes searches genes by name using the criteria filter.

type Dataset

type Dataset struct {
	ID           int    `json:"id" kit:"id"`
	PlaneSection int    `json:"plane_section_id,omitempty"`
	Genes        []Gene `json:"genes,omitempty"`
}

Dataset is one section dataset from the Allen Brain Atlas.

type Domain

type Domain struct{}

Domain is the Allen Brain Atlas 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) pair, so `ant resolve` and `ant url` touch no network.

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 human-facing 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 Gene

type Gene struct {
	ID       int    `json:"id" kit:"id"`
	Acronym  string `json:"acronym"`
	Name     string `json:"name"`
	EntrezID int    `json:"entrez_id,omitempty"`
}

Gene is one gene entry from the Allen Brain Atlas.

Jump to

Keyboard shortcuts

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