GFF/Adaptor/memory/iterator.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 90.0% 45 / 50 CC 6 SCAR 14.7
CC
6
Cov
93%
next_feature
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« GFF/Segment.pm ↑ Summary GFF/Adaptor/memory/feature_serializer.pm »
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
BranchTrueFalseTotal
if @{$self->{"cache"};} 0 285 285
58  
59 285 ▶ my $data = $self->{data} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $data = $self->{"data"} or return 280 5 285
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
BranchTrueFalseTotal
if ($feature) { } 270 15 285
66 270 $features = $callback->(@{$feature});
67 270 ▶ last if $features;
Branch: 1 branch
BranchTrueFalseTotal
if $features 265 5 270
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
BranchTrueFalseTotal
$self->{"cache"} = $features or return 280 0 280
77 280 shift @{$self->{cache}};
78 }
79  
80 5 1;
« GFF/Segment.pm ↑ Summary GFF/Adaptor/memory/feature_serializer.pm »