Coordinate/ExtrapolatingPair.pm

filter: Statementstmt 100% 62 / 62 Branchbran 73.5% 25 / 34 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 92.1% 105 / 114 CC 20 SCAR 18.7
CC
20
Cov
91%
map
9.8
_map
9.0
strict
3.0
CRAP 6.5
« Coordinate/Graph.pm ↑ Summary Coordinate/Result.pm »
1 package Bio::Coordinate::ExtrapolatingPair;
2 3 our $AUTHORITY = 'cpan:BIOPERLML';
3 3 $Bio::Coordinate::ExtrapolatingPair::VERSION = '1.007001';
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Bio::LocationI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use parent qw(Bio::Coordinate::Pair);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Continuous match between two coordinate sets.
12 # AUTHOR: Heikki Lehvaslaiho <heikki@bioperl.org>
13 # OWNER: Heikki Lehvaslaiho
14 # LICENSE: Perl_5
15  
16  
17  
18 11 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
19 11 my($class,@args) = @_;
20 11 my $self = $class->SUPER::new(@args);
21  
22 11 my($strict) =
23 $self->_rearrange([qw(STRICT
24 )],
25 @args);
26  
27 11 ▶ $strict && $self->strict($strict);
Branch: 1 branch
BranchTrueFalseTotal
$strict and $self->strict($strict) 1 10 11
28 11 return $self;
29 }
30  
31  
32 42 ▶sub strict {
Subroutine strict: called CC=3 SCAR=11.0
Pod documented
33 42 my ($self,$value) = @_;
34 42 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 41 42
35 1 ▶ $self->{'_strict'} = 1 if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 1 0 1
36 }
37 42 return $self->{'_strict'};
38 }
39  
40  
41 37 ▶sub map {
Subroutine map: called CC=9 SCAR=22.8
Pod documented
42 37 my ($self,$value) = @_;
43  
44 37 ▶ $self->throw("Need to pass me a value.")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 37 37
45 unless defined $value;
46 37 ▶ $self->throw("I need a Bio::Location, not [$value]")
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Bio::LocationI") 0 37 37
47 unless $value->isa('Bio::LocationI');
48 37 ▶ $self->throw("Input coordinate system not set")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->in 0 37 37
49 unless $self->in;
50 37 ▶ $self->throw("Output coordinate system not set")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->out 0 37 37
51 unless $self->out;
52  
53 37 my $match;
54  
55 37 ▶ if ($value->isa("Bio::Location::SplitLocationI")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa('Bio::Location::SplitLocationI')) { } 2 35 37
56  
57 2 my $split = Bio::Coordinate::Result->new(-seq_id=>$self->out->seq_id);
58 2 foreach my $loc ( sort { $a->start <=> $b->start }
59 $value->sub_Location ) {
60  
61 5 $match = $self->_map($loc);
62 5 ▶ $split->add_sub_Location($match) if $match;
Branch: 1 branch
BranchTrueFalseTotal
if $match 5 0 5
63  
64 }
65 2 ▶ $split->each_Location ? (return $split) : return ;
Branch: 1 branch
BranchTrueFalseTotal
$split->each_Location ? : 2 0 2
66  
67 } else {
68 35 return $self->_map($value);
69 }
70 }
71  
72  
73 40 ▶sub _map {
Subroutine _map: called CC=9 SCAR=22.0
74 40 my ($self,$value) = @_;
75  
76 40 my ($offset, $start, $end);
77  
78 40 ▶ if ($self->strand == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strand == -1) { } 12 28 40
79 12 $offset = $self->in->end + $self->out->start;
80 12 $start = $offset - $value->end;
81 12 $end = $offset - $value->start ;
82 } else { # undef, 0 or 1
83 28 $offset = $self->in->start - $self->out->start;
84 28 $start = $value->start - $offset;
85 28 $end = $value->end - $offset;
86 }
87  
88 # strict prevents matches outside stated range
89 40 ▶ if ($self->strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strict) 5 35 40
90 5 ▶ return if $start < 0 and $end < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 and $end < 0 1 4 5
Condition100%3/3
$start < 0 and $end < 0
!ll&&!rl&&r
311
MC/DC100%2/2
$start < 0 and $end < 0
$start < 0 $end < 0
Truth table100%3/3
A and B
A= $start < 0B= $end < 0
ABresult
0X0
100
111
91 4 ▶ return if $start > $self->out->end;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $self->out->end 0 4 4
92 4 ▶ $start = 1 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 1 3 4
93 4 ▶ $end = $self->out->end if $end > $self->out->end;
Branch: 1 branch
BranchTrueFalseTotal
if $end > $self->out->end 2 2 4
94 }
95  
96 39 my $match = Bio::Location::Simple->
97 new(-start => $start,
98 -end => $end,
99 -strand => $self->strand,
100 -seq_id => $self->out->seq_id,
101 -location_type => $value->location_type
102 );
103 39 ▶ $match->strand($match->strand * $value->strand) if $value->strand;
Branch: 1 branch
BranchTrueFalseTotal
if $value->strand 39 0 39
104 39 bless $match, 'Bio::Coordinate::Result::Match';
105  
106 39 return $match;
107 }
108  
109 3 1;
110  
111 __END__
« Coordinate/Graph.pm ↑ Summary Coordinate/Result.pm »