Bio::DB::SoapEUtilities
DocSumAdaptor
Toolbar
Summary
Bio::DB::SoapEUtilities::DocSumAdaptor - Handle for Entrez SOAP DocSums
Package variables
No package variables defined.
Included modules
Inherit
Bio::Root::Root
Synopsis
my $fac = Bio::DB::SoapEUtilities->new();
# run a query, returning a DocSumAdaptor
my $docs = $fac->esummary( -db => 'taxonomy',
-id => 527031 )->run(-auto_adapt=>1);
# iterate over docsums
while (my $d = $docs->next_docsum) {
@available_items = $docsum->item_names;
# any available item can be called as an accessor
# from the docsum object...watch your case...
$sci_name = $d->ScientificName;
$taxid = $d->TaxId;
}
Description
This adaptor provides an iterator (next_docsum()) and other
convenience functions for parsing NCBI Entrez EUtility esummary
SOAP results.
Methods
Methods description
Title : new Usage : my $obj = new Bio::DB::SoapEUtilities::DocSumAdaptor(); Function: Builds a new Bio::DB::SoapEUtilities::DocSumAdaptor object Returns : an instance of Bio::DB::SoapEUtilities::DocSumAdaptor Args : |
Title : next_docsum Usage : Function: return the next DocSum from the attached Result Returns : Args : |
Methods code
sub new
{ my ($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($result) = $self->_rearrange([qw(RESULT)], @args);
$self->throw("DocSumAdaptor requires a SoapEUtilities::Result argument")
unless $result;
$self->throw("DocSumAdaptor only works with elink results") unless
$result->util eq 'esummary';
$self->{'_result'} = $result;
$self->{'_idx'} = 1;
return $self;} |
sub next_docsum
{ my $self = shift;
my $stem = "//Body/".$self->result->result_type."/[".$self->{'_idx'}."]";
my $som = $self->result->som;
return unless $som->valueof($stem);
my ($ret, %params);
my $get = sub { $som->valueof("$stem/".shift) };
$params{'-id'} = $get->('Id');
my $names = [];
for (my $i = 1; my $data = $som->dataof("$stem/[$i]"); $i++) {
if ( $data->value and $data->value !~ /^\s*$/) {
my $name = $data->attr->{'Name'};
next unless $name;
my $content = $som->valueof("$stem/[$i]/ItemContent");
unless (defined $content) {
next unless $som->dataof("$stem/[$i]/Item");
my $h = {};
_traverse_items("$stem/[$i]", $som, $h);
$content = $h;
}
push @$names, $name;
$params{$name} = $content;
}
}
$params{'_item_names'} = $names;
my $class = ref($self)."::docsum";
$ret = $class->new(%params);
($self->{'_idx'})++;
return $ret;} |
sub rewind
{ shift->{'_idx'} = 1; };} |
| _traverse_items | description | prev | next | Top |
sub _traverse_items
{ my ($stem, $som, $h) = @_;
for (my $i = 1; my $data = $som->dataof($stem."/[$i]"); $i++) {
my $name = $data->attr->{'Name'};
next unless $name;
if ($name =~ /Type$/) {
_traverse_items("$stem/[$i]", $som, $h);
}
else {
my $content = $som->valueof("$stem/[$i]/ItemContent");
if ($content) {
$$h{$name} = $content;
}
else {
$$h{$name} = {};
_traverse_items("$stem/[$i]", $som, $$h{$name});
}
}
}
return;
}
1;
package Bio::DB::SoapEUtilities::DocSumAdaptor::docsum;
use strict;
use warnings;
use base qw(Bio::Root::Root);} |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.orgrather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
| AUTHOR - Mark A. Jensen | Top |
Email maj -at- fortinbras -dot- us
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _