2 # BioPerl module for Bio::LocationI
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 # Cared for by Jason Stajich <jason@bioperl.org>
7 # Copyright Jason Stajich
9 # You may distribute this module under the same terms as perl itself
10 # POD documentation - main docs before the code
14 Bio::LocationI - Abstract interface of a Location on a Sequence
18 # get a LocationI somehow
19 printf( "start = %d, end = %d, strand = %s, seq_id = %s\n",
20 $location->start, $location->end, $location->strand,
22 print "location str is ", $location->to_FTstring(), "\n";
27 This Interface defines the methods for a Bio::LocationI, an object
28 which encapsulates a location on a biological sequence. Locations
29 need not be attached to actual sequences as they are stand alone
30 objects. LocationI objects are used by L<Bio::SeqFeatureI> objects to
31 manage and represent locations for a Sequence Feature.
35 User feedback is an integral part of the evolution of this and other
36 Bioperl modules. Send your comments and suggestions preferably to one
37 of the Bioperl mailing lists. Your participation is much appreciated.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 Please direct usage questions or support issues to the mailing list:
46 I<bioperl-l@bioperl.org>
48 rather than to the module maintainer directly. Many experienced and
49 reponsive experts will be able look at the problem and quickly
50 address it. Please include a thorough description of the problem
51 with code and data examples if at all possible.
55 Report bugs to the Bioperl bug tracking system to help us keep track
56 the bugs and their resolution. Bug reports can be submitted via the
59 https://github.com/bioperl/bioperl-live/issues
61 =head1 AUTHOR - Jason Stajich
63 Email jason-at-bioperl-dot-org
67 The rest of the documentation details each of the object
68 methods. Internal methods are usually preceded with a _
72 # Let the code begin...
74 package Bio
::LocationI
;
80 use base
qw(Bio::RangeI);
85 Usage : my $location_type = $location->location_type();
86 Function: Get location type encoded as text
87 Returns : string ('EXACT', 'WITHIN', 'IN-BETWEEN')
93 my ($self,@args) = @_;
94 $self->throw_not_implemented();
100 Usage : $start = $location->start();
101 Function: Get the start coordinate of this location as defined by
102 the currently active coordinate computation policy. In
103 simple cases, this will return the same number as
104 min_start() and max_start(), in more ambiguous cases like
105 fuzzy locations the number may be equal to one or neither
108 We override this here from RangeI in order to delegate
109 'get' to a L<Bio::Location::CoordinatePolicy> implementing
110 object. Implementing classes may also wish to provide
111 'set' functionality, in which case they *must* override
112 this method. The implementation provided here will throw
113 an exception if called with arguments.
115 Returns : A positive integer value.
118 See L<Bio::Location::CoordinatePolicy> for more information
123 my ($self,@args) = @_;
125 # throw if @args means that we don't support updating information
126 # in the interface but will delegate to the coordinate policy object
127 # for interpreting the 'start' value
129 $self->throw_not_implemented if @args;
130 return $self->coordinate_policy()->start($self);
136 Usage : $end = $location->end();
137 Function: Get the end coordinate of this location as defined by the
138 currently active coordinate computation policy. In simple
139 cases, this will return the same number as min_end() and
140 max_end(), in more ambiguous cases like fuzzy locations
141 the number may be equal to one or neither of both.
143 We override this here from Bio::RangeI in order to delegate
144 'get' to a L<Bio::Location::CoordinatePolicy> implementing
145 object. Implementing classes may also wish to provide
146 'set' functionality, in which case they *must* override
147 this method. The implementation provided here will throw
148 an exception if called with arguments.
150 Returns : A positive integer value.
153 See L<Bio::Location::CoordinatePolicy> and L<Bio::RangeI> for more
159 my ($self,@args) = @_;
161 # throw if @args means that we don't support updating information
162 # in the interface but will delegate to the coordinate policy object
163 # for interpreting the 'end' value
164 $self->throw_not_implemented if @args;
165 return $self->coordinate_policy()->end($self);
171 Usage : my $minstart = $location->min_start();
172 Function: Get minimum starting point of feature.
174 Note that an implementation must not call start() in this method.
176 Returns : integer or undef if no minimum starting point.
183 $self->throw_not_implemented();
189 Usage : my $maxstart = $location->max_start();
190 Function: Get maximum starting point of feature.
192 Note that an implementation must not call start() in this method
193 unless start() is overridden such as not to delegate to the
194 coordinate computation policy object.
196 Returns : integer or undef if no maximum starting point.
203 $self->throw_not_implemented();
206 =head2 start_pos_type
208 Title : start_pos_type
209 Usage : my $start_pos_type = $location->start_pos_type();
210 Function: Get start position type encoded as text
212 Known valid values are 'BEFORE' (<5..100), 'AFTER' (>5..100),
213 'EXACT' (5..100), 'WITHIN' ((5.10)..100), 'BETWEEN', (5^6), with
214 their meaning best explained by their GenBank/EMBL location string
215 encoding in brackets.
217 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
224 $self->throw_not_implemented();
231 Usage : $location->flip_strand();
232 Function: Flip-flop a strand to the opposite
241 $self->strand($self->strand * -1);
247 Usage : my $minend = $location->min_end();
248 Function: Get minimum ending point of feature.
250 Note that an implementation must not call end() in this method
251 unless end() is overridden such as not to delegate to the
252 coordinate computation policy object.
254 Returns : integer or undef if no minimum ending point.
261 $self->throw_not_implemented();
267 Usage : my $maxend = $location->max_end();
268 Function: Get maximum ending point of feature.
270 Note that an implementation must not call end() in this method
271 unless end() is overridden such as not to delegate to the
272 coordinate computation policy object.
274 Returns : integer or undef if no maximum ending point.
281 $self->throw_not_implemented();
287 Usage : my $end_pos_type = $location->end_pos_type();
288 Function: Get end position encoded as text.
290 Known valid values are 'BEFORE' (5..<100), 'AFTER' (5..>100),
291 'EXACT' (5..100), 'WITHIN' (5..(90.100)), 'BETWEEN', (5^6), with
292 their meaning best explained by their GenBank/EMBL location string
293 encoding in brackets.
295 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
302 $self->throw_not_implemented();
308 Usage : my $seqid = $location->seq_id();
309 Function: Get/Set seq_id that location refers to
310 Returns : seq_id (a string)
311 Args : [optional] seq_id value to set
317 $self->throw_not_implemented();
323 Usage : $is_remote_loc = $loc->is_remote()
324 Function: Whether or not a location is a remote location.
326 A location is said to be remote if it is on a different
327 'object' than the object which 'has' this
328 location. Typically, features on a sequence will sometimes
329 have a remote location, which means that the location of
330 the feature is on a different sequence than the one that is
331 attached to the feature. In such a case, $loc->seq_id will
332 be different from $feat->seq_id (usually they will be the
335 While this may sound weird, it reflects the location of the
336 kind of AL445212.9:83662..166657 which can be found in GenBank/EMBL
340 Returns : TRUE if the location is a remote location, and FALSE otherwise
341 Args : Value to set to
347 shift->throw_not_implemented();
350 =head2 coordinate_policy
352 Title : coordinate_policy
353 Usage : $policy = $location->coordinate_policy();
354 $location->coordinate_policy($mypolicy); # set may not be possible
355 Function: Get the coordinate computing policy employed by this object.
357 See L<Bio::Location::CoordinatePolicyI> for documentation
358 about the policy object and its use.
360 The interface *does not* require implementing classes to
361 accept setting of a different policy. The implementation
362 provided here does, however, allow one to do so.
364 Implementors of this interface are expected to initialize
365 every new instance with a
366 L<Bio::Location::CoordinatePolicyI> object. The
367 implementation provided here will return a default policy
368 object if none has been set yet. To change this default
369 policy object call this method as a class method with an
370 appropriate argument. Note that in this case only
371 subsequently created Location objects will be affected.
373 Returns : A L<Bio::Location::CoordinatePolicyI> implementing object.
374 Args : On set, a L<Bio::Location::CoordinatePolicyI> implementing object.
376 See L<Bio::Location::CoordinatePolicyI> for more information
381 sub coordinate_policy
{
382 shift->throw_not_implemented();
388 Usage : my $locstr = $location->to_FTstring()
389 Function: returns the FeatureTable string of this location
397 $self->throw_not_implemented();
402 Title : each_Location
403 Usage : @locations = $locObject->each_Location($order);
404 Function: Conserved function call across Location:: modules - will
405 return an array containing the component Location(s) in
406 that object, regardless if the calling object is itself a
407 single location or one containing sublocations.
408 Returns : an array of Bio::LocationI implementing objects
409 Args : Optional sort order to be passed to sub_Location() for Splits
414 my ($self,@args) = @_;
415 $self->throw_not_implemented();
419 =head2 valid_Location
421 Title : valid_Location
422 Usage : if ($location->valid_location) {...};
423 Function: boolean method to determine whether location is considered valid
424 (has minimum requirements for a specific LocationI implementation)
425 Returns : Boolean value: true if location is valid, false otherwise
431 my ($self,@args) = @_;
432 $self->throw_not_implemented();