| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | Bio::DB::GFF::Adaptor::dbi::iterator - iterator for Bio::DB::GFF::Adaptor::dbi | ||||||||||
| 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 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 | ||||||||||
| 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::dbi::iterator; | ||||||||||
| 37 | 10 | $Bio::DB::GFF::Adaptor::dbi::iterator::VERSION = '1.7.4'; | |||||||||
| 38 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 10 | ▶ | use Bio::Root::Version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | 10 | ▶ | use constant STH => 0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 10 | ▶ | use constant CALLBACK => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 10 | ▶ | use constant CACHE => 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | |||||||||||
| 45 | 10 | *next_seq = \&next_feature; | |||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 48 | 0 | my $class = shift; | |||||||||
| 49 | 0 | my ($sth,$callback) = @_; | |||||||||
| 50 | 0 | return bless [$sth,$callback,[]],$class; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub next_feature { | ||||||||
|
Subroutine
next_feature: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||
| 54 | 0 | my $self = shift; | |||||||||
| 55 | 0 | ▶ | return shift @{$self->[CACHE]} if @{$self->[CACHE]}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | ▶ | my $sth = $self->[STH] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | my $callback = $self->[CALLBACK]; | |||||||||
| 58 | |||||||||||
| 59 | 0 | my $features; | |||||||||
| 60 | 0 | while (1) { | |||||||||
| 61 | 0 | ▶ | if (my @row = $sth->fetchrow_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | $features = $callback->(@row); | |||||||||
| 63 | 0 | ▶ | last if $features; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | } else { | ||||||||||
| 65 | 0 | $sth->finish; | |||||||||
| 66 | 0 | undef $self->[STH]; | |||||||||
| 67 | 0 | $features = $callback->(); | |||||||||
| 68 | 0 | last; | |||||||||
| 69 | } | ||||||||||
| 70 | } | ||||||||||
| 71 | 0 | ▶ | $self->[CACHE] = $features or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | shift @{$self->[CACHE]}; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 10 | 1; | |||||||||