Skip to main content

No project description provided

Project description


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.

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


pip install scibiomart


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


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'},
# 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 datasets

sb = SciBiomart()
err = sb.list_datasets()

List attributes

sb = SciBiomart()  
err = sb.list_attributes()

List configs

sb = SciBiomart()
err = sb.list_configs()

List filters

sb = SciBiomart()
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()
results = sb.run_query({'ensembl_gene_id': 'ENSG00000139618,ENSG00000091483'},
                       ['ensembl_gene_id', 'hgnc_symbol', 'uniprotswissprot'])

Match mouse to human

Get mouse orthologs for human genes

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

See tests for more examples.

Biomart information below


Martservices usage:

(a) Querying BioMart

To submit a query using our webservices generate an XML document conforming to our Query XML syntax. This can be achieved simply by building up your query using MartView and hitting the XML button. This XML should be posted to attached to a single parameter of query. For example you could either:

  • submit using wget replacing MY_XML with the XML obtained above, first removing any new lines.
wget -O results.txt '' 

(b) Retrieving Meta Data:

  • to retrieve registry information:
  • to retrieve datasets available for a mart:
  • to retrieve attributes available for a dataset:
  • to retrieve filters available for a dataset:
  • to retrieve configuration for a dataset:

More documentation at: [[]]

At the time of writing this the version of biomart was 0.7.</Query><Query virtualSchemaName = "default" formatter = "TSV" header = "0" uniqueRows = "0" count = "" datasetConfigVersion = "0.6" ><Dataset name = "hsapiens_gene_ensembl" interface = "default" ><Filter name = "ensembl_gene_id" value = "ENSG00000139618,ENSG00000091483"/><Attribute name = "ensembl_gene_id" /></Dataset></Query><Query virtualSchemaName = "default" formatter = "TSV" header = "0" uniqueRows = "0" count = "" datasetConfigVersion = "0.6" ><Dataset name = "hsapiens_gene_ensembl" interface = "default" >< Filter name = "ensembl_gene_id" value = "ENSG00000139618,ENSG00000091483" /><Attribute name = "ensembl_gene_id" /><Attribute name = "hgnc_symbol" /><Attribute name = "uniprotswissprot" /></Dataset></Query>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for scibiomart, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size scibiomart-1.0.0-py3-none-any.whl (40.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size scibiomart-1.0.0.tar.gz (22.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page