source: orange-bioinformatics/docs/modules/obiBioMart-query.py @ 1623:186d828e3699

Revision 1623:186d828e3699, 1.3 KB checked in by mitar, 2 years ago (diff)

Renamed documentation directory.

Line 
1from obiBioMart import *
2
3## Printing attribute configurations
4
5connection = BioMartConnection("http://www.biomart.org/biomart/martservice")
6registry = connection.registry()
7#for schema in registry.virtual_schemas()[:1]:
8#    for database in schema.marts()[:1]:
9#        for dataset in database.datasets()[:2]:
10#            for attrTree in dataset.configuration().attributes():
11#                if not getattr(attrTree, "hidden", "false") == "true":
12#                    print dataset.name, "has attribute", getattr(attrTree, "displayName", "<unknown>")
13                   
14## Printing dataset attributes
15
16database = registry["ensembl"]
17dataset = database["hsapiens_gene_ensembl"]
18
19for attr in dataset.attributes():
20    print attr
21
22for filter in dataset.filters():
23    print filter
24                   
25query = BioMartQuery(connection, dataset="hsapiens_gene_ensembl", attributes=["ensembl_transcript_id", "chromosome_name"], 
26                     filters=[("chromosome_name", ["22"])])
27print query.get_count()
28
29print query.run()
30
31query = BioMartQuery(connection)
32query.set_dataset("hsapiens_gene_ensembl")
33query.add_filter("chromosome_name", ["22"])
34query.add_attribute("ensembl_transcript_id")
35query.add_attribute("chromosome_name")
36query.add_attribute("uniprot_swissprot")
37print query.get_count()
38print query.run()
Note: See TracBrowser for help on using the repository browser.