Skip to main content

scibiomart

DOI PyPI

This is just a simple wrapper around the API from BioMart, but I found existing packages were not quite sufficent for what I was wanting to do i.e. cli interface and python interface with tsv API.

Here you can simply get the list of all genes and perform other biomart functions such as mapping between human and mouse.

Have a look at the docs which explains things in more detail.

Installation

pip install scibiomart

Usage

For the most simple usage, use API which will get the latest mouse and human and map gene IDs to gene names.

Examples

from scibiomart import SciBiomartApi

sb = SciBiomartApi()

# Get only the default for those genes
results_df = sb.get_mouse_default({'ensembl_gene_id': 'ENSMUSG00000029844,ENSMUSG00000032446'})

# Select attributes
results_df = sb.get_mouse_default({'ensembl_gene_id': 'ENSMUSG00000020875,ENSMUSG00000038210'},
                                     attr_list=['entrezgene_id'])
# Get all genes
results_df = sb.get_mouse_default()

# Sort the results based on TSS (takes direction into account)
results_df = sb.sort_df_on_starts(results_df)

# Get human
results_df = sb.get_human_default()

Examples extended

If you are interested in more than the simple API, see the tests for all examples, however, you can list the datasets etc, and query other attributes.

Print marts

sb = SciBiomart()
marts = sb.list_marts()
print('\n'.join(marts))

Print datasets

sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
err = sb.list_datasets()

List attributes

sb = SciBiomart()  
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_attributes()

List configs

sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_configs()

List filters

sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_filters()

Run generic query

Here we show a generic query for two genes (as a comma separated list) and the attributes we're interested in are 'ensembl_gene_id', 'hgnc_symbol', 'uniprotswissprot'.

Run query: def run_query(self, filter_dict: dict, attr_list: list): i.e. you can pass it a filter dictionary and a list of attributes. This will make it quicker, you can also run it and it will get all genes (i.e. if filter_dict is empty).

sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('hsapiens_gene_ensembl')
results = sb.run_query({'ensembl_gene_id': 'ENSG00000139618,ENSG00000091483'},
                       ['ensembl_gene_id', 'hgnc_symbol', 'uniprotswissprot'])
print(results)

Match mouse to human

Get mouse orthologs for human genes

sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('hsapiens_gene_ensembl')
attributes = ['ensembl_gene_id', 'mmusculus_homolog_ensembl_gene', 'mmusculus_homolog_perc_id_r1']
results = sb.run_query({'ensembl_gene_id': 'ENSG00000139618,ENSG00000091483'},  attributes)
print(results)

See docs for more info

Metadata

Release files for scibiomart 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scibiomart 1.0.2
File Size Uploaded Provenance Actions
scibiomart-1.0.2.tar.gz 22.2 kB Without provenance Details for scibiomart-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scibiomart 1.0.2
File Interpreter ABI Platform Actions
scibiomart-1.0.2-py3-none-any.whl Python 3 none any Details for scibiomart-1.0.2-py3-none-any.whl

Total release size: 61.9 kB

Release files / scibiomart-1.0.2.tar.gz

Download URL scibiomart-1.0.2.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
36ff33648ed6fe1bbb2eb7aae9cd537fed6c543a713574e0baf02ec1e48039ea
BLAKE2b-256 checksum
How to use checksums
ba2c110ab6b539046ca1a2a3fa759ca6f956de633f8af5129242b8dda864ef12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / scibiomart-1.0.2-py3-none-any.whl

Download URL scibiomart-1.0.2-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd46aa3985c9e82e075811b3e023ae255c5f488be3a9dace970b9904ad15b276
BLAKE2b-256 checksum
How to use checksums
491480e321f02acee1558782de43867fc8c8ab4c0a083b2ce5a2401c6858011c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Security for scibiomart 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page