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
;
79 use base
qw(Bio::RangeI);
84 Usage : my $location_type = $location->location_type();
85 Function: Get location type encoded as text
86 Returns : string ('EXACT', 'WITHIN', 'IN-BETWEEN')
92 my ($self,@args) = @_;
93 $self->throw_not_implemented();
99 Usage : $start = $location->start();
100 Function: Get the start coordinate of this location as defined by
101 the currently active coordinate computation policy. In
102 simple cases, this will return the same number as
103 min_start() and max_start(), in more ambiguous cases like
104 fuzzy locations the number may be equal to one or neither
107 We override this here from RangeI in order to delegate
108 'get' to a L<Bio::Location::CoordinatePolicy> implementing
109 object. Implementing classes may also wish to provide
110 'set' functionality, in which case they *must* override
111 this method. The implementation provided here will throw
112 an exception if called with arguments.
114 Returns : A positive integer value.
117 See L<Bio::Location::CoordinatePolicy> for more information
122 my ($self,@args) = @_;
124 # throw if @args means that we don't support updating information
125 # in the interface but will delegate to the coordinate policy object
126 # for interpreting the 'start' value
128 $self->throw_not_implemented if @args;
129 return $self->coordinate_policy()->start($self);
135 Usage : $end = $location->end();
136 Function: Get the end coordinate of this location as defined by the
137 currently active coordinate computation policy. In simple
138 cases, this will return the same number as min_end() and
139 max_end(), in more ambiguous cases like fuzzy locations
140 the number may be equal to one or neither of both.
142 We override this here from Bio::RangeI in order to delegate
143 'get' to a L<Bio::Location::CoordinatePolicy> implementing
144 object. Implementing classes may also wish to provide
145 'set' functionality, in which case they *must* override
146 this method. The implementation provided here will throw
147 an exception if called with arguments.
149 Returns : A positive integer value.
152 See L<Bio::Location::CoordinatePolicy> and L<Bio::RangeI> for more
158 my ($self,@args) = @_;
160 # throw if @args means that we don't support updating information
161 # in the interface but will delegate to the coordinate policy object
162 # for interpreting the 'end' value
163 $self->throw_not_implemented if @args;
164 return $self->coordinate_policy()->end($self);
170 Usage : my $minstart = $location->min_start();
171 Function: Get minimum starting point of feature.
173 Note that an implementation must not call start() in this method.
175 Returns : integer or undef if no minimum starting point.
182 $self->throw_not_implemented();
188 Usage : my $maxstart = $location->max_start();
189 Function: Get maximum starting point of feature.
191 Note that an implementation must not call start() in this method
192 unless start() is overridden such as not to delegate to the
193 coordinate computation policy object.
195 Returns : integer or undef if no maximum starting point.
202 $self->throw_not_implemented();
205 =head2 start_pos_type
207 Title : start_pos_type
208 Usage : my $start_pos_type = $location->start_pos_type();
209 Function: Get start position type encoded as text
211 Known valid values are 'BEFORE' (<5..100), 'AFTER' (>5..100),
212 'EXACT' (5..100), 'WITHIN' ((5.10)..100), 'BETWEEN', (5^6), with
213 their meaning best explained by their GenBank/EMBL location string
214 encoding in brackets.
216 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
223 $self->throw_not_implemented();
230 Usage : $location->flip_strand();
231 Function: Flip-flop a strand to the opposite
240 $self->strand($self->strand * -1);
246 Usage : my $minend = $location->min_end();
247 Function: Get minimum ending point of feature.
249 Note that an implementation must not call end() in this method
250 unless end() is overridden such as not to delegate to the
251 coordinate computation policy object.
253 Returns : integer or undef if no minimum ending point.
260 $self->throw_not_implemented();
266 Usage : my $maxend = $location->max_end();
267 Function: Get maximum ending point of feature.
269 Note that an implementation must not call end() in this method
270 unless end() is overridden such as not to delegate to the
271 coordinate computation policy object.
273 Returns : integer or undef if no maximum ending point.
280 $self->throw_not_implemented();
286 Usage : my $end_pos_type = $location->end_pos_type();
287 Function: Get end position encoded as text.
289 Known valid values are 'BEFORE' (5..<100), 'AFTER' (5..>100),
290 'EXACT' (5..100), 'WITHIN' (5..(90.100)), 'BETWEEN', (5^6), with
291 their meaning best explained by their GenBank/EMBL location string
292 encoding in brackets.
294 Returns : string ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
301 $self->throw_not_implemented();
307 Usage : my $seqid = $location->seq_id();
308 Function: Get/Set seq_id that location refers to
309 Returns : seq_id (a string)
310 Args : [optional] seq_id value to set
316 $self->throw_not_implemented();
322 Usage : $is_remote_loc = $loc->is_remote()
323 Function: Whether or not a location is a remote location.
325 A location is said to be remote if it is on a different
326 'object' than the object which 'has' this
327 location. Typically, features on a sequence will sometimes
328 have a remote location, which means that the location of
329 the feature is on a different sequence than the one that is
330 attached to the feature. In such a case, $loc->seq_id will
331 be different from $feat->seq_id (usually they will be the
334 While this may sound weird, it reflects the location of the
335 kind of AL445212.9:83662..166657 which can be found in GenBank/EMBL
339 Returns : TRUE if the location is a remote location, and FALSE otherwise
340 Args : Value to set to
346 shift->throw_not_implemented();
349 =head2 coordinate_policy
351 Title : coordinate_policy
352 Usage : $policy = $location->coordinate_policy();
353 $location->coordinate_policy($mypolicy); # set may not be possible
354 Function: Get the coordinate computing policy employed by this object.
356 See L<Bio::Location::CoordinatePolicyI> for documentation
357 about the policy object and its use.
359 The interface *does not* require implementing classes to
360 accept setting of a different policy. The implementation
361 provided here does, however, allow one to do so.
363 Implementors of this interface are expected to initialize
364 every new instance with a
365 L<Bio::Location::CoordinatePolicyI> object. The
366 implementation provided here will return a default policy
367 object if none has been set yet. To change this default
368 policy object call this method as a class method with an
369 appropriate argument. Note that in this case only
370 subsequently created Location objects will be affected.
372 Returns : A L<Bio::Location::CoordinatePolicyI> implementing object.
373 Args : On set, a L<Bio::Location::CoordinatePolicyI> implementing object.
375 See L<Bio::Location::CoordinatePolicyI> for more information
380 sub coordinate_policy
{
381 shift->throw_not_implemented();
387 Usage : my $locstr = $location->to_FTstring()
388 Function: returns the FeatureTable string of this location
396 $self->throw_not_implemented();
401 Title : each_Location
402 Usage : @locations = $locObject->each_Location($order);
403 Function: Conserved function call across Location:: modules - will
404 return an array containing the component Location(s) in
405 that object, regardless if the calling object is itself a
406 single location or one containing sublocations.
407 Returns : an array of Bio::LocationI implementing objects
408 Args : Optional sort order to be passed to sub_Location() for Splits
413 my ($self,@args) = @_;
414 $self->throw_not_implemented();
418 =head2 valid_Location
420 Title : valid_Location
421 Usage : if ($location->valid_location) {...};
422 Function: boolean method to determine whether location is considered valid
423 (has minimum requirements for a specific LocationI implementation)
424 Returns : Boolean value: true if location is valid, false otherwise
430 my ($self,@args) = @_;
431 $self->throw_not_implemented();