0
|
1 # $Id: AvWithinCoordPolicy.pm,v 1.4 2002/12/01 00:05:20 jason Exp $
|
|
2 #
|
|
3 # BioPerl module for Bio::Location::AvWithinCoordPolicy
|
|
4 #
|
|
5 # Cared for by Hilmar Lapp <hlapp@gmx.net>
|
|
6 # and Jason Stajich <jason@bioperl.org>
|
|
7 #
|
|
8 # Copyright Hilmar Lapp, Jason Stajich
|
|
9 #
|
|
10 # You may distribute this module under the same terms as perl itself
|
|
11 # POD documentation - main docs before the code
|
|
12
|
|
13 =head1 NAME
|
|
14
|
|
15 Bio::Location::AvWithinCoordPolicy - class implementing
|
|
16 Bio::Location::CoordinatePolicy as the average for WITHIN and the widest possible and reasonable range otherwise
|
|
17
|
|
18 =head1 SYNOPSIS
|
|
19
|
|
20 See Bio::Location::CoordinatePolicyI
|
|
21
|
|
22 =head1 DESCRIPTION
|
|
23
|
|
24 CoordinatePolicyI implementing objects are used by Bio::LocationI
|
|
25 implementing objects to determine integer-valued coordinates when
|
|
26 asked for it.
|
|
27
|
|
28 This class will compute the coordinates such that for fuzzy locations
|
|
29 of type WITHIN and BETWEEN the average of the two limits will be
|
|
30 returned, and for all other locations it will return the widest
|
|
31 possible range, but by using some common sense. This means that
|
|
32 e.g. locations like "E<lt>5..100" (start before position 5) will return 5
|
|
33 as start (returned values have to be positive integers).
|
|
34
|
|
35 =head1 FEEDBACK
|
|
36
|
|
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.
|
|
40
|
|
41 bioperl-l@bioperl.org - General discussion
|
|
42 http://bio.perl.org/MailList.html - About the mailing lists
|
|
43
|
|
44 =head2 Reporting Bugs
|
|
45
|
|
46 Report bugs to the Bioperl bug tracking system to help us keep track
|
|
47 the bugs and their resolution. Bug reports can be submitted via email
|
|
48 or the web:
|
|
49
|
|
50 bioperl-bugs@bio.perl.org
|
|
51 http://bugzilla.bioperl.org/
|
|
52
|
|
53 =head1 AUTHOR - Hilmar Lapp, Jason Stajich
|
|
54
|
|
55 Email E<lt>hlapp@gmx.netE<gt>, E<lt>jason@bioperl.orgE<gt>
|
|
56
|
|
57 =head1 APPENDIX
|
|
58
|
|
59 The rest of the documentation details each of the object
|
|
60 methods. Internal methods are usually preceded with a _
|
|
61
|
|
62 =cut
|
|
63
|
|
64 # Let the code begin...
|
|
65
|
|
66
|
|
67 package Bio::Location::AvWithinCoordPolicy;
|
|
68 use vars qw(@ISA);
|
|
69 use strict;
|
|
70
|
|
71 use Bio::Location::WidestCoordPolicy;
|
|
72
|
|
73 @ISA = qw(Bio::Location::WidestCoordPolicy);
|
|
74
|
|
75 sub new {
|
|
76 my ($class, @args) = @_;
|
|
77 my $self = $class->SUPER::new(@args);
|
|
78
|
|
79 return $self;
|
|
80 }
|
|
81
|
|
82
|
|
83
|
|
84 =head2 start
|
|
85
|
|
86 Title : start
|
|
87 Usage : $start = $policy->start($location);
|
|
88 Function: Get the integer-valued start coordinate of the given location as
|
|
89 computed by this computation policy.
|
|
90 Returns : A positive integer number.
|
|
91 Args : A Bio::LocationI implementing object.
|
|
92
|
|
93 =cut
|
|
94
|
|
95 sub start {
|
|
96 my ($self,$loc) = @_;
|
|
97
|
|
98 if(($loc->start_pos_type() eq 'WITHIN') ||
|
|
99 ($loc->start_pos_type() eq 'BETWEEN')) {
|
|
100 my ($min, $max) = ($loc->min_start(), $loc->max_start());
|
|
101 return int(($min+$max)/2) if($min && $max);
|
|
102 }
|
|
103 return $self->SUPER::start($loc);
|
|
104 }
|
|
105
|
|
106 =head2 end
|
|
107
|
|
108 Title : end
|
|
109 Usage : $end = $policy->end($location);
|
|
110 Function: Get the integer-valued end coordinate of the given location as
|
|
111 computed by this computation policy.
|
|
112 Returns : A positive integer number.
|
|
113 Args : A Bio::LocationI implementing object.
|
|
114
|
|
115 =cut
|
|
116
|
|
117 sub end {
|
|
118 my ($self,$loc) = @_;
|
|
119
|
|
120 if(($loc->end_pos_type() eq 'WITHIN') ||
|
|
121 ($loc->end_pos_type() eq 'BETWEEN')) {
|
|
122 my ($min, $max) = ($loc->min_end(), $loc->max_end());
|
|
123 return int(($min+$max)/2) if($min && $max);
|
|
124 }
|
|
125 return $self->SUPER::end($loc);
|
|
126 }
|
|
127
|
|
128 1;
|
|
129
|