| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $self->{'_strict'} = 1 if $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 45 | unless defined $value; | ||||||||||||||||||||||||||||
| 46 | 37 | ▶ | $self->throw("I need a Bio::Location, not [$value]") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | unless $value->isa('Bio::LocationI'); | ||||||||||||||||||||||||||||
| 48 | 37 | ▶ | $self->throw("Input coordinate system not set") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | unless $self->in; | ||||||||||||||||||||||||||||
| 50 | 37 | ▶ | $self->throw("Output coordinate system not set") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | unless $self->out; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 37 | my $match; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 37 | ▶ | if ($value->isa("Bio::Location::SplitLocationI")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 2 | ▶ | $split->each_Location ? (return $split) : return ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 90 | 5 | ▶ | return if $start < 0 and $end < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$start < 0 and $end < 0
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
| |||||||||||||||||||||||||||||
| 91 | 4 | ▶ | return if $start > $self->out->end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 4 | ▶ | $start = 1 if $start < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 4 | ▶ | $end = $self->out->end if $end > $self->out->end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 104 | 39 | bless $match, 'Bio::Coordinate::Result::Match'; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 39 | return $match; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 3 | 1; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||