geo

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 geo is the library behind the geo command line: the HTTP client, request shaping, and the typed data models for NCBI GEO.

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 Host = "eutils.ncbi.nlm.nih.gov"

Host is the eUtils hostname this client talks to, and the host the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to NCBI eUtils for GEO DataSets records.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using the given Config.

func (*Client) FetchDatasets

func (c *Client) FetchDatasets(ctx context.Context, ids []string) ([]*Dataset, error)

FetchDatasets fetches dataset details for the given IDs (up to ~500 per call; callers should batch if needed).

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, uid string) (*Dataset, error)

GetDataset fetches a single dataset by its GEO numeric UID.

func (*Client) Search

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

Search searches GEO DataSets for records matching the query and returns IDs and the total hit count.

func (*Client) SearchAndFetch

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

SearchAndFetch searches GEO DataSets and returns full Dataset records.

type Config

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

Config holds the runtime settings for the GEO client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults: 400ms rate limit, 3 retries, and a 30s timeout.

type Dataset

type Dataset struct {
	ID            string   `json:"id"                  kit:"id"`
	Accession     string   `json:"accession"`
	Title         string   `json:"title"`
	Summary       string   `json:"summary,omitempty"`
	Type          string   `json:"type,omitempty"`
	Platform      string   `json:"platform,omitempty"`
	PlatformTitle string   `json:"platform_title,omitempty"`
	Organism      string   `json:"organism,omitempty"`
	SampleCount   string   `json:"sample_count,omitempty"`
	PubMedIDs     []string `json:"pubmed_ids,omitempty"`
	EntryType     string   `json:"entry_type,omitempty"`
	Date          string   `json:"date,omitempty"`
	FTPLink       string   `json:"ftp_link,omitempty"`
}

Dataset is a single GEO DataSets record.

type Domain

type Domain struct{}

Domain is the GEO 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) (string, string, error)

Classify turns any accepted input into the canonical (type, id). All-digit strings are GEO numeric UIDs; GSE/GDS/GPL/GSM-prefixed strings are GEO accessions — both map to the "dataset" type.

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(t, 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.

Jump to

Keyboard shortcuts

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