lib/BIE/App/PacBio.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« bin/pacbioBas.pl ↑ Summary
1 package BIE::App::PacBio;
2 our $VERSION = '0.01';
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 0 ▶use BIE::Data::HDF5::File;
Subroutine BEGIN: called CC=1 SCAR=2.6
7  
8 has 'file' => (is => 'ro',
9 isa => 'Str',
10 required => 1
11 );
12  
13 has 'h5' => (is => 'rw',
14 isa => 'BIE::Data::HDF5::File',
15 );
16  
17 has 'content' => (is => 'ro',
18 isa => 'ArrayRef[Str]',
19 lazy => 1,
20 default => sub {
21 my $self = shift;
22 my $objs = $self->h5->list;
23 [grep { $objs->{$_} eq 'dataset'
24 } keys %$objs]
25 },
26 );
27  
28 has 'data' => (
29 is => 'ro',
30 lazy => 1,
31 default => sub {
32 my $self = shift;
33 return {map {$_ => $self->h5->pwd->openData($_) } @{$self->content}};
34 },
35 );
36  
37 has 'lens' => (
38 is => 'rw',
39 isa => 'ArrayRef[Int]',
40 );
41  
42 has 'hitIdx' => (
43 is => 'ro',
44 isa => 'ArrayRef[Int]',
45 writer => 'getHitIdx',
46 );
47  
48 around 'lens' => sub {
49 my $orig = shift;
50 my $self = shift;
51 return $self->$orig unless @_;
52 my $d = shift;
53 $self->getHitIdx([grep {$d->[$_]>0} 0..$#$d]);
54 my @lens = @{$d}[@{$self->hitIdx}];
55 $self->$orig(\@lens);
56 };
57  
58 sub read {
59 my $self = shift;
60 return undef unless @_;
61 my $data = $self->h5->pwd->openData($_[0]);
62 return $data->read;
63 }
64  
65 sub split {
66 my $self = shift;
67 my $ori = $self->read($_[0]);
68 my $p = 0;
69 return [map {my $r=[@{$ori}[$p .. ($p+$_-1)]];
70 $p+=$_;
71 $r} @{$self->lens}];
72 }
73  
74 sub BUILD {
75 my $self = shift;
76 $self->h5(BIE::Data::HDF5::File->new(h5File => $self->file));
77 }
78  
79 __PACKAGE__->meta->make_immutable;
80  
81 1;
82 __END__
« bin/pacbioBas.pl ↑ Summary