maint: restructure to use Dist::Zilla
[bioperl-live.git] / lib / Bio / Location / AvWithinCoordPolicy.pm
blob1f3fb50604d97204300c14333958ca79739c9f49
2 # BioPerl module for Bio::Location::AvWithinCoordPolicy
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Hilmar Lapp <hlapp@gmx.net>
7 # and Jason Stajich <jason@bioperl.org>
9 # Copyright Hilmar Lapp, Jason Stajich
11 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Location::AvWithinCoordPolicy - class implementing
17 Bio::Location::CoordinatePolicy as the average for WITHIN and the widest possible and reasonable range otherwise
19 =head1 SYNOPSIS
21 See Bio::Location::CoordinatePolicyI
23 =head1 DESCRIPTION
25 CoordinatePolicyI implementing objects are used by Bio::LocationI
26 implementing objects to determine integer-valued coordinates when
27 asked for it.
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 "E<lt>5..100" (start before position 5) will return 5
34 as start (returned values have to be positive integers).
36 =head1 FEEDBACK
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.
42 bioperl-l@bioperl.org - General discussion
43 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45 =head2 Support
47 Please direct usage questions or support issues to the mailing list:
49 I<bioperl-l@bioperl.org>
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.
56 =head2 Reporting Bugs
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:
62 https://github.com/bioperl/bioperl-live/issues
64 =head1 AUTHOR - Hilmar Lapp, Jason Stajich
66 Email E<lt>hlapp-at-gmx-dot-netE<gt>, E<lt>jason-at-bioperl-dot-orgE<gt>
68 =head1 APPENDIX
70 The rest of the documentation details each of the object
71 methods. Internal methods are usually preceded with a _
73 =cut
75 # Let the code begin...
78 package Bio::Location::AvWithinCoordPolicy;
79 use strict;
82 use base qw(Bio::Location::WidestCoordPolicy);
84 sub new {
85 my ($class, @args) = @_;
86 my $self = $class->SUPER::new(@args);
88 return $self;
93 =head2 start
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.
102 =cut
104 sub start {
105 my ($self,$loc) = @_;
107 if(($loc->start_pos_type() eq 'WITHIN') ||
108 ($loc->start_pos_type() eq 'BETWEEN')) {
109 my ($min, $max) = ($loc->min_start(), $loc->max_start());
110 return int(($min+$max)/2) if($min && $max);
112 return $self->SUPER::start($loc);
115 =head2 end
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.
124 =cut
126 sub end {
127 my ($self,$loc) = @_;
129 if(($loc->end_pos_type() eq 'WITHIN') ||
130 ($loc->end_pos_type() eq 'BETWEEN')) {
131 my ($min, $max) = ($loc->min_end(), $loc->max_end());
132 return int(($min+$max)/2) if($min && $max);
134 return $self->SUPER::end($loc);