Hi Drake,
there is one change that you need to get this working and that is to
point the $conf variable to a local file:
my $confFile = "conf/apiExampleRegistry.xml";
Additionally, for perl API to work, you need biomart-perl downloaded
with API dependencies installed. See instructions here:
http://www.biomart.org/install-overview.html
There is an example (apiExample.pl) of perl script under
biomart-perl/scripts/
Furthermore, since you are querying ensembl mouse dataset, i have
attached an example registry file that you cant drop into
biomart-perl/conf/ and point the $conf variable to this file in your script.
Hope this helps, let us know if you have any questions.
Syed
On 10/02/2011 19:14, Drake Evans wrote:
Hi my name is Andrew Evans and I work at a lab at Vanderbilt University and
we're trying to use Biomart to query databases for gene data. However, I have
been unable to run the queries effectively and I was hoping you could help.
I want to be able to query the Biomart Central portal without using the Web Interface
manually. I have been able to generate queries in Perl and XML format via the
Martview at biomart.org<http://biomart.org>.
When I try to run this perl script:
# 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 = "http://www.biomart.org/biomart/martservice?type=registry";
#
# 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 $initializer = BioMart::Initializer->new('registryFile'=>$confFile,
'action'=>$action);
my $registry = $initializer->getRegistry;
my $query =
BioMart::Query->new('registry'=>$registry,'virtualSchemaName'=>'default');
$query->setDataset("mmusculus_gene_ensembl");
$query->addFilter("refseq_dna",
["NM_016894","NM_177410","NM_145506","NM_001114662","NM_001159649","NM_026500","NM_178052","NM_001111316","NM_011210","NM_001039511","NM_001039512","NM_054102","NM_172843","NM_022329","NM_138314","NM_178071","NM_001113391","NM_001160262"]);
$query->addAttribute("ensembl_gene_id");
$query->addAttribute("ensembl_transcript_id");
$query->addAttribute("external_gene_id");
$query->addAttribute("name_1006");
$query->addAttribute("go_cellular_component__dm_name_1006");
$query->addAttribute("go_molecular_function__dm_name_1006");
$query->addAttribute("refseq_dna");
$query->addAttribute("refseq_peptide");
$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();
#####################################################################
I get this message:
Can't locate BioMart/Initializer.pm in @INC (@INC contains:
/Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0
/System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0
/Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0
/Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.10.0 .) at query.pl<http://query.pl> line 4.
BEGIN failed--compilation aborted at query.pl<http://query.pl> line 4.
When i try to run wget -O results.txt
'http://www.biomart.org/biomart/martservice?query=Query.xml using query.xml i
created from Martview this is the results.txt:
Query ERROR: caught BioMart::Exception: non-BioMart die(): File does not exist:
Query.xml at
/srv/biomart_server/biomart.org/biomart-perl/lib/BioMart/Query.pm<http://biomart.org/biomart-perl/lib/BioMart/Query.pm>
line 1935
When I try to run the Webexample.pl from the scripts directory using the xml I
got from martview (saved as query.xml) the terminal window says:
Usage: perl webExample.pl Query.xml
and there is no results.txt file.
Not sure If maybe I installed the Biomart-Perl API wrong or if I am not
configuring my perl or xml files correctly. Any help would be greatly
appreciated.
Thanks
Andrew Evans
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MartRegistry>
<MartRegistry>
<MartDBLocation databaseType="mysql" host="martdb.ensembl.org" database="ensembl_mart_61" name="ensembl" displayName="ENSEMBL 61 GENE (SANGER UK)" port="5316" schema="ensembl_mart_61" user="anonymous" password="" visible="1" default="1" martUser="" includeDatasets="" />
<MartDBLocation databaseType="mysql" host="martdb.ensembl.org" database="ontology_mart_61" name="ontology" displayName="ENSEMBL 61 ONTOLOGY (SANGER UK)" port="5316" schema="ontology_mart_61" user="anonymous" password="" visible="0" default="1" martUser="" includeDatasets="" />
<MartDBLocation databaseType="mysql" host="martdb.ensembl.org" database="genomic_features_mart_61" name="gen_features" displayName="ENSEMBL 61 GENOMIC FEATURES (SANGER UK)" port="5316" schema="genomic_features_mart_61" user="anonymous" password="" visible="0" default="1" martUser="" includeDatasets="" />
<MartDBLocation databaseType="mysql" host="martdb.ensembl.org" database="sequence_mart_61" name="seq" displayName="ENSEMBL 61 SEQ (SANGER UK)" port="5316" schema="sequence_mart_61" user="anonymous" password="" visible="061" default="1" martUser="" includeDatasets="" />
<MartDBLocation databaseType="mysql" host="martdb.ensembl.org" database="snp_mart_61" name="snp" displayName="ENSEMBL 61 SNP (SANGER UK)" port="5316" schema="snp_mart_61" user="anonymous" password="" visible="1" default="1" martUser="" includeDatasets="" />
</MartRegistry>
_______________________________________________
Users mailing list
[email protected]
https://lists.biomart.org/mailman/listinfo/users