myvariant

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

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 DefaultUserAgent = "myvariant-cli/0.1.0 (+https://github.com/tamnd/myvariant-cli)"

DefaultUserAgent identifies the client to MyVariant.info.

View Source
const Host = "myvariant.info"

Host is the site 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 {
	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 MyVariant.info over HTTP.

func NewClient

func NewClient() *Client

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

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.

func (*Client) GetVariant

func (c *Client) GetVariant(ctx context.Context, variantID string, assembly string) (*Variant, error)

GetVariant fetches a single variant by HGVS id or rsID.

func (*Client) SearchVariants

func (c *Client) SearchVariants(ctx context.Context, query string, limit int, assembly string) ([]*Variant, int, error)

SearchVariants searches for variants matching query. Returns the matching variants, the total count, and any error.

type Domain

type Domain struct{}

Domain is the myvariant 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).

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 Variant

type Variant struct {
	ID        string  `json:"id"                             kit:"id"`
	RsID      string  `json:"rsid,omitempty"`
	ClinSig   string  `json:"clinical_significance,omitempty"`
	CADD      float64 `json:"cadd_phred,omitempty"`
	GnomadAF  float64 `json:"gnomad_af,omitempty"`
	Gene      string  `json:"gene,omitempty"`
	ClinVarID int     `json:"clinvar_id,omitempty"`
}

Variant is a single annotated genetic variant from MyVariant.info.

Jump to

Keyboard shortcuts

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