3 # BioPerl module for Bio::Map::MappableI
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Map::MappableI - An object that can be placed in a map
21 # do not use this module directly
22 # See Bio::Map::Mappable for an example of
27 This object handles the generic notion of an element placed on a
28 (linear) Map. A Mappable can have multiple positions in multiple maps, such as
29 is the case of Restriction enzyme cut sites on sequence maps. For exact
30 information about a mappable's position in a map one must query the associate
31 PositionI objects which are accessible through the get_positions() method.
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 Please direct usage questions or support issues to the mailing list:
48 L<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.
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via the
61 http://bugzilla.open-bio.org/
63 =head1 AUTHOR - Jason Stajich
65 Email jason@bioperl.org
69 Heikki Lehvaslaiho heikki-at-bioperl-dot-org
70 Lincoln Stein lstein@cshl.org
71 Sendu Bala bix@sendu.me.uk
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
80 # Let the code begin...
82 package Bio
::Map
::MappableI
;
84 use Bio
::Map
::PositionHandler
;
86 use base
qw(Bio::Map::EntityI Bio::AnnotatableI);
88 =head2 EntityI methods
90 These are fundamental to coordination of Mappables and other entities, so are
91 implemented at the interface level
95 =head2 get_position_handler
97 Title : get_position_handler
98 Usage : my $position_handler = $entity->get_position_handler();
99 Function: Gets a PositionHandlerI that $entity is registered with.
100 Returns : Bio::Map::PositionHandlerI object
105 sub get_position_handler
{
107 unless (defined $self->{_eh
}) {
108 my $ph = Bio
::Map
::PositionHandler
->new(-self
=> $self);
115 =head2 PositionHandlerI-related methods
117 These are fundamental to coordination of Mappables and other entities, so are
118 implemented at the interface level
125 Usage : $mappable->add_position($position);
126 Function: Add a position to this mappable (defining where on which map it is).
128 Args : L<Bio::Map::PositionI> object
134 # actually, we allow multiple positions to be set at once
135 $self->get_position_handler->add_positions(@_);
140 Title : get_positions
141 Usage : my @positions = $mappable->get_positions();
142 Function: Get all the Positions of this Mappable (sorted).
143 Returns : Array of L<Bio::Map::PositionI> objects
144 Args : none for all, OR
145 L<Bio::Map::MapI> object for positions on the given map, AND/OR some
146 other true value to avoid sorting
151 my ($self, $thing, $no_sort) = @_;
153 if (ref($thing) && $thing->isa('Bio::Map::MapI')) {
159 my @positions = $self->get_position_handler->get_positions($map);
160 return @positions if @positions == 1;
164 # @positions = sort { $a->sortable <=> $b->sortable } @positions;
165 # directly since sortable() can result in the call of another sort
166 # routine and cause problems; pre-compute sortable values instead
167 # (which is also more efficient)
168 @positions = map { $_->[1] }
169 sort { $a->[0] <=> $b->[0] }
170 map { [$_->sortable, $_] }
178 Title : each_position
179 Function: Synonym of the get_positions() method.
180 Status : deprecated, will be removed in next version
184 *each_position
= \
&get_positions
;
186 =head2 purge_positions
188 Title : purge_positions
189 Usage : $mappable->purge_positions();
190 Function: Remove positions from this mappable.
192 Args : none to remove all positions, OR
193 L<Bio::Map::PositionI> object to remove just that Position, OR
194 L<Bio::Map::MapI> object to remove only those positions on the given
199 sub purge_positions
{
200 my ($self, $thing) = @_;
201 $self->get_position_handler->purge_positions($thing);
207 Usage : my @maps = $marker->known_maps()
208 Function: Returns the maps that this mappable is found on
209 Returns : Array of L<Bio::Map::MapI> objects
216 return $self->get_position_handler->get_other_entities;
219 =head2 MappableI-specific methods
226 Usage : my $name = $marker->name();
227 $marker->name($new_name);
228 Function: Get/Set the name for this Mappable.
229 Returns : A scalar representing the current name of this Mappable
237 $self->throw_not_implemented();
243 Usage : my $id = $marker->id();
244 $marker->id($new_id);
245 Function: Get/Set the id for this Mappable.
246 Returns : A scalar representing the current id of this Mappable
254 $self->throw_not_implemented();
260 Usage : if ($marker->in_map($map)) {...}
261 Function: Tests if this mappable is found on a specific map
263 Args : L<Bio::Map::MapI>
269 $self->throw_not_implemented();
272 =head1 RangeI-related Methods
274 They throw an error if start and end are not defined in the Positions of the
282 Usage : if ($mappable->equals($other_mappable)) {...}
283 my @equal_positions = $mappable->equals($other_mappable);
284 Function: Finds the positions in this mappable that are equal to any
285 comparison positions.
286 Returns : array of L<Bio::Map::PositionI> objects
287 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
288 this one to (mandatory)
289 arg #2 = optionally, the key => value pairs below
290 -map => Bio::Map::MapI : optionally a Map to only consider
291 positions on the given map
292 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
293 the Positions equal in terms of
294 their relative position to the
295 thing described by that Relative
301 $self->throw_not_implemented();
307 Usage : if ($mappable->overlaps($other_mappable)) {...}
308 my @overlapping_positions = $mappable->overlaps($other_mappable);
309 Function: Finds the positions in this mappable that overlap with any
310 comparison positions.
311 Returns : array of L<Bio::Map::PositionI> objects
312 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
313 this one to (mandatory)
314 arg #2 = optionally, the key => value pairs below
315 -map => Bio::Map::MapI : optionally a Map to only consider
316 positions on the given map
317 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
318 the Positions overlap in terms of
319 their relative position to the
320 thing described by that Relative
326 $self->throw_not_implemented();
332 Usage : if ($mappable->contains($other_mappable)) {...}
333 my @container_positions = $mappable->contains($other_mappable);
334 Function: Finds the positions in this mappable that contain any comparison
336 Returns : array of L<Bio::Map::PositionI> objects
337 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
338 this one to (mandatory)
339 arg #2 = optionally, the key => value pairs below
340 -map => Bio::Map::MapI : optionally a Map to only consider
341 positions on the given map
342 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
343 the Positions contains in terms of
344 their relative position to the
345 thing described by that Relative
351 $self->throw_not_implemented();
357 Usage : my $position = $mappable->intersection($other_mappable);
358 my $position = Bio::Map::Mappable->intersection(\@mappables);
359 Function: Make the position that is at the intersection of all positions of all
361 Returns : L<Bio::Map::PositionI> object or undef (if not all positions overlap)
362 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
363 this one to, or an array ref of such objects (mandatory)
364 arg #2 = optionally, the key => value pairs below
365 -map => Bio::Map::MapI : optionally a Map to only consider
366 positions on the given map
367 -relative => Bio::Map::RelativeI : optionally a Relative to to ask
368 how the Positions intersect in
369 terms of their relative position
370 to the thing described by that
377 $self->throw_not_implemented();
383 Usage : my $position = $mappable->union($other_mappable);
384 my $position = Bio::Map::Mappable->union(@mappables);
385 Function: Make the minimal position that contains all of the positions of all
387 Returns : L<Bio::Map::PositionI> object or undef (if not all positions overlap)
388 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
389 this one to, or an array ref of such objects (mandatory)
390 arg #2 = optionally, the key => value pairs below
391 -map => Bio::Map::MapI : optionally a Map to only consider
392 positions on the given map
393 -relative => Bio::Map::RelativeI : optionally a Relative to to ask
394 if the union of the Positions in
395 terms of their relative position
396 to the thing described by that
403 $self->throw_not_implemented();