Created
September 21, 2018 09:50
-
-
Save dbolser-ebi/1890e35cb6d1366544e1346666cfe6f5 to your computer and use it in GitHub Desktop.
Plant Reactome BioMart Perl API script for Justin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example script demonstrating the use of BioMart API. | |
# This perl API representation is only available for configuration versions >= 0.5 | |
use strict; | |
use BioMart::Initializer; | |
use BioMart::Query; | |
use BioMart::QueryRunner; | |
my $confFile = "../conf/martURLLocation.xml"; | |
my $species = shift || "bnapus"; | |
print STDERR "The other species is $species\n"; | |
# | |
# NB: change action to 'clean' if you wish to start a fresh configuration | |
# and to 'cached' if you want to skip configuration step on subsequent runs from the same registry | |
# | |
my $action='clean'; | |
#my $action='cached'; | |
my $initializer = BioMart::Initializer->new('registryFile'=>$confFile, 'action'=>$action); | |
my $registry = $initializer->getRegistry; | |
my $query = BioMart::Query->new('registry'=>$registry,'virtualSchemaName'=>'default'); | |
$query->setDataset("osativa_eg_gene"); | |
$query->addAttribute("ensembl_gene_id"); | |
$query->addAttribute("${species}_eg_homolog_ensembl_gene"); | |
$query->addAttribute("${species}_eg_homolog_perc_id"); | |
$query->addAttribute("${species}_eg_homolog_perc_id_r1"); | |
$query->addAttribute("${species}_eg_homolog_orthology_confidence"); | |
$query->formatter("TSV"); | |
my $query_runner = BioMart::QueryRunner->new(); | |
############################## GET COUNT ############################ | |
# $query->count(1); | |
# $query_runner->execute($query); | |
# print $query_runner->getCount(); | |
##################################################################### | |
############################## GET RESULTS ########################## | |
# to obtain unique rows only | |
# $query_runner->uniqueRowsOnly(1); | |
$query_runner->execute($query); | |
$query_runner->printHeader(); | |
$query_runner->printResults(); | |
$query_runner->printFooter(); | |
##################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment