error while using plant ensembl biomart

error while using plant ensembl biomart

2

Hi,
I am trying to extract gene ontology term from plant ensembl biomart using the following code:

from pybiomart import Server
server = Server(host="http://plants.ensembl.org")
#print server.list_marts() # available marts



mart = server['plants_mart'] # connecting   plants_mart 
  #print mart.list_datasets() # print available datasets

dataset = mart['zmays_eg_gene']

print dataset.query(attributes=['go'], filters={"transcript_id": ['Zm00001d000475_T001']})

but I have this error:

pybiomart.base.BiomartException: Query ERROR: caught BioMart::Exception::Usage: WITHIN Virtual Schema : default, Dataset zmays_eg_gene NOT FOUND

even though 'zmays_eg_gene was listed in mart.list_datasets()


software error


gene


ensembl


biomart

• 1.4k views

Hi, I don’t know what’s going on there, but you can install the bioconductor package biomaRt and then run the following commands.

library(biomaRt)
host="plants.ensembl.org"
mysets<-listDatasets(useMart("plants_mart", host = host))
myusemart <- useDataset("zmays_eg_gene", mart = useMart("plants_mart", host = host))
resultTable <- getBM(attributes=c("ensembl_gene_id","chromosome_name","start_position","end_position","go_id","goslim_goa_accession"), mart = myusemart)

The attributes of getBM can be changed (I usually get go and goslim), and then you can just use the write.table function to save the file if you want to get rid of R and work back in python.

In pybiomart even though you give the host as ”plants.ensembl.org” the virtual schema is set to default. that’s the reason why you can find any ”zmays_eg_gene”.
I’m not sure whether you can change the virtual schema in pybiomart but you can do the same using bioservices package in python

from bioservices import BioMart as biomart 
s = biomart('plants.ensembl.org')
services = [x for x in s.registry()]
pd.DataFrame(services)
dataset="zmays_eg_gene"
filt="transcript_id"
s.new_query()
s.add_dataset_to_xml(dataset)
s.add_filter_to_xml(filt, value="Zm00001d000475_T001")
s.add_attribute_to_xml('go')
xmlq = s.get_xml()
print(xmlq)
xmlq = xmlq.replace('virtualSchemaName = "default"',
    'virtualSchemaName = "plants_mart"')
print(xmlq)
res = s.query(xmlq)
print(res)


Login
before adding your answer.

Traffic: 2343 users visited in the last hour

Read more here: Source link