gwas

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 gwas is the library behind the gwas command line: the HTTP client, request shaping, and the typed data models for the NHGRI-EBI GWAS Catalog.

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 GWAS Catalog 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 GWAS Catalog REST 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) (int, error)

GetCount returns the total number of studies in the GWAS Catalog.

func (*Client) GetStudy

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

GetStudy fetches a single study by its GWAS Catalog accession ID (e.g. GCST000854).

func (*Client) SearchStudies

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

SearchStudies returns up to limit studies starting at the given page offset. It also returns the total number of studies available.

type Config

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

Config carries the tunable parameters for the GWAS Catalog client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults for the GWAS Catalog REST API.

type Count

type Count struct {
	Label string `json:"label" kit:"id"`
	Total int    `json:"total"`
}

Count holds the total number of studies in the GWAS Catalog.

type Domain

type Domain struct{}

Domain is the GWAS Catalog 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). Any non-empty string is treated as a GWAS study accession (e.g. GCST000854).

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 Study

type Study struct {
	ID            string `json:"id"                   kit:"id"` // accessionId like GCST000854
	Trait         string `json:"trait,omitempty"`
	PubMedID      string `json:"pubmed_id,omitempty"`
	Title         string `json:"title,omitempty"`
	Journal       string `json:"journal,omitempty"`
	Author        string `json:"author,omitempty"`
	Date          string `json:"date,omitempty"`
	InitialSample string `json:"initial_sample,omitempty"`
	SnpCount      int    `json:"snp_count,omitempty"`
}

Study is a single GWAS Catalog study record.

Jump to

Keyboard shortcuts

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