ena

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 ena is the library behind the ena command line: the HTTP client, request shaping, and the typed data models for the EMBL-EBI European Nucleotide Archive (ENA).

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 = "www.ebi.ac.uk"

Host is the ENA portal host, used for URI resolution and the domain Hosts list.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the ENA Portal API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with the default config.

func NewClientWithConfig

func NewClientWithConfig(cfg Config) *Client

NewClientWithConfig returns a Client using the given config.

func (*Client) Get

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

Get fetches rawURL and returns the response body, pacing and retrying.

func (*Client) GetCount

func (c *Client) GetCount(ctx context.Context, resultType string) (int, error)

GetCount returns the total record count for a result type (study, sequence, read_run, sample, …). The /count endpoint returns plain text: first line is "count", second line is the integer.

func (*Client) GetStudy

func (c *Client) GetStudy(ctx context.Context, accession string) (*Study, error)

GetStudy fetches a single study by accession (e.g. PRJNA449226, ERP000958).

func (*Client) SearchSequences

func (c *Client) SearchSequences(ctx context.Context, query string, limit, offset int) ([]*Sequence, error)

SearchSequences searches ENA sequences and returns up to limit records starting at offset.

func (*Client) SearchStudies

func (c *Client) SearchStudies(ctx context.Context, query string, limit, offset int) ([]*Study, error)

SearchStudies searches ENA studies and returns up to limit records starting at offset.

type Config

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

Config carries the tunable parameters for the ENA client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults for the ENA Portal API.

type Domain

type Domain struct{}

Domain is the ENA 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). ENA study accessions start with PRJNA, ERP, SRP, DRP, or similar prefixes. Any non-empty string is treated as a study accession.

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 Sequence

type Sequence struct {
	ID          string `json:"id"          kit:"id"` // accession
	Description string `json:"description,omitempty"`
	MolType     string `json:"mol_type,omitempty"`
	Length      string `json:"length,omitempty"`
	Organism    string `json:"organism,omitempty"`
	TaxID       string `json:"tax_id,omitempty"`
}

Sequence is a single ENA sequence record.

type Stat

type Stat struct {
	Type  string `json:"type"  kit:"id"`
	Count int    `json:"count"`
}

Stat is one row in the stats output.

type Study

type Study struct {
	ID              string `json:"id"                        kit:"id"` // study_accession
	Title           string `json:"title"`
	Description     string `json:"description,omitempty"`
	StudyType       string `json:"study_type,omitempty"`
	TaxID           string `json:"tax_id,omitempty"`
	Organism        string `json:"organism,omitempty"`
	FirstPublic     string `json:"first_public,omitempty"`
	LastUpdated     string `json:"last_updated,omitempty"`
	SecondaryAccess string `json:"secondary_accession,omitempty"`
}

Study is a single ENA study record.

Jump to

Keyboard shortcuts

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