lib/BoutrosLab/TSVStream/IO/Role/Base/Dyn.pm

filter: Statementstmt 84.0% 42 / 50 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod n/a totaltotal 82.2% 51 / 62 CC 2 SCAR 6.5
CC
2
Cov
81%
__ANON__
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« blib/lib/BoutrosLab/TSVStream/Format/VCF/FullNoChr/Dyn.pm ↑ Summary lib/BoutrosLab/TSVStream/Format/VCF/Role.pm »
1 =head1 NAME
2  
3 BoutrosLab::TSVStream::IO::Role::Base::Dyn
4  
5 =head1 SYNOPSIS
6  
7 This is a collection of base attributes and methods used internally
8 by dynamic TSVStream reader and writer role modules. It augments
9 BoutrosLab::IO::Role::Base::Fixed.
10  
11 =cut
12  
13 package BoutrosLab::TSVStream::IO::Role::Base::Dyn;
14  
15 # safe Perl
16 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use BoutrosLab::TSVStream::IO::Role::Base::Fixed;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 with 'BoutrosLab::TSVStream::IO::Role::Base::Fixed';
25  
26 # Base role for all Dynamic reader/writer variants
27  
28 1 has dyn_fields => (
29 is => 'ro',
30 isa => 'ArrayRef[Str]',
31 predicate => '_has_dyn_fields',
32 writer => '_set_dyn_fields',
33 trigger => \&_dyn_fields_set
34 );
35  
36 1 has _dyn_fields_initialized => (
37 is => 'rw',
38 isa => 'Bool',
39 default => 0
40 );
41  
42 1 for my $name ( qw( _fixed_start _fixed_end _dyn_start _dyn_end) ) {
43 4 has $name => ( is => 'ro', isa => 'Int', writer => "_set$name" );
44 }
45  
46 87 ▶sub _dyn_fields_set {
Subroutine _dyn_fields_set: called CC=1 SCAR=0.0
47 87 my( $self, $dyn ) = @_;
48 87 my $fixed_size = scalar(@{$self->fields});
49 87 my $dyn_size = scalar(@$dyn);
50 87 $self->_set_fixed_start(0);
51 87 $self->_set_fixed_end($fixed_size-1);
52 87 $self->_set_dyn_start($fixed_size);
53 87 $self->_set_dyn_end($fixed_size+$dyn_size-1);
54 87 $self->_num_fields($fixed_size+$dyn_size);
55 }
56  
57 51 ▶sub _extra_names {
Subroutine _extra_names: called CC=1 SCAR=0.0
58 51 my $self = shift;
59 51 my $cnt = shift;
60 51 return map { "extra$_" } 1 .. $cnt;
61 }
62  
63 0 ▶around '_to_fields' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
64 0 my $orig = shift;
65 0 my $self = shift;
66 0 my $obj = shift;
67 0 ▶ unless ($self->_dyn_fields_initialized) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_dyn_fields_initialized) 0 0 0
68 0 $self->_set_dyn_fields( $obj->dyn_fields );
69 0 $self->_dyn_fields_initialized(1);
70 }
71 0 return( ($self->$orig($obj), @{ $obj->dyn_values } ) );
72 1 };
73  
74 84 ▶around '_read_config' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
75 84 my $orig = shift;
76 84 my $self = shift;
77 84 return ($self->$orig, dyn_fields => $self->dyn_fields);
78 1 };
79  
80  
81 =head1 AUTHOR
82  
83 John Macdonald - Boutros Lab
84  
85 =head1 ACKNOWLEDGEMENTS
86  
87 Paul Boutros, Phd, PI - Boutros Lab
88  
89 The Ontario Institute for Cancer Research
90  
91 =cut
92  
93 1 1;
94  
« blib/lib/BoutrosLab/TSVStream/Format/VCF/FullNoChr/Dyn.pm ↑ Summary lib/BoutrosLab/TSVStream/Format/VCF/Role.pm »