tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / Bio / Location / AvWithinCoordPolicy.pm
blobcc6c080be22f25b1d1c6396a675c8682ecb87b2b
1 # $Id$
3 # BioPerl module for Bio::Location::AvWithinCoordPolicy
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Hilmar Lapp <hlapp@gmx.net>
8 # and Jason Stajich <jason@bioperl.org>
10 # Copyright Hilmar Lapp, Jason Stajich
12 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Location::AvWithinCoordPolicy - class implementing
18 Bio::Location::CoordinatePolicy as the average for WITHIN and the widest possible and reasonable range otherwise
20 =head1 SYNOPSIS
22 See Bio::Location::CoordinatePolicyI
24 =head1 DESCRIPTION
26 CoordinatePolicyI implementing objects are used by Bio::LocationI
27 implementing objects to determine integer-valued coordinates when
28 asked for it.
30 This class will compute the coordinates such that for fuzzy locations
31 of type WITHIN and BETWEEN the average of the two limits will be
32 returned, and for all other locations it will return the widest
33 possible range, but by using some common sense. This means that
34 e.g. locations like "E<lt>5..100" (start before position 5) will return 5
35 as start (returned values have to be positive integers).
37 =head1 FEEDBACK
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to one
41 of the Bioperl mailing lists. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 =head2 Support
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
57 =head2 Reporting Bugs
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 the bugs and their resolution. Bug reports can be submitted via the
61 web:
63 http://bugzilla.open-bio.org/
65 =head1 AUTHOR - Hilmar Lapp, Jason Stajich
67 Email E<lt>hlapp-at-gmx-dot-netE<gt>, E<lt>jason-at-bioperl-dot-orgE<gt>
69 =head1 APPENDIX
71 The rest of the documentation details each of the object
72 methods. Internal methods are usually preceded with a _
74 =cut
76 # Let the code begin...
79 package Bio::Location::AvWithinCoordPolicy;
80 use strict;
83 use base qw(Bio::Location::WidestCoordPolicy);
85 sub new {
86 my ($class, @args) = @_;
87 my $self = $class->SUPER::new(@args);
89 return $self;
94 =head2 start
96 Title : start
97 Usage : $start = $policy->start($location);
98 Function: Get the integer-valued start coordinate of the given location as
99 computed by this computation policy.
100 Returns : A positive integer number.
101 Args : A Bio::LocationI implementing object.
103 =cut
105 sub start {
106 my ($self,$loc) = @_;
108 if(($loc->start_pos_type() eq 'WITHIN') ||
109 ($loc->start_pos_type() eq 'BETWEEN')) {
110 my ($min, $max) = ($loc->min_start(), $loc->max_start());
111 return int(($min+$max)/2) if($min && $max);
113 return $self->SUPER::start($loc);
116 =head2 end
118 Title : end
119 Usage : $end = $policy->end($location);
120 Function: Get the integer-valued end coordinate of the given location as
121 computed by this computation policy.
122 Returns : A positive integer number.
123 Args : A Bio::LocationI implementing object.
125 =cut
127 sub end {
128 my ($self,$loc) = @_;
130 if(($loc->end_pos_type() eq 'WITHIN') ||
131 ($loc->end_pos_type() eq 'BETWEEN')) {
132 my ($min, $max) = ($loc->min_end(), $loc->max_end());
133 return int(($min+$max)/2) if($min && $max);
135 return $self->SUPER::end($loc);