line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::JBrowse::FeatureStream::Filter; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
887
|
$Bio::JBrowse::FeatureStream::Filter::AUTHORITY = 'cpan:RBUELS'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Bio::JBrowse::FeatureStream::Filter::VERSION = '0.1'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: filter another stream using a subroutine |
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use base 'Bio::JBrowse::FeatureStream'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
699
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
2
|
|
|
2
|
1
|
1768
|
my ( $class, $stream, $filter_sub ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
3
|
my $self; |
20
|
|
|
|
|
|
|
my @buffer; |
21
|
|
|
|
|
|
|
return $self = bless sub { |
22
|
5
|
|
33
|
5
|
|
40
|
return shift @buffer || do { |
23
|
|
|
|
|
|
|
while( !@buffer && ( my $f = $stream->() ) ) { |
24
|
|
|
|
|
|
|
push @buffer, $self->_apply_filter( $filter_sub, $f ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
shift @buffer; |
27
|
|
|
|
|
|
|
}; |
28
|
2
|
|
|
|
|
15
|
}, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _apply_filter { |
32
|
10
|
|
|
10
|
|
15
|
my ( $self, $filter_sub, $feature ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
10
|
100
|
|
|
|
19
|
return $feature if $filter_sub->( $feature ); |
35
|
7
|
100
|
|
|
|
47
|
return map $self->_apply_filter( $filter_sub, $_ ), |
36
|
7
|
|
|
|
|
38
|
@{ $feature->{subfeatures} || [] }; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |