Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def datasets(self, mart, raw=False):
"""to retrieve datasets available for a mart:
:param str mart: e.g. ensembl. see :attr:`names` for a list of valid
MART names the mart is the database. see lookfor method or
databases attributes
>>> s = BioMart(verbose=False)
>>> s.datasets("prod-intermart_1")
['protein', 'entry', 'uniparc']
"""
if mart not in self.names:
raise BioServicesError("Provided mart name (%s) is not valid. see 'names' attribute" % mart)
ret = self.http_get("?type=datasets&mart=%s" %mart, frmt="txt")
if raw is False:
try:
ret2 = [x.split("\t") for x in ret.split("\n") if len(x.strip())]
ret = [x[1] for x in ret2]
except:
ret = ["?"]
return ret
def show_pie(self):
"""a simple example to demonstrate how to visualise number of
interactions found in various databases
"""
try:
from pylab import pie, clf, title, show, legend
except ImportError:
from bioservices import BioServicesError
raise BioServicesError("You must install pylab/matplotlib to use this functionality")
labels = range(1, self.N + 1)
print(labels)
counting = [len(self.relevant_interactions[i]) for i in labels]
clf()
#pie(counting, labels=[str(int(x)) for x in labels], shadow=True)
pie(counting, labels=[str(x) for x in counting], shadow=True)
title("Number of interactions found in N databases")
legend([str(x) + " database(s)" for x in labels])
show()
def create_filter(self, name, value, dataset=None):
if dataset:
valid_filters = self.filters(dataset).keys()
if name not in valid_filters:
raise BioServicesError("Invalid filter name. ")
_filter = ''
if '=' in value:
_filter = """
def create_attribute(self, name, dataset=None):
#s.attributes(dataset)
# valid dataset
if dataset:
valid_attributes = self.attributes(dataset).keys()
if name not in valid_attributes:
raise BioServicesError("Invalid attribute name. ")
attrib = """ """ % name
return attrib
def get_xml(self):
if self.dataset is None:
raise BioServicesError("data set must be set. Use add_dataset method")
xml = self.header
xml += self.dataset + "\n\n"
for line in self.filters:
xml += line +"\n"
for line in self.attributes:
xml += line + "\n"
xml += self.footer
return xml