Bio-EUtilities
view release on metacpan or search on metacpan
lib/Bio/Tools/EUtilities/EUtilDataI.pm view on Meta::CPAN
package Bio::Tools::EUtilities::EUtilDataI;
$Bio::Tools::EUtilities::EUtilDataI::VERSION = '1.77';
use utf8;
use strict;
use warnings;
use base qw(Bio::Root::RootI);
use Text::Wrap qw(wrap);
# ABSTRACT: EUtil data object interface.
# AUTHOR: Chris Fields <cjfields@bioperl.org>
# OWNER: 2006-2013 Chris Fields
# LICENSE: Perl_5
{
my %VALID_EUTILS = map {$_ => 1} qw(esearch epost espell egquery elink einfo esummary);
sub eutil {
my ($self, $eutil) = @_;
if ($eutil) {
$self->throw("$eutil not supported") if !exists $VALID_EUTILS{$eutil};
return $self->{'_eutil'} = $eutil;
}
return $self->{'_eutil'};
}
}
sub datatype {
my $self = shift;
return $self->{'_type'} = shift if @_;
return $self->{'_type'};
}
sub rewind {
shift->warn("Object may not need an iterator. Please check the documentation.");
}
sub _add_data {
shift->throw_not_implemented;
}
sub to_string {
shift->throw_not_implemented;
}
sub _text_wrap {
shift;
return wrap(@_);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Bio::Tools::EUtilities::EUtilDataI - EUtil data object interface.
=head1 VERSION
version 1.77
=head1 SYNOPSIS
# say you had some data in a hash ref ($data) and wanted to create hierarchies
# of object using the same interface, starting with the topmost...
# $object is a Bio::Tools::EUtilities::EUtilDataI instance
$object->_add_data($data);
# in _add_data()... sort through keys and create subobjects as needed
if ($key eq 'foo') {
my $sub = Bio::Tools::EUtilities::FooData->new(-eutil => 'efoo',
-type => 'foo');
$sub->_add_data($subdata);
# store into parent object as needed...
...
}
# access stored data
while (my $sub = $parent->next_Foo) {...}
=head1 DESCRIPTION
This is a simple interface which allows creation of simple typed object
hierarchies. Single layers can be accessed via simple iterators (next_* methods)
or retrieved all at once (get_*) methods; nested data can be iterated through
nested iterators for each object, or retrieved using get_all_* methods.
This interface defines common methods required for all eutil data-holding
objects: _add_data(), eutil(), and type(). It also specifies inheriting
interface classes use at least one of three methods: get_ids(), get_term(), or
get_database(), which are the three types of data that eutils mainly centers on.
Generally, eutil() is the Bio::Tools::EUtilities parser used to set the data.
( run in 1.873 second using v1.01-cache-2.11-cpan-df04353d9ac )