line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Bio::Polloc::GroupCriteria::operator::seq - A sequence operator |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 AUTHOR - Luis M. Rodriguez-R |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Email lmrodriguezr at gmail dot com |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Bio::Polloc::GroupCriteria::operator::seq; |
12
|
3
|
|
|
3
|
|
19
|
use base qw(Bio::Polloc::GroupCriteria::operator); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
287
|
|
13
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
108
|
|
14
|
3
|
|
|
3
|
|
17
|
use Bio::Seq; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2010
|
|
15
|
|
|
|
|
|
|
our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 APPENDIX |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Methods provided by the package |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 new |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Generic initialization method. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head3 Arguments |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
See L<Bio::Polloc::GroupCriteria::operator->new()> |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head3 Returns |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
A L<Bio::Polloc::GroupCriteria::operator::bool> object. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
0
|
my($caller,@args) = @_; |
38
|
0
|
|
|
|
|
0
|
my $self = $caller->SUPER::new(@args); |
39
|
0
|
|
|
|
|
0
|
$self->_initialize(@args); |
40
|
0
|
|
|
|
|
0
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 operate |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head3 Returns |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A L<Bio::Seq> object. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub operate { |
52
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
53
|
0
|
0
|
|
|
|
0
|
return $self->val if defined $self->val; |
54
|
0
|
0
|
0
|
|
|
0
|
$self->throw('Bad operators', $self->operators) |
55
|
|
|
|
|
|
|
unless ref($self->operators) |
56
|
|
|
|
|
|
|
and ref($self->operators)=~/ARRAY/; |
57
|
0
|
0
|
|
|
|
0
|
if($self->operation =~ /^\s*sequence\s*$/i){ |
58
|
0
|
|
|
|
|
0
|
my $locus = $self->operators->[0]->operate; |
59
|
0
|
|
0
|
|
|
0
|
$self->operators->[1] = 0 + ($self->operators->[1] || 0); |
60
|
0
|
|
0
|
|
|
0
|
$self->operators->[2] = 0 + ($self->operators->[2] || 0); |
61
|
0
|
|
0
|
|
|
0
|
$self->operators->[3] = 0 + ($self->operators->[3] || 0); |
62
|
0
|
|
|
|
|
0
|
my($from, $to); |
63
|
0
|
0
|
|
|
|
0
|
if($self->operators->[1]<0){ |
|
|
0
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
$from = $locus->from + $self->operators->[2]; |
65
|
0
|
|
|
|
|
0
|
$to = $locus->from + $self->operators->[3]; |
66
|
|
|
|
|
|
|
}elsif($self->operators->[1]>0){ |
67
|
0
|
|
|
|
|
0
|
$from = $locus->to + $self->operators->[2]; |
68
|
0
|
|
|
|
|
0
|
$to = $locus->to + $self->operators->[3]; |
69
|
|
|
|
|
|
|
}else{ |
70
|
0
|
|
|
|
|
0
|
$from = $locus->from + $self->operators->[2]; |
71
|
0
|
|
|
|
|
0
|
$to = $locus->to - $self->operators->[3]; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
0
|
|
|
|
0
|
my($start, $end) = ($from<=$to) ? ($from, $to) : ($to, $from); |
74
|
0
|
0
|
|
|
|
0
|
$start = 1 unless $start>0; |
75
|
0
|
0
|
|
|
|
0
|
$end = $locus->seq->length unless $end < $locus->seq->length; |
76
|
0
|
|
|
|
|
0
|
my $seq = Bio::Seq->new(-seq=>$locus->seq->subseq($start, $end)); |
77
|
0
|
0
|
|
|
|
0
|
return $seq->revcom if $from > $to; |
78
|
0
|
|
|
|
|
0
|
return $seq; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
0
|
|
|
|
0
|
if($self->operation =~ /^\s*reverse\s*$/i){ |
81
|
0
|
0
|
0
|
|
|
0
|
$self->throw('Unexpected operator', $self->operators->[0]) unless |
82
|
|
|
|
|
|
|
UNIVERSAL::isa($self->operators->[0], 'isa') |
83
|
|
|
|
|
|
|
and $self->operators->[0]->isa('Bio::Seq'); |
84
|
0
|
|
|
|
|
0
|
return $self->operators->[0]->revcom; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
0
|
$self->throw("Unknown numeric operation", $self->operation); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Methods intended to be used only within the scope of Bio::Polloc::* |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 _initialize |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
36
|
|
|
36
|
|
67
|
sub _initialize { } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |