comparison variant_effect_predictor/Bio/Map/OrderedPositionWithDistance.pm @ 0:2bc9b66ada89 draft default tip

Uploaded
author mahtabm
date Thu, 11 Apr 2013 06:29:17 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2bc9b66ada89
1 # BioPerl module for Bio::Map::OrderedPositionWithDistance
2 #
3 # Cared for by Chad Matsalla <bioinformatics1@dieselwurks.com>
4 #
5 # Copyright Chad Matsalla
6 #
7 # You may distribute this module under the same terms as perl itself
8
9 # POD documentation - main docs before the code
10
11 =head1 NAME
12
13 Bio::Map::OrderedPositionWithDistance - Abstracts the notion of a member
14 of an ordered list of markers. Each marker is a certain distance
15 from the one in the ordered list before it.
16
17 =head1 SYNOPSIS
18
19 use Bio::Map::OrderedPositionWithDistance;
20 # the first marker in the sequence
21 my $position = new Bio::Map::OrderedPositionWithDistance(-positions => 1,
22 -distance => 22.3 );
23 # the second marker in the sequence, 15.6 units from the fist one
24 my $position2 = new Bio::Map::OrderedPositionWithDistance(-positions => 2,
25 -distance => 15.6 );
26 # the third marker in the sequence, coincidental with the second
27 # marker
28 my $position3 = new Bio::Map::OrderedPositionWithDistance(-positions => 3,
29 -distance => 0 );
30
31
32 =head1 DESCRIPTION
33
34 This object is an implementation of the PositionI interface and the
35 Position object handles the specific values of a position.
36 OrderedPositionWithDistance is intended to be slightly more specific
37 then Position but only specific enough for a parser from the MarkerIO
38 subsystem to create and then pass to a client application to bless into
39 the proper type. For an example of how this is intended to work, see the
40 Mapmaker.pm.
41
42 No units are assumed here - units are handled by context of which Map
43 a position is placed in.
44
45 Se Bio::Map::Position for additional information.
46
47 =head1 FEEDBACK
48
49 =head2 Mailing Lists
50
51 User feedback is an integral part of the evolution of this and other
52 Bioperl modules. Send your comments and suggestions preferably to
53 the Bioperl mailing list. Your participation is much appreciated.
54
55 bioperl-l@bioperl.org - General discussion
56 http://bioperl.org/MailList.shtml - About the mailing lists
57
58 =head2 Reporting Bugs
59
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via
62 email or the web:
63
64 bioperl-bugs@bioperl.org
65 http://bugzilla.bioperl.org/
66
67 =head1 AUTHOR - Chad Matsalla
68
69 Email bioinformatics1@dieselwurks.com
70
71 =head1 CONTRIBUTORS
72
73 Lincoln Stein, lstein@cshl.org
74 Heikki Lehvaslaiho, heikki@ebi.ac.uk
75
76 =head1 APPENDIX
77
78 The rest of the documentation details each of the object methods.
79 Internal methods are usually preceded with a _
80
81 =cut
82
83
84 # Let the code begin...
85
86
87 package Bio::Map::OrderedPositionWithDistance;
88 use vars qw(@ISA);
89 use strict;
90
91 use Bio::Root::Root;
92 use Bio::Map::Position;
93
94 @ISA = qw(Bio::Map::Position);
95
96 =head2 new
97
98 Title : new
99 Usage : my $obj = new Bio::Map::OrderedPositionWithDistance();
100 Function: Builds a new Bio::Map::OrderedPositionWithDistance object
101 Returns : Bio::Map::OrderedPositionWithDistance
102 Args : -positions - Should be a single value representing the order
103 of this marker within the list of markers
104 -distance - The distance this marker is from the marker before it.
105 0 reflects coincidentality.
106
107 =cut
108
109 sub new {
110 my($class,@args) = @_;
111 my $self = $class->SUPER::new(@args);
112 $self->{'_positions'} = [];
113 my ($positions,$distance) = $self->_rearrange([qw(POSITIONS DISTANCE)], @args);
114 if( ref($positions) =~ /array/i ) {
115 foreach my $p ( @$positions ) {
116 $self->add_position($p);
117 }
118 } else {
119 $self->add_position($positions);
120 }
121 $distance && $self->distance($distance);
122
123 return $self;
124
125 }
126
127
128 =head2 distance($new_distance)
129
130 Title : distance($new_distance)
131 Usage : $position->distance(new_distance) _or_
132 $position->distance()
133 Function: get/set the distance of this position from the previous marker
134 Returns : A scalar representing the current distance for this position.
135 Args : If $new_distance is provided the distance of this Position will
136 be set to $new_distance
137
138 =cut
139
140 sub distance {
141 my ($self,$distance) = @_;
142 if ($distance) {
143 $self->{'_distance'} = $distance;
144 }
145 return $self->{'_distance'};
146 }
147
148
149 1;