3 # BioPerl module for Bio::DB::EUtilities::Summary::DocSum
5 # Cared for by Chris Fields
7 # Copyright Chris Fields
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 # Part of the EUtilities BioPerl package
17 Bio::DB::EUtilities::Summary::DocSum - data object for document summary data
28 User feedback is an integral part of the
29 evolution of this and other Bioperl modules. Send
30 your comments and suggestions preferably to one
31 of the Bioperl mailing lists. Your participation
34 bioperl-l@lists.open-bio.org - General discussion
35 http://www.bioperl.org/wiki/Mailing_lists - About the mailing lists
39 Report bugs to the Bioperl bug tracking system to
40 help us keep track the bugs and their resolution.
41 Bug reports can be submitted via the web.
43 http://bugzilla.open-bio.org/
45 =head1 AUTHOR Chris Fields
47 Email cjfields at uiuc dot edu
51 The rest of the documentation details each of the
52 object methods. Internal methods are usually
57 # Let the code begin...
59 package Bio
::Tools
::EUtilities
::Summary
::DocSum
;
63 use base
qw(Bio::Root::Root Bio::Tools::EUtilities::EUtilDataI);
65 use Bio
::Tools
::EUtilities
::Summary
::Item
;
78 my ($class, @args) = @_;
79 my $self = $class->SUPER::new
(@args);
80 my ($type) = $self->_rearrange(['DATATYPE'],@args);
82 $self->eutil('esummary');
83 $self->datatype($type);
90 Usage : my ($id) = $item->get_ids;
91 Function : returns array or array ref with id
92 Returns : array or array ref
94 Note : the behavior of this method remains consistent with other
95 implementations of get_ids(). To retrieve the single DocSum ID
102 return wantarray ?
$self->{'_id'} : [$self->{'_id'}];
108 Usage : my ($id) = $item->get_id;
109 Function : returns UID of record
117 return $self->{'_id'};
123 Usage : while (my $item = $docsum->next_Item) {...}
124 Function : iterates through Items (nested layer of Item)
125 Returns : single Item
126 Args : [optional] single arg (string)
127 'flatten' - iterates through a flattened list ala
128 get_all_DocSum_Items()
133 my ($self, $request) = @_;
134 unless ($self->{"_items_it"}) {
135 #my @items = $self->get_Items;
136 my @items = ($request && $request eq 'flatten') ?
137 $self->get_all_Items :
139 $self->{"_items_it"} = sub {return shift @items}
141 $self->{'_items_it'}->();
147 Usage : my @items = $docsum->get_Items
148 Function : returns list of, well, Items
149 Returns : array of Items
156 return ref $self->{'_items'} ? @
{ $self->{'_items'} } : return ();
161 Title : get_all_Items
162 Usage : my @items = $docsum->get_all_Items
163 Function : returns flattened list of all Item objects (Items, ListItems,
165 Returns : array of Items
167 Note : items are added top-down (similar order to using nested calls)
168 in original list order.
171 Item - Item - Item - Item ...
177 Structure - Structure
183 unless ($self->{'_ordered_items'}) {
184 for my $item ($self->get_Items) {
185 push @
{$self->{'_ordered_items'}}, $item;
186 for my $ls ($item->get_ListItems) {
187 push @
{$self->{'_ordered_items'}}, $ls;
188 for my $st ($ls->get_StructureItems) {
189 push @
{$self->{'_ordered_items'}}, $st;
194 return @
{$self->{'_ordered_items'}};
197 =head2 get_content_by_name
199 Title : get_content_by_Item_name
200 Usage : my $data = get_content_by_name('CreateDate')
201 Function : Returns scalar content for named Item in DocSum (indicated by
203 Returns : scalar value (string) if present
204 Args : string (Item name)
205 Warns : If Item with name is not found
209 sub get_content_by_name
{
210 my ($self, $key) = @_;
212 my ($it) = grep {$_->get_name eq $key} $self->get_all_Items;
213 return $it->get_content;
216 =head2 get_type_by_name
218 Title : get_type_by_name
219 Usage : my $data = get_type_by_name('CreateDate')
220 Function : Returns data type for named Item in DocSum (indicated by
222 Returns : scalar value (string) if present
223 Args : string (Item name)
224 Warns : If Item with name is not found
228 sub get_type_by_name
{
229 my ($self, $key) = @_;
231 my ($it) = grep {$_->get_name eq $key} $self->get_all_Items;
232 return $it->get_type;
238 Usage : $docsum->rewind();
239 Function : rewinds DocSum iterator
242 'recursive' - rewind all DocSum object layers
243 (Items, ListItems, StructureItems)
248 my ($self, $request) = @_;
249 if ($request && $request eq 'all') {
250 map {$_->rewind('all') } $self->get_Items;
252 delete $self->{"_items_it"};
255 # private EUtilDataI method
258 my ($self, $data) = @_;
260 $self->{'_id'} = $data->{Id
} if exists $data->{Id
};
261 for my $sd (@
{ $data->{Item
} } ) {
262 $sd->{Id
} = $data->{Id
} if exists $data->{Id
};
264 Bio
::Tools
::EUtilities
::Summary
::Item
->new(-datatype
=> 'item',
265 -verbose
=> $self->verbose);
266 $subdoc->_add_data($sd);
267 push @
{ $self->{'_items'} }, $subdoc;
270 $self->{'_id'} = $data->{Id
} if exists $data->{Id
};