Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def biomart():
biomart = BioMart(host='www.ensembl.org', verbose=False)
biomart.mart_test = 'ENSEMBL_MART_ENSEMBL'
return biomart
def test_biomart_constructor():
s = BioMart()
try:
s.registry()
except:
pass
try:
s.host = "dummy"
except:
pass
s.host = "www.ensembl.org"
def _test_reactome_example():
# this is not working anymore...
s = BioMart("reactome.org")
s.lookfor("reactome")
s.datasets("REACTOME")
#['interaction', 'complex', 'reaction', 'pathway']
s.new_query()
s.add_dataset_to_xml("pathway")
s.add_filter_to_xml("species_selection", "Homo sapiens")
s.add_attribute_to_xml("pathway_db_id")
s.add_attribute_to_xml("_displayname")
xmlq = s.get_xml()
res = s.query(xmlq)
return
if database in ['Human', 'Mouse']:
database = 'Enrichr'
else:
database += 'Enrichr'
lib_url='http://amp.pharm.mssm.edu/%s/datasetStatistics'%database
response = requests.get(lib_url)
if not response.ok:
raise Exception("Error getting the Enrichr libraries")
libs_json = json.loads(response.text)
libs = [lib['libraryName'] for lib in libs_json['statistics']]
return sorted(libs)
class Biomart(BioMart):
"""query from BioMart"""
def __init__(self, host="www.ensembl.org", verbose=False):
"""A wrapper of BioMart() from bioseverices.
How to query validated dataset, attributes, filters:
example:
>>> from gseapy.parser import Biomart
>>> bm = Biomart(verbose=False, host="asia.ensembl.org")
>>> ## view validated marts
>>> marts = bm.get_marts()
>>> ## view validated dataset
>>> datasets = bm.get_datasets(mart='ENSEMBL_MART_ENSEMBL')
>>> ## view validated attributes
>>> attrs = bm.get_attributes(dataset='hsapiens_gene_ensembl')
>>> ## view validated filters
>>> filters = bm.get_filters(dataset='hsapiens_gene_ensembl')