[Bioperl-l] Bio::DB::Taxonomy and each_Descendent

Jason Stajich jason at bioperl.org
Mon Sep 20 15:38:36 UTC 2010


This works for me to get all the descendents from sub-node. You have to 
call the function with the dabatase handle.   I am not sure if the Taxon 
implementation has reference to the dbhandle or not:
#!/usr/bin/perl -w
use strict;
use Bio::DB::Taxonomy;
my $dbdir = '/db/taxonomy/ncbi/'; #downloaded data from NCBI taxdump 
into this directory
my $db = Bio::DB::Taxonomy->new(-source => 'flatfile',
                                 -nodesfile => "$dbdir/nodes.dmp",
                                 -namesfile => "$dbdir/names.dmp",
                                 );
my $taxa = $db->get_taxon(-taxonid => 151341);
my @d = $db->get_all_Descendents($taxa);

print join("\n", map { $_->id . " " . $_->rank . " " . 
$_->scientific_name } @d), "\n";


Hope that helps.
Jelle Scholtalbers wrote, On 9/20/10 1:04 AM:
> Hi,
>
> I'm trying to get all descendents for a specific taxon using Entrez.
> each_Descendent and get_all_Descendents don't seem to be implemented or
> working.  I then tried by getting the tree for this taxon using
> Bio::DB::Taxonomy's get_tree. However this only retrieves the
> ancestors/parents.
> What would be the best approach here?
>
> Cheers,
> Jelle
>
> On Wed, Apr 21, 2010 at 5:45 PM, Eric Collins<rec3141 at mcmaster.ca>  wrote:
>
>    
>> Thanks, that was indeed the answer to #2. Any idea about each_Descendent?
>> Eric
>>
>> On Tue, Apr 20, 2010 at 4:48 PM, Chris Fields<cjfields at illinois.edu>
>> wrote:
>>      
>>> Sounds like this is going through an initial indexing step (for
>>>        
>> flatfiles).  I would expect the initial indexing of the tables to take time
>> as you have to create the DB, but subsequent lookups post-indexing should be
>> much faster if the index is already present.  Maybe Jason could answer in
>> more detail?
>>      
>>> chris
>>>
>>> On Apr 20, 2010, at 3:20 PM, Eric Collins wrote:
>>>
>>>        
>>>> Hello,
>>>>
>>>> I tried the Bio::DB::Taxonomy example on this wiki page using perl
>>>> 5.8.5 with BioPerl 1.6.0
>>>> http://www.bioperl.org/wiki/Module:Bio::DB::Taxonomy
>>>>
>>>> It ran for 100 cpu seconds and output:
>>>>
>>>> 33090 Viridiplantae kingdom
>>>>
>>>> I was expecting it to also output the descendents. Some questions:
>>>>
>>>> 1) are calls to 'each_Descendent' or 'get_all_Descendents' actually
>>>> implemented? It looks to be in Taxon.pm but it is not documented and
>>>> when I ran Data::Dumper on $node the value '_desc' was empty.
>>>>
>>>> 2) is the flatfile reader always so slow? after replacing 'flatfile'
>>>> with a call to 'entrez' it took only 0.02 cpu seconds to come
>>>> up with the same result.
>>>>
>>>> thanks,
>>>> Eric
>>>> _______________________________________________
>>>> Bioperl-l mailing list
>>>> Bioperl-l at lists.open-bio.org
>>>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>>>          
>>>        
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>>      
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>    



More information about the Bioperl-l mailing list