2
# BioPerl module for Bio::Tools::EUtilities::EUtilDataI
4
# Please direct questions and support issues to <bioperl-l@bioperl.org>
6
# Cared for by Chris Fields <cjfields at bioperl dot org>
8
# Copyright Chris Fields
10
# You may distribute this module under the same terms as perl itself
12
# POD documentation - main docs before the code
16
Bio::Tools::EUtilities::EUtilDataI - eutil data object interface
20
# say you had some data in a hash ref ($data) and wanted to create hierarchies
21
# of object using the same interface, starting with the topmost...
23
# $object is a Bio::Tools::EUtilities::EUtilDataI instance
25
$object->_add_data($data);
27
# in _add_data()... sort through keys and create subobjects as needed
30
my $sub = Bio::Tools::EUtilities::FooData->new(-eutil => 'efoo',
32
$sub->_add_data($subdata);
33
# store into parent object as needed...
39
while (my $sub = $parent->next_Foo) {...}
44
This is a simple interface which allows creation of simple typed object
45
hierarchies. Single layers can be accessed via simple iterators (next_* methods)
46
or retrieved all at once (get_*) methods; nested data can be iterated through
47
nested iterators for each object, or retrieved using get_all_* methods.
49
This interface defines common methods required for all eutil data-holding
50
objects: _add_data(), eutil(), and type(). It also specifies inheriting
51
interface classes use at least one of three methods: get_ids(), get_term(), or
52
get_database(), which are the three types of data that eutils mainly centers on.
54
Generally, eutil() is the Bio::Tools::EUtilities parser used to set the data.
55
Similarly, datatype() is the specific data type for the class.
57
Implementations which rely on subclasses to store data and have iterators should
58
also define a generalized rewind() method that (by default) rewinds all
59
iterators to the start. Args passed can specify exactly which iterator to rewind
60
and (if possible) recursively rewind nested object iterators.
62
As the method implies, _add_data() is a private method that adds data chunks to
63
the object and sets internal parameters for the various data objects. Methods
64
corresponding to the data type simply return the set data or iterate through the
65
data sets if the values are more complex. Data can alternatively be passed
66
through the object constructor.
70
Please direct usage questions or support issues to the mailing list:
72
I<bioperl-l@bioperl.org>
74
rather than to the module maintainer directly. Many experienced and
75
reponsive experts will be able look at the problem and quickly
76
address it. Please include a thorough description of the problem
77
with code and data examples if at all possible.
81
Report bugs to the Bioperl bug tracking system to
82
help us keep track the bugs and their resolution.
83
Bug reports can be submitted via the web.
85
https://redmine.open-bio.org/projects/bioperl/
89
Email cjfields at bioperl dot org
93
The rest of the documentation details each of the
94
object methods. Internal methods are usually
99
package Bio::Tools::EUtilities::EUtilDataI;
102
use Text::Wrap qw(wrap);
104
use base qw(Bio::Root::RootI);
109
Usage : $eutil->$foo->eutil
110
Function : Get/Set eutil
112
Args : string (eutil)
113
Throws : on invalid eutil
118
my %VALID_EUTILS = map {$_ => 1} qw(esearch epost espell egquery elink einfo esummary);
121
my ($self, $eutil) = @_;
123
$self->throw("$eutil not supported") if !exists $VALID_EUTILS{$eutil};
124
return $self->{'_eutil'} = $eutil;
126
return $self->{'_eutil'};
134
Usage : $type = $qd->datatype;
135
Function: retrieve simple data type object holds (linkset, docsum, item, etc)
136
Returns : string (eutil name)
138
Note : this is probably more useful for devs than for users as a way to keep
139
track of the various types of modules used
145
return $self->{'_type'} = shift if @_;
146
return $self->{'_type'};
152
Usage : $esum->rewind
153
Function : rewinds the requested iterator
155
Args : [OPTIONAL] may include 'all', 'recursive', etc.
160
shift->warn("Object may not need an iterator. Please check the documentation.");
166
Usage : $foo->_add_data($data)
167
Function : adds data to current object as a chunk
169
Args : hash ref containing relevant data
174
shift->throw_not_implemented;
180
Usage : $foo->to_string()
181
Function : converts current object to string
183
Args : (optional) simple data for text formatting
184
Note : Used generally for debugging and for the print_* methods
189
shift->throw_not_implemented;
195
Usage : $foo->_text_wrap($string)
196
Function : private internal wrapper for Text::Wrap::wrap
199
Note : Internal use only. Simple wrapper method.