Bulk-query Ensembl BioMart for cross-database ID mapping, coordinate tables, and ortholog wide tables. Encodes: BioMart vs Ensembl REST decision (BioMart for >5K rows, REST for per-record), the mart-vs-dataset hierarchy, attribute/filter discovery, many-to-many row-multiplication when joining cross-references, R biomaRt vs Python pybiomart trade-off, and version pinning via useEnsembl(version=110).
pip install pybiomart pandas
# R alternative (more mature):
# BiocManager::install('biomaRt')
For published work, pin the Ensembl release in code.
"I have 8,000 Ensembl Gene IDs. Convert them to HGNC symbol, NCBI Entrez Gene ID, RefSeq mRNA accessions, and Swiss-Prot UniProt accessions. Use one pybiomart query against hsapiens_gene_ensembl with filters={'ensembl_gene_id': [...]}. Don't loop Ensembl REST -- that's 8,000 sequential calls."
"Pull all protein-coding genes on chromosome 17 with: ensembl_gene_id, external_gene_name, start, end, strand, biotype. One BioMart query."
"Build a wide table: for every human protein-coding gene, the mouse ortholog Ensembl ID and the zebrafish ortholog Ensembl ID, both filtered to ortholog_one2one only. Use mmusculus_homolog_ensembl_gene + drerio_homolog_ensembl_gene attributes."
"Get GO term annotations for [TP53, BRCA1, MYC, EGFR]. Returns long format -- one row per (gene, GO term)."
"I'm writing a paper. Use R biomaRt with useEnsembl(version=110) so the query reproduces in 2030. Don't use the default which follows the current release."
server.marts and mart.datasets before guessing names.attributes and filters programmatically; don't hallucinate field names.ortholog_one2one for high-confidence joins.useEnsembl(version=N) for reproducibility.ds.attributes / ds.filters -- don't guess.ensembl_gene_id or hgnc_id for stability.useEnsembl(version=110), or use archive host URL (https://nov2020.archive.ensembl.org).http://plants.ensembl.org/biomart/martservice.ENSEMBL_MART_SNP not ENSEMBL_MART_ENSEMBL.