3 Bio::DB::GFF::Adaptor::dbi::iterator - iterator for Bio::DB::GFF::Adaptor::dbi
11 This is an internal module that is used by the Bio::DB::GFF DBI
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
27 Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
29 Copyright (c) 2001 Cold Spring Harbor Laboratory.
31 This library is free software; you can redistribute it and/or modify
32 it under the same terms as Perl itself.
36 package Bio
::DB
::GFF
::Adaptor
::dbi
::iterator
;
38 use Bio
::Root
::Version
;
40 use constant STH
=> 0;
41 use constant CALLBACK
=> 1;
42 use constant CACHE
=> 2;
44 *next_seq
= \
&next_feature
;
48 my ($sth,$callback) = @_;
49 return bless [$sth,$callback,[]],$class;
54 return shift @
{$self->[CACHE
]} if @
{$self->[CACHE
]};
55 my $sth = $self->[STH
] or return;
56 my $callback = $self->[CALLBACK
];
60 if (my @row = $sth->fetchrow_array) {
61 $features = $callback->(@row);
66 $features = $callback->();
70 $self->[CACHE
] = $features or return;
71 shift @
{$self->[CACHE
]};