File Coverage

blib/lib/Bio/Polloc/Locus/extend.pm
Criterion Covered Total %
statement 20 27 74.0
branch 3 6 50.0
condition n/a
subroutine 5 7 71.4
pod 4 4 100.0
total 32 44 72.7


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Bio::Polloc::Locus::extend - A feature based on another one
4              
5             =head1 DESCRIPTION
6              
7             A feature of a sequence, inferred by similarity or surrounding
8             regions similar to those of a known feature. Implements
9             L<Bio::Polloc::LocusI>.
10              
11             =head1 AUTHOR - Luis M. Rodriguez-R
12              
13             Email lmrodriguezr at gmail dot com
14              
15             =cut
16              
17             package Bio::Polloc::Locus::extend;
18 1     1   7 use base qw(Bio::Polloc::LocusI);
  1         2  
  1         125  
19 1     1   6 use strict;
  1         2  
  1         474  
20             our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version
21              
22              
23             =head1 APPENDIX
24              
25             Methods provided by the package
26              
27             =head2 new
28              
29             Creates a B<Bio::Polloc::Locus::repeat> object.
30              
31             =head3 Arguments
32              
33             =over
34              
35             =item -basefeature I<Bio::Polloc::LocusI object>
36              
37             The reference feature or part of the reference collection.
38              
39             =item -score I<float>
40              
41             The score of extension (bit-score on BLAST or score on HMMer, for example).
42              
43             =back
44              
45             =cut
46              
47             sub new {
48 0     0 1 0 my($caller,@args) = @_;
49 0         0 my $self = $caller->SUPER::new(@args);
50 0         0 $self->_initialize(@args);
51 0         0 return $self;
52             }
53              
54              
55             =head2 basefeature
56              
57             Gets/sets the reference feature of the extension. Be careful, this can also
58             refer to one feature in a collection of reference. Avoid using specific data
59             from this feature.
60              
61             =head3 Arguments
62              
63             The reference feature (L<Bio::Polloc::LocusI> object, optional).
64              
65             =head3 Returns
66              
67             The reference feature (L<Bio::Polloc::LocusI> object or undef).
68              
69             =cut
70              
71             sub basefeature {
72 70     70 1 528 my($self,$value) = @_;
73 70 100       135 if (defined $value){
74 34         64 $self->{'_basefeature'} = $value;
75 34         127 $self->family($value->family);
76             }
77 70         225 return $self->{'_basefeature'};
78             }
79              
80              
81             =head2 score
82              
83             Gets/sets the score.
84              
85             =head3 Arguments
86              
87             The score (float, optional).
88              
89             =head3 Returns
90              
91             The score (float or undef).
92              
93             =cut
94              
95             sub score {
96 34     34 1 45 my($self,$value) = @_;
97 34 50       122 $self->{'_score'} = $value+0 if defined $value;
98 34         136 return $self->{'_score'};
99             }
100              
101             =head2 distance
102              
103             Tries to calculate the distance using the base-feature's C<distance()>
104             method. See L<Bio::Polloc::LocusI->distance()>.
105              
106             =head3 Throws
107              
108             L<Bio::Polloc::Polloc::Error>.
109              
110             =cut
111              
112             sub distance {
113 0     0 1 0 my ($self, @args) = @_;
114 0 0       0 $self->throw('Impossible to find a base feature.') unless defined $self->basefeature;
115 0         0 return $self->basefeature->distance(-locusref=>$self, @args);
116             }
117              
118             =head1 INTERNAL METHODS
119              
120             Methods intended to be used only within the scope of Bio::Polloc::*
121              
122             =head2 _initialize
123              
124             =cut
125              
126             sub _initialize {
127 34     34   167 my($self,@args) = @_;
128 34         128 my($basefeature,$score) = $self->_rearrange([qw(BASEFEATURE SCORE)], @args);
129 34         136 $self->type('extend');
130 34         80 $self->comments("Extended feature");
131 34         121 $self->basefeature($basefeature);
132 34         68 $self->score($score);
133             }
134              
135             1;