tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / Bio / Location / NarrowestCoordPolicy.pm
blobba25be3027a56bfe558851046e05794cf44e761c
1 # $Id$
3 # BioPerl module for Bio::Location::NarrowestCoordPolicy
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::NarrowestCoordPolicy - class implementing
18 Bio::Location::CoordinatePolicy as the narrowest possible and reasonable range
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 always the narrowest possible
31 range is returned, but by using some common sense. This means that e.g.
32 locations like "E<gt>5..100" (start before position 5) will return 5 as start
33 (returned values have to be positive integers).
35 =head1 FEEDBACK
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to one
39 of the Bioperl mailing lists. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 =head2 Support
46 Please direct usage questions or support issues to the mailing list:
48 I<bioperl-l@bioperl.org>
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
55 =head2 Reporting Bugs
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 the bugs and their resolution. Bug reports can be submitted via the
59 web:
61 http://bugzilla.open-bio.org/
63 =head1 AUTHOR - Hilmar Lapp, Jason Stajich
65 Email E<lt>hlapp-at-gmx.netE<gt>, E<lt>jason@bioperl.orgE<gt>
67 =head1 APPENDIX
69 The rest of the documentation details each of the object
70 methods. Internal methods are usually preceded with a _
72 =cut
74 # Let the code begin...
77 package Bio::Location::NarrowestCoordPolicy;
78 use strict;
81 use base qw(Bio::Root::Root Bio::Location::CoordinatePolicyI);
83 sub new {
84 my ($class, @args) = @_;
85 my $self = $class->SUPER::new(@args);
87 return $self;
91 =head2 start
93 Title : start
94 Usage : $start = $policy->start($location);
95 Function: Get the integer-valued start coordinate of the given location as
96 computed by this computation policy.
97 Returns : A positive integer number.
98 Args : A Bio::LocationI implementing object.
100 =cut
102 sub start {
103 my ($self,$loc) = @_;
105 # For performance reasons we don't check that it's indeed a Bio::LocationI
106 # object. Hopefully, Location-object programmers are smart enough.
107 my $pos = $loc->max_start();
108 # if max is not defined or equals 0 we resort to min
109 $pos = $loc->min_start() if(! $pos);
110 return $pos;
113 =head2 end
115 Title : end
116 Usage : $end = $policy->end($location);
117 Function: Get the integer-valued end coordinate of the given location as
118 computed by this computation policy.
119 Returns : A positive integer number.
120 Args : A Bio::LocationI implementing object.
122 =cut
124 sub end {
125 my ($self,$loc) = @_;
127 # For performance reasons we don't check that it's indeed a Bio::LocationI
128 # object. Hopefully, Location-object programmers are smart enough.
129 my $pos = $loc->min_end();
130 # if min is not defined or equals 0 we resort to max
131 $pos = $loc->max_end() if(! $pos);
132 return $pos;