10 my ($nodesfile,$namesfile);
11 my $idx_dir = '/tmp/idx';
12 GetOptions
('v|verbose' => \
$verbose,
13 'nodes:s' => \
$nodesfile,
14 'names:s' => \
$namesfile,
16 'h|help' => sub{ exec('perldoc',$0);
20 unless( @ARGV || $nodesfile || $namesfile ) {
24 mkdir($idx_dir) unless -d
$idx_dir;
26 my $db = new Bio
::DB
::Taxonomy
(-source
=> 'flatfile',
27 -nodesfile
=> $nodesfile,
28 -namesfile
=> $namesfile,
29 -directory
=> $idx_dir);
30 foreach my $sp ( @ARGV ) {
31 my $node = $db->get_Taxonomy_Node(-name
=> $sp);
33 print "id is ", $node->id, "\n"; # 9606
34 print "rank is ", $node->rank, "\n"; # species
35 print "scientific name is ", $node->scientific_name, "\n"; # Homo sapiens
36 print "division is ", $node->division, "\n"; # Primates
38 warn("no node found for query $sp");
44 bp_local_taxonomydb_query - query a local TaxonomyDB for species or taxonid
48 This script provides an example implementation of access to a local
49 Taxonomy database implemented with Berkeley DB (DB_File module is needed).
53 bp_local_taxonomydb_query.PLS: [-v] --nodes nodes.dmp --names names.dmp "Genus1 species1" "Genus2 species2"
55 Providing the nodes.dmp and names.dmp files from the NCBI Taxonomy
56 dump (see Bio::DB::Taxonomy::flatfile for more info) is only necessary
57 on the first time running. This will create the local indexes and may
58 take quite a long time. However once created, these indexes will
59 allow fast access for species to taxon id OR taxon id to species name