comparison variant_effect_predictor/Bio/Map/LinkageMap.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 # BioPerl module for Bio::Map::LinkageMap
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::LinkageMap - A representation of a genetic linkage map.
14
15 =head1 SYNOPSIS
16
17 use Bio::Map::LinkageMap;
18 # create a new map
19 my $map = new Bio::Map::LinkageMap(-name => 'Chads Superterriffic Map',
20 -type => 'Linkage',
21 -units=> 'cM');
22 # create the location of a marker for that map
23 my $position = new Bio::Map::LinkagePosition( -positions => 1,
24 -distance => "22.3");
25 # create a marker and place it at that position
26 my $marker = new Bio::Map::Marker::Microsatellite(
27 -name => 'SuuuperMarker',
28 -position => $position);
29 # place that marker on that map
30 $map->add_element($marker);
31
32 # done!
33
34 =head1 DESCRIPTION
35
36 This object describes the basic functionality of a genetic linkage map in
37 Bioperl. Each 'position' can have one or more markers that map some number of
38 units from the markers at the previous position.
39
40 =head1 FEEDBACK
41
42 =head2 Mailing Lists
43
44 User feedback is an integral part of the evolution of this and other
45 Bioperl modules. Send your comments and suggestions preferably to
46 the Bioperl mailing list. Your participation is much appreciated.
47
48 bioperl-l@bioperl.org - General discussion
49 http://bioperl.org/MailList.shtml - About the mailing lists
50
51 =head2 Reporting Bugs
52
53 Report bugs to the Bioperl bug tracking system to help us keep track
54 of the bugs and their resolution. Bug reports can be submitted via
55 email or the web:
56
57 bioperl-bugs@bioperl.org
58 http://bugzilla.bioperl.org/
59
60 =head1 AUTHOR - Chad Matsalla
61
62 Email bioinformatics1@dieselwurks.com
63
64 =head1 CONTRIBUTORS
65
66 Lincoln Stein lstein@cshl.org
67 Heikki Lehvaslaiho heikki@ebi.ac.uk
68 Jason Stajich jason@bioperl.org
69
70 =head1 APPENDIX
71
72 The rest of the documentation details each of the object methods.
73 Internal methods are usually preceded with a _
74
75 =cut
76
77
78 # Let the code begin...
79
80 package Bio::Map::LinkageMap;
81 use vars qw(@ISA);
82 use strict;
83 use Bio::Map::SimpleMap;
84
85 @ISA = qw(Bio::Map::SimpleMap);
86
87 =head2 new
88
89 Title : new
90 Usage : my $linkage_map = new Bio::Map::LinkageMap();
91 Function: Builds a new Bio::Map::LinkageMap object
92 Returns : Bio::Map::LinkageMap
93 Args : -name => the name of the map (string) [optional]
94 -type => the type of this map (string, defaults to Linkage) [optional]
95 -species => species for this map (Bio::Species) [optional]
96 -units => the map units (string, defaults to cM) [optional]
97 -elements=> elements to initialize with
98 (arrayref of Bio::Map::MappableI objects) [optional]
99
100 -uid => Unique ID of this map
101 =cut
102
103 # new provided by SimpleMap
104
105
106
107 =head2 length()
108
109 Title : length()
110 Usage : my $length = $map->length();
111 Function: Retrieves the length of the map. In the case of a LinkageMap, the
112 length is the sum of all marker distances.
113 Returns : An integer representing the length of this LinkageMap. Will return
114 undef if length is not calculateable
115 Args : None.
116
117
118 =cut
119
120 sub length {
121 my ($self) = @_;
122 my $total_distance;
123 foreach (@{$self->{'_elements'}}) {
124 if ($_) {
125 $total_distance += ($_->position()->each_position_value($self))[0];
126 }
127 }
128 return $total_distance;
129 }
130
131 =head2 add_element($marker)
132
133 Title : add_element($marker)
134 Usage : $map->add_element($marker)
135 Function: Add a Bio::Map::MappableI object to the Map
136 Returns : none
137 Args : Bio::Map::MappableI object
138 Notes : It is strongly recommended that you use a
139 Bio::Map::LinkagePosition as the position in any
140 Bio::Map::Mappable that you create to place on this
141 map. Using some other Bio::Map::Position might work but might
142 be unpredictable.
143 N.B. I've added Bio::Map::OrderedPosition which should achieve
144 similar things from LinkagePosition and will work for
145 RH markers too.
146 =cut
147
148 #'
149 sub _add_element {
150 my ($self,$marker) = @_;
151
152 my $o_position = $marker->position();
153
154 $self->debug( "marker position is ". $marker->position());
155 # print("add_element: \$o_position is $o_position\n");
156 # print("add_element: \$marker is $marker\n");
157
158 my $position;
159 unless ( $o_position->isa('Bio::Map::LinkagePosition') ||
160 $o_position->isa('Bio::Map::OrderedPosition')
161 ) {
162 $self->warn("You really should use a Linkage Position for this object. This insures that there is only one position. Trying anyway...");
163 my @p = ( $o_position->each_position_value($self));
164 $position = shift @p;
165 if( ! defined $position ) {
166 $self->throw("This marker ($marker) does not have a position in this map ($self)");
167 }
168 } else {
169 $position = $o_position->order;
170 }
171
172 if ($self->{'_elements'}[$position]) {
173 $self->warn("Replacing the marker in position $position because in a linkage map the position is a key.");
174 }
175 $self->{'_elements'}[$position] = $marker;
176 }
177
178 =head2 each_element
179
180 Title : each_element
181 Usage : my @elements = $map->each_element;
182 Function: Retrieves all the elements in a map
183 _ordered_.
184 Returns : An array containing MappableI objects.
185 Args : None.
186 Notes : This is a useless concept in the context of a linkage map but is
187 included if you want a list of all of the marker names on the map.
188
189 =cut
190
191 sub each_element {
192 my ($self) = @_;
193 return @{$self->{'_elements'}};
194 }
195
196 =head2 implemented by Bio::Map::SimpleMap
197
198 =cut
199
200 =head2 name($new_name)
201
202 Title : name($new_name)
203 Usage : my $name = $map->name($new_name) _or_
204 my $length = $map->name()
205 Function: Get/set the name of the map.
206 Returns : The current name of the map.
207 Args : If provided, the name of the map is set to $new_name.
208
209 =head2 species
210
211 Title : species
212 Usage : my $species = $map->species;
213 Function: Get/Set Species for a map
214 Returns : Bio::Species object
215 Args : (optional) Bio::Species
216
217
218 =head2 units
219
220 Title : units
221 Usage : $map->units('cM');
222 Function: Get/Set units for a map
223 Returns : units for a map
224 Args : units for a map (string)
225
226
227 =head2 type
228
229 Title : type
230 Usage : my $type = $map->type
231 Function: Get/Set Map type
232 Returns : String coding map type
233 Args : (optional) string
234
235 =head2 unique_id
236
237 Title : unique_id
238 Usage : my $id = $map->unique_id;
239 Function: Get/Set the unique ID for this map
240 Returns : a unique identifier
241 Args : [optional] new identifier to set
242
243 =cut
244
245 1;