3 # BioPerl module for Bio::LocationI
4 # Cared for by Jason Stajich <jason@bioperl.org>
6 # Copyright Jason Stajich
8 # You may distribute this module under the same terms as perl itself
9 # POD documentation - main docs before the code
13 Bio::LocationI - Abstract interface of a Location on a Sequence
17 # get a LocationI somehow
18 printf( "start = %d, end = %d, strand = %s, seq_id = %s\n",
19 $location->start, $location->end, $location->strand,
21 print "location str is ", $location->to_FTstring(), "\n";
26 This Interface defines the methods for a Bio::LocationI, an object
27 which encapsulates a location on a biological sequence. Locations
28 need not be attached to actual sequences as they are stand alone
29 objects. LocationI objects are used by L<Bio::SeqFeatureI> objects to
30 manage and represent locations for a Sequence Feature.
34 User feedback is an integral part of the evolution of this and other
35 Bioperl modules. Send your comments and suggestions preferably to one
36 of the Bioperl mailing lists. Your participation is much appreciated.
38 bioperl-l@bioperl.org - General discussion
39 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
43 Report bugs to the Bioperl bug tracking system to help us keep track
44 the bugs and their resolution. Bug reports can be submitted via the
47 http://bugzilla.open-bio.org/
49 =head1 AUTHOR - Jason Stajich
51 Email jason-at-bioperl-dot-org
55 The rest of the documentation details each of the object
56 methods. Internal methods are usually preceded with a _
60 # Let the code begin...
62 package Bio
::LocationI
;
67 use base
qw(Bio::RangeI);
72 Usage : my $location_type = $location->location_type();
73 Function: Get location type encoded as text
74 Returns : string ('EXACT', 'WITHIN', 'IN-BETWEEN')
80 my ($self,@args) = @_;
81 $self->throw_not_implemented();
87 Usage : $start = $location->start();
88 Function: Get the start coordinate of this location as defined by
89 the currently active coordinate computation policy. In
90 simple cases, this will return the same number as
91 min_start() and max_start(), in more ambiguous cases like
92 fuzzy locations the number may be equal to one or neither
95 We override this here from RangeI in order to delegate
96 'get' to a L<Bio::Location::CoordinatePolicy> implementing
97 object. Implementing classes may also wish to provide
98 'set' functionality, in which case they *must* override
99 this method. The implementation provided here will throw
100 an exception if called with arguments.
102 Returns : A positive integer value.
105 See L<Bio::Location::CoordinatePolicy> for more information
110 my ($self,@args) = @_;
112 # throw if @args means that we don't support updating information
113 # in the interface but will delegate to the coordinate policy object
114 # for interpreting the 'start' value
116 $self->throw_not_implemented if @args;
117 return $self->coordinate_policy()->start($self);
123 Usage : $end = $location->end();
124 Function: Get the end coordinate of this location as defined by the
125 currently active coordinate computation policy. In simple
126 cases, this will return the same number as min_end() and
127 max_end(), in more ambiguous cases like fuzzy locations
128 the number may be equal to one or neither of both.
130 We override this here from Bio::RangeI in order to delegate
131 'get' to a L<Bio::Location::CoordinatePolicy> implementing
132 object. Implementing classes may also wish to provide
133 'set' functionality, in which case they *must* override
134 this method. The implementation provided here will throw
135 an exception if called with arguments.
137 Returns : A positive integer value.
140 See L<Bio::Location::CoordinatePolicy> and L<Bio::RangeI> for more
146 my ($self,@args) = @_;
148 # throw if @args means that we don't support updating information
149 # in the interface but will delegate to the coordinate policy object
150 # for interpreting the 'end' value
151 $self->throw_not_implemented if @args;
152 return $self->coordinate_policy()->end($self);
158 Usage : my $minstart = $location->min_start();
159 Function: Get minimum starting point of feature.
161 Note that an implementation must not call start() in this method.
163 Returns : integer or undef if no minimum starting point.
170 $self->throw_not_implemented();
176 Usage : my $maxstart = $location->max_start();
177 Function: Get maximum starting point of feature.
179 Note that an implementation must not call start() in this method
180 unless start() is overridden such as not to delegate to the
181 coordinate computation policy object.
183 Returns : integer or undef if no maximum starting point.
190 $self->throw_not_implemented();
193 =head2 start_pos_type
195 Title : start_pos_type
196 Usage : my $start_pos_type = $location->start_pos_type();
197 Function: Get start position type encoded as text
199 Known valid values are 'BEFORE' (<5..100), 'AFTER' (>5..100),
200 'EXACT' (5..100), 'WITHIN' ((5.10)..100), 'BETWEEN', (5^6), with
201 their meaning best explained by their GenBank/EMBL location string
202 encoding in brackets.
204 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
211 $self->throw_not_implemented();
218 Usage : $location->flip_strand();
219 Function: Flip-flop a strand to the opposite
228 $self->strand($self->strand * -1);
234 Usage : my $minend = $location->min_end();
235 Function: Get minimum ending point of feature.
237 Note that an implementation must not call end() in this method
238 unless end() is overridden such as not to delegate to the
239 coordinate computation policy object.
241 Returns : integer or undef if no minimum ending point.
248 $self->throw_not_implemented();
254 Usage : my $maxend = $location->max_end();
255 Function: Get maximum ending point of feature.
257 Note that an implementation must not call end() in this method
258 unless end() is overridden such as not to delegate to the
259 coordinate computation policy object.
261 Returns : integer or undef if no maximum ending point.
268 $self->throw_not_implemented();
274 Usage : my $end_pos_type = $location->end_pos_type();
275 Function: Get end position encoded as text.
277 Known valid values are 'BEFORE' (5..<100), 'AFTER' (5..>100),
278 'EXACT' (5..100), 'WITHIN' (5..(90.100)), 'BETWEEN', (5^6), with
279 their meaning best explained by their GenBank/EMBL location string
280 encoding in brackets.
282 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
289 $self->throw_not_implemented();
295 Usage : my $seqid = $location->seq_id();
296 Function: Get/Set seq_id that location refers to
297 Returns : seq_id (a string)
298 Args : [optional] seq_id value to set
304 $self->throw_not_implemented();
310 Usage : $is_remote_loc = $loc->is_remote()
311 Function: Whether or not a location is a remote location.
313 A location is said to be remote if it is on a different
314 'object' than the object which 'has' this
315 location. Typically, features on a sequence will sometimes
316 have a remote location, which means that the location of
317 the feature is on a different sequence than the one that is
318 attached to the feature. In such a case, $loc->seq_id will
319 be different from $feat->seq_id (usually they will be the
322 While this may sound weird, it reflects the location of the
323 kind of AB18375:450-900 which can be found in GenBank/EMBL
327 Returns : TRUE if the location is a remote location, and FALSE otherwise
334 shift->throw_not_implemented();
337 =head2 coordinate_policy
339 Title : coordinate_policy
340 Usage : $policy = $location->coordinate_policy();
341 $location->coordinate_policy($mypolicy); # set may not be possible
342 Function: Get the coordinate computing policy employed by this object.
344 See L<Bio::Location::CoordinatePolicyI> for documentation
345 about the policy object and its use.
347 The interface *does not* require implementing classes to
348 accept setting of a different policy. The implementation
349 provided here does, however, allow to do so.
351 Implementors of this interface are expected to initialize
352 every new instance with a
353 L<Bio::Location::CoordinatePolicyI> object. The
354 implementation provided here will return a default policy
355 object if none has been set yet. To change this default
356 policy object call this method as a class method with an
357 appropriate argument. Note that in this case only
358 subsequently created Location objects will be affected.
360 Returns : A L<Bio::Location::CoordinatePolicyI> implementing object.
361 Args : On set, a L<Bio::Location::CoordinatePolicyI> implementing object.
363 See L<Bio::Location::CoordinatePolicyI> for more information
368 sub coordinate_policy
{
369 shift->throw_not_implemented();
375 Usage : my $locstr = $location->to_FTstring()
376 Function: returns the FeatureTable string of this location
384 $self->throw_not_implemented();
389 Title : each_Location
390 Usage : @locations = $locObject->each_Location($order);
391 Function: Conserved function call across Location:: modules - will
392 return an array containing the component Location(s) in
393 that object, regardless if the calling object is itself a
394 single location or one containing sublocations.
395 Returns : an array of Bio::LocationI implementing objects
396 Args : Optional sort order to be passed to sub_Location() for Splits
401 my ($self,@args) = @_;
402 $self->throw_not_implemented();