Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Queries the UCSC Genome Browser REST API for DNA sequences, annotation tracks, gene models, chromosome sizes, and conservation scores.
77% 95%+18 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 17 of 22 without it.
Write a Python function to retrieve all chromosome lengths for assembly hg38 using the UCSC REST API to establish chromosome boundary limits.
The code extracts chromosome lengths from the chromosomeSizes key in the JSON response.
3 of 3 safety checks passed
The UCSC Genome Browser REST API at https://api.genome.ucsc.edu/ provides programmatic access to genome sequences, annotation tracks, and hub data for 100+ assemblies including hg38, mm39, and dm6. The API is free, requires no authentication, and returns JSON. Use it with the requests library to fetch DNA sequences for genomic regions, retrieve track data (genes, repeats, conservation), list available tracks, and query chromosome sizes for genome-scale coordinate arithmetic.
ensembl-database instead when you need Ensembl stable IDs, VEP variant annotation, or cross-species comparative genomics via the Ensembl REST APIbedtools-genomic-intervals with pre-downloaded UCSC annotation filesrequests, matplotlib (for visualization)hg38, mm39)pip install requests matplotlib
import requests
BASE = "https://api.genome.ucsc.edu"
def get_sequence(genome, chrom, start, end):
"""Fetch DNA sequence for a genomic region (0-based, half-open)."""
r = requests.get(f"{BASE}/getData/sequence",
params={"genome": genome, "chrom": chrom,
"start": start, "end": end})
Next to this one in the catalogue, plus more from the same author.