gdc

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 gdc is the library behind the gdc command line: the HTTP client, request shaping, and the typed data models for the NCI Genomic Data Commons (GDC), which indexes cancer genomics data: 50k+ cases, 1.27M files, 3.3M mutations across 91 cancer projects.

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 BaseURL = "https://api.gdc.cancer.gov"

BaseURL is the root every request is built from.

View Source
const Host = "api.gdc.cancer.gov"

Host is the GDC API hostname this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	ID          string `json:"id"           kit:"id"`
	SubmitterID string `json:"submitter_id"`
	ProjectID   string `json:"project_id"`
	PrimarySite string `json:"primary_site"`
	DiseaseType string `json:"disease_type"`
	Age         int    `json:"age"`
	Gender      string `json:"gender"`
	Race        string `json:"race"`
}

Case is a single GDC cancer case record.

type Client

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

Client talks to the GDC REST API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using the given Config.

func (*Client) GetCase

func (c *Client) GetCase(ctx context.Context, caseID string) (*Case, error)

GetCase fetches a single case by its case_id.

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, caseID string, limit, from int) ([]File, int, error)

ListFiles lists files for a given case_id.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, limit, from int) ([]Project, int, error)

ListProjects lists all GDC cancer projects.

func (*Client) SearchCases

func (c *Client) SearchCases(ctx context.Context, keyword, site, project string, limit, from int) ([]Case, int, error)

SearchCases searches cases by keyword and optional site/project filters.

func (*Client) SearchMutations

func (c *Client) SearchMutations(ctx context.Context, geneSymbol string, limit, from int) ([]Mutation, int, error)

SearchMutations lists mutations for a gene symbol.

type Config

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

Config holds the runtime settings for the GDC client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the GDC 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). UUID-shaped inputs (contain "-" and len>30) are treated as case IDs; everything else is also classified as a case keyword search target.

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 File

type File struct {
	ID           string `json:"id"            kit:"id"`
	Name         string `json:"name"`
	DataType     string `json:"data_type"`
	DataCategory string `json:"data_category"`
	Format       string `json:"format"`
	SizeBytes    int64  `json:"size_bytes"`
	Access       string `json:"access"`
	CaseID       string `json:"case_id"`
	ProjectID    string `json:"project_id"`
}

File is a single GDC file record.

type Mutation

type Mutation struct {
	ID           string `json:"id"            kit:"id"`
	Chromosome   string `json:"chromosome"`
	StartPos     int64  `json:"start_pos"`
	EndPos       int64  `json:"end_pos"`
	RefAllele    string `json:"ref_allele"`
	TumorAllele  string `json:"tumor_allele"`
	MutationType string `json:"mutation_type"`
	GeneID       string `json:"gene_id"`
	GeneSymbol   string `json:"gene_symbol"`
}

Mutation is a single GDC somatic mutation (SSM) record.

type Project

type Project struct {
	ID          string `json:"id"           kit:"id"`
	Name        string `json:"name"`
	Program     string `json:"program"`
	PrimarySite string `json:"primary_site"`
	Cases       int    `json:"cases"`
	Files       int    `json:"files"`
}

Project is a single GDC cancer project record.

Jump to

Keyboard shortcuts

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