encode

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

Documentation

Overview

Package encode is the library behind the encode command line: the HTTP client, request shaping, and the typed data models for the ENCODE (Encyclopedia of DNA Elements) Project.

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. Build your endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

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

DefaultUserAgent identifies the client to the ENCODE portal.

View Source
const Host = "www.encodeproject.org"

Host is the ENCODE portal 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 the ENCODE portal over HTTPS.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using the given Config.

func (*Client) GetExperiment

func (c *Client) GetExperiment(ctx context.Context, accession string) (*Experiment, error)

GetExperiment fetches a single ENCODE experiment by its accession (e.g. ENCSR961MEG). The portal auto-redirects /<accession>?format=json to the canonical path.

func (*Client) SearchExperiments

func (c *Client) SearchExperiments(ctx context.Context, assayType, status string, limit int) ([]*Experiment, int, error)

SearchExperiments searches ENCODE for experiment records. assayType filters by assay title (e.g. "Hi-C", "ChIP-seq"); status filters by release status. Returns the matching experiments, the total hit count, and any error.

func (*Client) SearchFiles

func (c *Client) SearchFiles(ctx context.Context, fileType string, limit int) ([]*File, int, error)

SearchFiles searches ENCODE for file records. fileType filters by file type (e.g. "bam", "fastq", "bigwig"). Returns the matching files, total count, and any error.

type Config

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

Config holds the runtime settings for the ENCODE client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults: 400ms rate limit, 3 retries, and a 30s timeout — staying well within ENCODE's request limits.

type Domain

type Domain struct{}

Domain is the ENCODE 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). Any non-empty string maps to ("experiment", input).

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.

type Experiment

type Experiment struct {
	ID         string `json:"id"                    kit:"id"`
	Accession  string `json:"accession"`
	AssayTitle string `json:"assay_title,omitempty"`
	Biosample  string `json:"biosample,omitempty"`
	Status     string `json:"status,omitempty"`
	Released   string `json:"date_released,omitempty"`
}

Experiment is a single ENCODE experiment record.

type File

type File struct {
	ID         string `json:"id"               kit:"id"`
	Accession  string `json:"accession"`
	FileType   string `json:"file_type,omitempty"`
	OutputType string `json:"output_type,omitempty"`
	FileSize   int64  `json:"file_size,omitempty"`
	Status     string `json:"status,omitempty"`
}

File is a single ENCODE file record.

Jump to

Keyboard shortcuts

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