File Coverage

Bio/Location/AvWithinCoordPolicy.pm
Criterion Covered Total %
statement 17 19 89.4
branch 4 8 50.0
condition 4 12 33.3
subroutine 5 5 100.0
pod 3 3 100.0
total 33 47 70.2


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Location::AvWithinCoordPolicy
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Hilmar Lapp
7             # and Jason Stajich
8             #
9             # Copyright Hilmar Lapp, Jason Stajich
10             #
11             # You may distribute this module under the same terms as perl itself
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::Location::AvWithinCoordPolicy - class implementing
17             Bio::Location::CoordinatePolicy as the average for WITHIN and the widest possible and reasonable range otherwise
18              
19             =head1 SYNOPSIS
20              
21             See Bio::Location::CoordinatePolicyI
22              
23             =head1 DESCRIPTION
24              
25             CoordinatePolicyI implementing objects are used by Bio::LocationI
26             implementing objects to determine integer-valued coordinates when
27             asked for it.
28              
29             This class will compute the coordinates such that for fuzzy locations
30             of type WITHIN and BETWEEN the average of the two limits will be
31             returned, and for all other locations it will return the widest
32             possible range, but by using some common sense. This means that
33             e.g. locations like "E5..100" (start before position 5) will return 5
34             as start (returned values have to be positive integers).
35              
36             =head1 FEEDBACK
37              
38             User feedback is an integral part of the evolution of this and other
39             Bioperl modules. Send your comments and suggestions preferably to one
40             of the Bioperl mailing lists. Your participation is much appreciated.
41              
42             bioperl-l@bioperl.org - General discussion
43             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44              
45             =head2 Support
46              
47             Please direct usage questions or support issues to the mailing list:
48              
49             I
50              
51             rather than to the module maintainer directly. Many experienced and
52             reponsive experts will be able look at the problem and quickly
53             address it. Please include a thorough description of the problem
54             with code and data examples if at all possible.
55              
56             =head2 Reporting Bugs
57              
58             Report bugs to the Bioperl bug tracking system to help us keep track
59             the bugs and their resolution. Bug reports can be submitted via the
60             web:
61              
62             https://github.com/bioperl/bioperl-live/issues
63              
64             =head1 AUTHOR - Hilmar Lapp, Jason Stajich
65              
66             Email Ehlapp-at-gmx-dot-netE, Ejason-at-bioperl-dot-orgE
67              
68             =head1 APPENDIX
69              
70             The rest of the documentation details each of the object
71             methods. Internal methods are usually preceded with a _
72              
73             =cut
74              
75             # Let the code begin...
76              
77              
78             package Bio::Location::AvWithinCoordPolicy;
79 1     1   656 use strict;
  1         1  
  1         24  
80              
81              
82 1     1   3 use base qw(Bio::Location::WidestCoordPolicy);
  1         0  
  1         254  
83              
84             sub new {
85 1     1 1 2 my ($class, @args) = @_;
86 1         6 my $self = $class->SUPER::new(@args);
87              
88 1         3 return $self;
89             }
90              
91              
92              
93             =head2 start
94              
95             Title : start
96             Usage : $start = $policy->start($location);
97             Function: Get the integer-valued start coordinate of the given location as
98             computed by this computation policy.
99             Returns : A positive integer number.
100             Args : A Bio::LocationI implementing object.
101              
102             =cut
103              
104             sub start {
105 3     3 1 3 my ($self,$loc) = @_;
106              
107 3 50 33     6 if(($loc->start_pos_type() eq 'WITHIN') ||
108             ($loc->start_pos_type() eq 'BETWEEN')) {
109 3         4 my ($min, $max) = ($loc->min_start(), $loc->max_start());
110 3 50 33     22 return int(($min+$max)/2) if($min && $max);
111             }
112 0         0 return $self->SUPER::start($loc);
113             }
114              
115             =head2 end
116              
117             Title : end
118             Usage : $end = $policy->end($location);
119             Function: Get the integer-valued end coordinate of the given location as
120             computed by this computation policy.
121             Returns : A positive integer number.
122             Args : A Bio::LocationI implementing object.
123              
124             =cut
125              
126             sub end {
127 3     3 1 3 my ($self,$loc) = @_;
128              
129 3 50 33     5 if(($loc->end_pos_type() eq 'WITHIN') ||
130             ($loc->end_pos_type() eq 'BETWEEN')) {
131 3         6 my ($min, $max) = ($loc->min_end(), $loc->max_end());
132 3 50 33     20 return int(($min+$max)/2) if($min && $max);
133             }
134 0           return $self->SUPER::end($loc);
135             }
136              
137             1;
138