2 # BioPerl module for Bio::Map::MappableI
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Sendu Bala <bix@sendu.me.uk>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Map::MappableI - An object that can be placed in a map
20 # do not use this module directly
21 # See Bio::Map::Mappable for an example of
26 This object handles the generic notion of an element placed on a
27 (linear) Map. A Mappable can have multiple positions in multiple maps, such as
28 is the case of Restriction enzyme cut sites on sequence maps. For exact
29 information about a mappable's position in a map one must query the associate
30 PositionI objects which are accessible through the get_positions() method.
36 User feedback is an integral part of the evolution of this and other
37 Bioperl modules. Send your comments and suggestions preferably to
38 the Bioperl mailing list. Your participation is much appreciated.
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45 Please direct usage questions or support issues to the mailing list:
47 I<bioperl-l@bioperl.org>
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 of the bugs and their resolution. Bug reports can be submitted via the
60 https://redmine.open-bio.org/projects/bioperl/
62 =head1 AUTHOR - Jason Stajich
64 Email jason@bioperl.org
68 Heikki Lehvaslaiho heikki-at-bioperl-dot-org
69 Lincoln Stein lstein@cshl.org
70 Sendu Bala bix@sendu.me.uk
74 The rest of the documentation details each of the object methods.
75 Internal methods are usually preceded with a _
79 # Let the code begin...
81 package Bio
::Map
::MappableI
;
83 use Bio
::Map
::PositionHandler
;
85 use base
qw(Bio::Map::EntityI Bio::AnnotatableI);
87 =head2 EntityI methods
89 These are fundamental to coordination of Mappables and other entities, so are
90 implemented at the interface level
94 =head2 get_position_handler
96 Title : get_position_handler
97 Usage : my $position_handler = $entity->get_position_handler();
98 Function: Gets a PositionHandlerI that $entity is registered with.
99 Returns : Bio::Map::PositionHandlerI object
104 sub get_position_handler
{
106 unless (defined $self->{_eh
}) {
107 my $ph = Bio
::Map
::PositionHandler
->new(-self
=> $self);
114 =head2 PositionHandlerI-related methods
116 These are fundamental to coordination of Mappables and other entities, so are
117 implemented at the interface level
124 Usage : $mappable->add_position($position);
125 Function: Add a position to this mappable (defining where on which map it is).
127 Args : L<Bio::Map::PositionI> object
133 # actually, we allow multiple positions to be set at once
134 $self->get_position_handler->add_positions(@_);
139 Title : get_positions
140 Usage : my @positions = $mappable->get_positions();
141 Function: Get all the Positions of this Mappable (sorted).
142 Returns : Array of L<Bio::Map::PositionI> objects
143 Args : none for all, OR
144 L<Bio::Map::MapI> object for positions on the given map, AND/OR some
145 other true value to avoid sorting
150 my ($self, $thing, $no_sort) = @_;
152 if (ref($thing) && $thing->isa('Bio::Map::MapI')) {
158 my @positions = $self->get_position_handler->get_positions($map);
159 return @positions if @positions == 1;
163 # @positions = sort { $a->sortable <=> $b->sortable } @positions;
164 # directly since sortable() can result in the call of another sort
165 # routine and cause problems; pre-compute sortable values instead
166 # (which is also more efficient)
167 @positions = map { $_->[1] }
168 sort { $a->[0] <=> $b->[0] }
169 map { [$_->sortable, $_] }
177 Title : each_position
178 Function: Synonym of the get_positions() method.
179 Status : deprecated, will be removed in next version
183 *each_position
= \
&get_positions
;
185 =head2 purge_positions
187 Title : purge_positions
188 Usage : $mappable->purge_positions();
189 Function: Remove positions from this mappable.
191 Args : none to remove all positions, OR
192 L<Bio::Map::PositionI> object to remove just that Position, OR
193 L<Bio::Map::MapI> object to remove only those positions on the given
198 sub purge_positions
{
199 my ($self, $thing) = @_;
200 $self->get_position_handler->purge_positions($thing);
206 Usage : my @maps = $marker->known_maps()
207 Function: Returns the maps that this mappable is found on
208 Returns : Array of L<Bio::Map::MapI> objects
215 return $self->get_position_handler->get_other_entities;
218 =head2 MappableI-specific methods
225 Usage : my $name = $marker->name();
226 $marker->name($new_name);
227 Function: Get/Set the name for this Mappable.
228 Returns : A scalar representing the current name of this Mappable
236 $self->throw_not_implemented();
242 Usage : my $id = $marker->id();
243 $marker->id($new_id);
244 Function: Get/Set the id for this Mappable.
245 Returns : A scalar representing the current id of this Mappable
253 $self->throw_not_implemented();
259 Usage : if ($marker->in_map($map)) {...}
260 Function: Tests if this mappable is found on a specific map
262 Args : L<Bio::Map::MapI>
268 $self->throw_not_implemented();
271 =head1 RangeI-related Methods
273 They throw an error if start and end are not defined in the Positions of the
281 Usage : if ($mappable->equals($other_mappable)) {...}
282 my @equal_positions = $mappable->equals($other_mappable);
283 Function: Finds the positions in this mappable that are equal to any
284 comparison positions.
285 Returns : array of L<Bio::Map::PositionI> objects
286 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
287 this one to (mandatory)
288 arg #2 = optionally, the key => value pairs below
289 -map => Bio::Map::MapI : optionally a Map to only consider
290 positions on the given map
291 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
292 the Positions equal in terms of
293 their relative position to the
294 thing described by that Relative
300 $self->throw_not_implemented();
306 Usage : if ($mappable->overlaps($other_mappable)) {...}
307 my @overlapping_positions = $mappable->overlaps($other_mappable);
308 Function: Finds the positions in this mappable that overlap with any
309 comparison positions.
310 Returns : array of L<Bio::Map::PositionI> objects
311 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
312 this one to (mandatory)
313 arg #2 = optionally, the key => value pairs below
314 -map => Bio::Map::MapI : optionally a Map to only consider
315 positions on the given map
316 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
317 the Positions overlap in terms of
318 their relative position to the
319 thing described by that Relative
325 $self->throw_not_implemented();
331 Usage : if ($mappable->contains($other_mappable)) {...}
332 my @container_positions = $mappable->contains($other_mappable);
333 Function: Finds the positions in this mappable that contain any comparison
335 Returns : array of L<Bio::Map::PositionI> objects
336 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
337 this one to (mandatory)
338 arg #2 = optionally, the key => value pairs below
339 -map => Bio::Map::MapI : optionally a Map to only consider
340 positions on the given map
341 -relative => Bio::Map::RelativeI : optionally a Relative to ask if
342 the Positions contains in terms of
343 their relative position to the
344 thing described by that Relative
350 $self->throw_not_implemented();
356 Usage : my $position = $mappable->intersection($other_mappable);
357 my $position = Bio::Map::Mappable->intersection(\@mappables);
358 Function: Make the position that is at the intersection of all positions of all
360 Returns : L<Bio::Map::PositionI> object or undef (if not all positions overlap)
361 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
362 this one to, or an array ref of such objects (mandatory)
363 arg #2 = optionally, the key => value pairs below
364 -map => Bio::Map::MapI : optionally a Map to only consider
365 positions on the given map
366 -relative => Bio::Map::RelativeI : optionally a Relative to to ask
367 how the Positions intersect in
368 terms of their relative position
369 to the thing described by that
376 $self->throw_not_implemented();
382 Usage : my $position = $mappable->union($other_mappable);
383 my $position = Bio::Map::Mappable->union(@mappables);
384 Function: Make the minimal position that contains all of the positions of all
386 Returns : L<Bio::Map::PositionI> object or undef (if not all positions overlap)
387 Args : arg #1 = L<Bio::Map::MappableI> OR L<Bio::Map::PositionI> to compare
388 this one to, or an array ref of such objects (mandatory)
389 arg #2 = optionally, the key => value pairs below
390 -map => Bio::Map::MapI : optionally a Map to only consider
391 positions on the given map
392 -relative => Bio::Map::RelativeI : optionally a Relative to to ask
393 if the union of the Positions in
394 terms of their relative position
395 to the thing described by that
402 $self->throw_not_implemented();