gget

repository·main·Indexed 20 days ago

https://github.com/scverse/gget

A command-line tool and Python package for efficient, single-line querying of genomic databases including Ensembl, PDB, NCBI Virus, cellxgene, Bgee, and ARCHS4. It provides functionality for retrieving gene specificity statistics and expression values from 8cubeDB, performing BLAST searches, predicting protein structures via AlphaFold2, and fetching orthology data.

Tokens
60.4K
Snippets
147
Records
226
Agent score
77%

What's inside gget

  1. Overview of gget modules

    main

    gget is a collection of interoperable modules designed for efficient querying of genomic databases. Each module is intended to facilitate a specific type of query in a single line of code, either via the Python API or the command-line interface.

    Core modules include:

    • Expression & Tissue: 8cube (mouse strain/tissue expression), archs4 (gene expression in specific tissues), cbio (cancer expression), cellxgene (single-cell RNA seq matrices).
    • Sequence Analysis: blast (BLAST sequences), blat (genomic location of sequences), diamond (amino acid alignment), muscle (multiple sequence alignment), mutate (sequence mutation), seq (fetch gene sequences), virus (viral sequences).
    • Genomic & Protein Data: bgee (orthologs), elm (protein domains/functions), g2p (structural/functional annotations), info (Ensembl ID info), opentargets (disease/drug associations), pdb (Protein Data Bank data), ref (Ensembl reference genomes).
    • Search & Enrichment: cosmic (cancer associations), enrichr (gene list enrichment), search (find Ensembl IDs by keyword).
  2. Software that depends on gget

    main

    The following software projects and frameworks utilize gget for genomics queries, bioinformatics analysis, or as a core dependency:

    • gget-mcp: An MCP server providing a bioinformatics toolkit for genomics queries.
    • PantheonOS: A multi-agent biological agent system (Stanford) that uses gget for database access (Ensembl, etc.).
    • Biomni: A General-Purpose Biomedical AI Scientist.
    • SCIENCECLAW + INFINITE: A framework for autonomous scientific investigation (MIT).
    • PerTurboAgent: A self-planning agent for Perturb-seq experiments.
    • Scientific skills for Claude: A repository of scientific skills including bioinformatics/genomics tools like gget.
    • Therapeutics Data Commons (TDC): An AI foundation for therapeutic science.
    • BioDiscoveryAgent: An LLM-based AI agent for genetic perturbation experiments.
    • DeepChopper: A tool for identifying chimeric reads in NanoPore sequencing.
    • BRAD: An LLM-powered bioinformatics chatbot.
    • scPRINT: A transformer model for inferring gene networks from scRNAseq data.
    • AnoPrimer: A Python package for primer design in An. gambiae and An. funestus.
    • AvaTaR: An LLM agent optimizer for tool-assisted knowledge retrieval.
    • GRLDrugProp: Graph representation learning for drug properties.
    • MicrobioLink2: A tool for analyzing host-microbe interactions.
    • ggetrs: A Rust implementation of gget.

    Other notable projects include getbio, AchillesPrediction, cancermuts, SNPrimer, and various LLM-based bioinformatics agents.

  3. Set up gget specialized modules (ELM and cellxgene)

    main

    Some gget features require a one-time setup to download necessary resources or dependencies.

    Eukaryotic Linear Motifs (ELM):

    1. Run gget.setup("elm") (CLI: gget setup elm).
    2. Use gget.elm(sequence) to find motifs.

    cellxgene (scRNAseq matrices):

    1. Run gget.setup("cellxgene") (CLI: gget setup cellxgene).
    2. Use gget.cellxgene(gene=..., tissue=..., cell_type=...) to fetch AnnData formatted matrices.
    import gget
    
    # Setup for ELM
    gget.setup("elm")
    ortho_df, regex_df = gget.elm("MSSSSWLLLSLVAVTAAQSTIEEQAKTFLDKFNHEAEDLFYQSSLAS")
    
    # Setup for cellxgene
    gget.setup("cellxgene")
    gget.cellxgene(gene = ["ACE2", "SLC5A1"], tissue = "lung", cell_type = "mucus secreting cell")
  4. Interpret OpenTargets disease scores and IDs

    main

    When using the diseases resource:

    • score: This is OpenTargets' overall target–disease association score (0 to 1). It is an aggregate value across all data types and sources, not a per-source score.
    • disease.id: These are EFO ontology IDs. They are not exclusively diseases; they can include MONDO disease terms (MONDO_*), Human Phenotype Ontology phenotypes (HP_*), Orphanet rare diseases (Orphanet_*), or EFO measurements/traits (EFO_*).
    • Filtering for diseases: To keep only MONDO disease terms in a Python DataFrame, use: df[df['disease.id'].str.startswith('MONDO')].
  5. Understand OpenTargets expression data changes (v0.30.8+)

    main

    As of gget v0.30.8, the expression resource has changed due to OpenTargets API updates. It no longer returns the old target.expressions field. Instead, it returns baselineExpression data.

    Key Changes:

    • Output Format: Results are now per-biosample (tissue and/or cell type) rather than per-tissue.
    • Columns: Results include summary statistics (median, min, q1, q3, max, unit) and identifiers (tissueBiosample.* / celltypeBiosample.*, datasourceId, datatypeId).
    • Scale: A gene can have thousands of biosamples. OpenTargets returns at most 3000 per request. If your gene exceeds this, use --filters (e.g., datasourceId or datatypeId) or --limit to narrow the results.
  6. Use gget in Python

    main

    To use gget in a Python environment (such as a script, Jupyter Lab, or Google Colab), simply import the package.

    import gget
    import gget
  7. Setup gget for cellxgene

    main

    Before using the cellxgene functionality for the first time, you must perform a one-time setup. This can be done via the command line or within a Python script.

    Command line:

    # Run this once before your first use
    # Note: Refer to the main 'gget setup' documentation for full details
    # This is the equivalent of the Python call below

    Python:

    import gget
    # Run this once before your first use
    # Note: Refer to the main 'gget setup' documentation for full details
    # This is the equivalent of the command line call below
    gget.setup("cellxgene")
  8. Compare AlphaFold predictions with PDB structures

    main

    To assess the quality of a gget alphafold prediction, you can perform a comparative analysis by finding similar sequences in the PDB and fetching their structures.

    1. Find similar sequences: Use gget blast with the pdbaa database to find sequences deposited in the PDB that match your target.
    2. Fetch PDB files: Use gget pdb to download the structures of those similar sequences for comparison.

    Example Workflow:

    # 1. Find similar sequences
    gget blast --database pdbaa MAAHKGAEHHHKAAEHHEQAAKHHHAAAEHHEKGEHEQAAHHADTAYAHHKHAEEHAAQAAKHDAEHHAPKPH
    
    # 2. Fetch PDB files for comparison (e.g., IDs 3UQ3 and 2K42)
    gget pdb 3UQ3 -o 3UQ3.pdb
    gget pdb 2K42 -o 2K42.pdb
    # 1. Find similar sequences
    import gget
    gget.blast("MAAHKGAEHHHKAAEHHEQAAKHHHAAAEHHEKGEHEQAAHHADTAYAHHKHAEEHAAQAAKHDAEHHAPKPH", database="pdbaa")
    
    # 2. Fetch PDB files
    gget.pdb("3UQ3", save=True)
    gget.pdb("2K42", save=True)
    # CLI workflow
    # Find similar sequences
    gget blast --database pdbaa MAAHKGAEHHHKAAEHHEQAAKHHHAAAEHHEKGEHEQAAHHADTAYAHHKHAEEHAAQAAKHDAEHHAPKPH
    
    # Fetch PDB files
    gget pdb 3UQ3 -o 3UQ3.pdb
  9. Download COSMIC databases with gget

    main

    To use COSMIC data, you must first download a database. This process requires a COSMIC account and will prompt for your email and password. The download is typically performed once per project.

    CLI Usage: Use the --download_cosmic flag along with --cosmic_project to specify which dataset to fetch.

    Python Usage: Call gget.cosmic() with download_cosmic=True and searchterm=None.

    Available cosmic_project options:

    • cancer: Cancer Mutation Census (CMC). Most feature-rich, only available for GRCh37. (~2 GB)
    • cancer_example: Minimal subset for testing. No COSMIC account required. (~2.5 MB)
    • census: Curated somatic mutations in known cancer drivers. (~630 MB)
    • resistance: Mutations associated with drug resistance. (~1.6 MB)
    • cell_line: Cell Lines Project mutation data. (~2.7 GB)
    • genome_screen: Mutations from genome screening efforts.
    • targeted_screen: Focused panel datasets.

    Authentication: You can provide --email and --password (CLI) or email and password (Python) to avoid interactive prompts, but note that providing a password in a script stores it in plain text.

    # Download the 'cancer' project via CLI
    # This will prompt for COSMIC credentials
    gget cosmic --download_cosmic --cosmic_project cancer
    # Download the 'cancer' project via Python
    import gget
    # Set searchterm to None when downloading
    gget.cosmic(searchterm=None, download_cosmic=True, cosmic_project="cancer")
  10. Install gget

    main

    You can install gget using pip or uv. For development, you can also install it from the source repository.

    Using pip:

    pip install --upgrade gget

    Using uv:

    uv pip install gget

    From source:

    git clone https://github.com/scverse/gget.git
    cd gget
    uv pip install .
    pip install --upgrade gget
  11. Search for genes and transcripts with `gget search`

    main

    Use gget search to fetch genes or transcripts from Ensembl using free-form search terms. The search matches terms against the "gene name", "description", and (in version >= 0.27.9) the "synonym" sections of the Ensembl database.

    Command Line Usage: Results are returned as JSON by default. Use the -csv flag to return CSV format.

    Python Usage: Results are returned as a data frame by default. Use json=True to return JSON format.

    # CLI example
    # Search for genes related to 'gaba' or 'gamma-aminobutyric' in humans
    gget search -s human gaba gamma-aminobutyric
    # Python example
    import gget
    # Returns a data frame of results
    results = gget.search(["gaba", "gamma-aminobutyric"], "homo_sapiens")