BarMap/Mapping/Type.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 89.0% 57 / 64 CC 6 SCAR 9.5
CC
6
Cov
89%
__ANON__
5.6
arrow
2.0
BEGIN
1.0
CRAP 2.6
« BarMap/Mapping.pm ↑ Summary BarMap/Mapping/Set.pm »
1 # All methods are class methods, it's not meant to be instantiated. It just
2 # manages the type name string and converts it to arrows, etc.
3 package Bio::RNA::BarMap::Mapping::Type;
4 5 our $VERSION = '0.04';
5  
6 5 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Moose::Util::TypeConstraints; # for enum()
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 5 has '_type' => (
15 is => 'ro',
16 isa => enum([qw(EXACT APPROX)]),
17 required => 1,
18 );
19  
20 # Only allow construction from a single arrow string.
21 12804 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=5 SCAR=17.3
22 12804 my $orig = shift;
23 12804 my $class = shift;
24  
25 12804 ▶ confess 'Pass a single arrow string to construct a Mapping::Type object'
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 1 or ref $_[0] 0 12804 12804
Condition33%1/3
@_ != 1 or ref $_[0]
l!l&&r!l&&!r
0012804
MC/DC0%0/2
@_ != 1 or ref $_[0]
@_ != 1 ref $_[0]
Truth table33%1/3
A or B
A= @_ != 1B= ref $_[0]
ABresult
1X1
011
000
26 if @_ != 1 or ref $_[0];
27  
28 12804 my $arrow = shift; # arrow string passed
29 12804 ▶ if ($arrow eq '->') {
Branch: 2 branches
BranchTrueFalseTotal
if ($arrow eq '->') { } 11124 1680 12804
elsif ($arrow eq '~>') { } 1680 0 1680
30 11124 return $class->$orig(_type => 'EXACT')
31 }
32 elsif ($arrow eq '~>') {
33 1680 return $class->$orig(_type => 'APPROX')
34 }
35 else {
36 0 confess 'Unknown arrow string in constructor';
37 }
38 5 };
39  
40 # Returns a new mapping type object of type 'exact'.
41 20 ▶sub exact { return $_[0]->new('->'); }
Subroutine exact: called CC=1 SCAR=0.0
Pod documented
42  
43 # Returns a new mapping type object of type 'approx'.
44 12 ▶sub approx { return $_[0]->new('~>'); }
Subroutine approx: called CC=1 SCAR=0.0
Pod documented
45  
46 # Returns true iff the object is of EXACT type.
47 18 ▶sub is_exact {
Subroutine is_exact: called CC=1 SCAR=0.0
Pod documented
48 18 my ($self) = @_;
49 18 return $self->_type() eq 'EXACT';
50 }
51  
52 # Returns true iff the object is of APPROX type.
53 147 ▶sub is_approx {
Subroutine is_approx: called CC=1 SCAR=0.0
Pod documented
54 147 my ($self) = @_;
55 147 return $self->_type() eq 'APPROX';
56 }
57  
58 # Return the arrow representation of this object, i.e. '->' for exact and '~>'
59 # for approx mapping type objects.
60 12 ▶sub arrow {
Subroutine arrow: called CC=2 SCAR=6.9
Pod documented
61 12 my ($self) = @_;
62 12 ▶ return $self->is_exact ? '->' : '~>';
Branch: 1 branch
BranchTrueFalseTotal
$self->is_exact ? : 6 6 12
63 }
64  
65  
66 5 __PACKAGE__->meta->make_immutable;
67  
68 5 1; # End of Bio::RNA::BarMap::Mapping::Type
69  
70  
71 __END__
« BarMap/Mapping.pm ↑ Summary BarMap/Mapping/Set.pm »