| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | Bio::DB::GFF::Adaptor::memory::iterator - iterator for Bio::DB::GFF::Adaptor::memory | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | For internal use only | ||||||||||
| 8 | |||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||
| 10 | |||||||||||
| 11 | This is an internal module that is used by the Bio::DB::GFF in-memory | ||||||||||
| 12 | adaptor to return an iterator across a sequence feature query. The | ||||||||||
| 13 | object has a single method, next_feature(), that returns the next | ||||||||||
| 14 | feature from the query. The method next_seq() is an alias for | ||||||||||
| 15 | next_feature(). | ||||||||||
| 16 | |||||||||||
| 17 | =head1 BUGS | ||||||||||
| 18 | |||||||||||
| 19 | None known yet. | ||||||||||
| 20 | |||||||||||
| 21 | =head1 SEE ALSO | ||||||||||
| 22 | |||||||||||
| 23 | L<Bio::DB::GFF>, | ||||||||||
| 24 | |||||||||||
| 25 | =head1 AUTHOR | ||||||||||
| 26 | |||||||||||
| 27 | Lincoln Stein E<lt>lstein@cshl.orgE<gt>. | ||||||||||
| 28 | |||||||||||
| 29 | Copyright (c) 2001 Cold Spring Harbor Laboratory. | ||||||||||
| 30 | |||||||||||
| 31 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 32 | it under the same terms as Perl itself. | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | package Bio::DB::GFF::Adaptor::memory::iterator; | ||||||||||
| 37 | 5 | $Bio::DB::GFF::Adaptor::memory::iterator::VERSION = '1.7.4'; | |||||||||
| 38 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | # this module needs to be cleaned up and documented | ||||||||||
| 40 | 5 | ▶ | use Bio::Root::Version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 5 | *next_seq = \&next_feature; | |||||||||
| 43 | |||||||||||
| 44 | 15 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 45 | 15 | my $class = shift; | |||||||||
| 46 | 15 | my ($data,$callback) = @_; | |||||||||
| 47 | 15 | my $pos = 0; | |||||||||
| 48 | 15 | return bless {data => $data, | |||||||||
| 49 | pos => $pos, | ||||||||||
| 50 | callback => $callback, | ||||||||||
| 51 | cache => []},$class; | ||||||||||
| 52 | #return bless [$sth,$callback,[]],$class; | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 285 | ▶ | sub next_feature { | ||||||||
|
Subroutine
next_feature: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||
| 56 | 285 | my $self = shift; | |||||||||
| 57 | 0 | ▶ | return shift @{$self->{cache}} if @{$self->{cache}}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 285 | ▶ | my $data = $self->{data} or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 280 | my $callback = $self->{callback}; | |||||||||
| 61 | |||||||||||
| 62 | 280 | my $features; | |||||||||
| 63 | 280 | while (1) { | |||||||||
| 64 | 285 | my $feature = $data->[$self->{pos}++]; | |||||||||
| 65 | 285 | ▶ | if ($feature) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 270 | $features = $callback->(@{$feature}); | |||||||||
| 67 | 270 | ▶ | last if $features; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | } else { | ||||||||||
| 69 | 15 | $features = $callback->(); | |||||||||
| 70 | 15 | undef $self->{pos}; | |||||||||
| 71 | 15 | undef $self->{data}; | |||||||||
| 72 | 15 | undef $self->{cache}; | |||||||||
| 73 | 15 | last; | |||||||||
| 74 | } | ||||||||||
| 75 | } | ||||||||||
| 76 | 280 | ▶ | $self->{cache} = $features or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 280 | shift @{$self->{cache}}; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 5 | 1; | |||||||||