2 # BioPerl module for Bio::Das::SegmentI
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Lincoln Stein <lstein@cshl.org>
8 # Copyright Lincoln Stein
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Das::SegmentI - DAS-style access to a feature database
20 # Get a Bio::Das::SegmentI object from a Bio::DasI database...
22 $segment = $das->segment(-name=>'Landmark',
26 @features = $segment->overlapping_features(-type=>['type1','type2']);
27 # each feature is a Bio::SeqFeatureI-compliant object
29 @features = $segment->contained_features(-type=>['type1','type2']);
31 @features = $segment->contained_in(-type=>['type1','type2']);
33 $stream = $segment->get_feature_stream(-type=>['type1','type2','type3'];
34 while (my $feature = $stream->next_seq) {
35 # do something with feature
38 $count = $segment->features_callback(-type=>['type1','type2','type3'],
39 -callback => sub { ... { }
44 Bio::Das::SegmentI is a simplified alternative interface to sequence
45 annotation databases used by the distributed annotation system. In
46 this scheme, the genome is represented as a series of landmarks. Each
47 Bio::Das::SegmentI object ("segment") corresponds to a genomic region
48 defined by a landmark and a start and end position relative to that
49 landmark. A segment is created using the Bio::DasI segment() method.
51 Features can be filtered by the following attributes:
53 1) their location relative to the segment (whether overlapping,
54 contained within, or completely containing)
58 3) other attributes using tag/value semantics
60 Access to the feature list uses three distinct APIs:
62 1) fetching entire list of features at a time
64 2) fetching an iterator across features
72 User feedback is an integral part of the evolution of this and other
73 Bioperl modules. Send your comments and suggestions preferably to one
74 of the Bioperl mailing lists. Your participation is much appreciated.
76 bioperl-l@bio.perl.org
80 Please direct usage questions or support issues to the mailing list:
82 I<bioperl-l@bioperl.org>
84 rather than to the module maintainer directly. Many experienced and
85 reponsive experts will be able look at the problem and quickly
86 address it. Please include a thorough description of the problem
87 with code and data examples if at all possible.
91 Report bugs to the Bioperl bug tracking system to help us keep track
92 the bugs and their resolution. Bug reports can be submitted via the
95 https://github.com/bioperl/bioperl-live/issues
97 =head1 AUTHOR - Lincoln Stein
103 The rest of the documentation details each of the object
104 methods. Internal methods are usually preceded with a _
109 # Let the code begin...
111 package Bio
::Das
::SegmentI
;
115 # Object preamble - inherits from Bio::Root::RootI;
116 use base
qw(Bio::Root::RootI);
121 Usage : $ref = $s->seq_id
122 Function: return the ID of the landmark
129 sub seq_id
{ shift->throw_not_implemented }
134 Usage : $ref = $s->seq_name
135 Function: return the human-readable name for the landmark
140 This defaults to the same as seq_id.
144 sub display_name
{ shift->seq_id }
150 Function: start of segment
155 This is a read-only accessor for the start of the segment. Alias
156 to low() for Gadfly compatibility.
160 sub start
{ shift->throw_not_implemented }
161 sub low
{ shift->start }
167 Function: end of segment
172 This is a read-only accessor for the end of the segment. Alias to
173 high() for Gadfly compatibility.
177 sub end
{ shift->throw_not_implemented }
178 sub stop
{ shift->end }
179 sub high
{ shift->end }
185 Function: length of segment
190 Returns the length of the segment. Always a positive number.
194 sub length { shift->throw_not_implemented; }
200 Function: get the sequence string for this segment
205 Returns the sequence for this segment as a simple string.
209 sub seq
{shift->throw_not_implemented}
214 Usage : $ref = $s->ref([$newlandmark])
215 Function: get/set the reference landmark for addressing
220 This method is used to examine/change the reference landmark used to
221 establish the coordinate system. By default, the landmark cannot be
222 changed and therefore this has the same effect as seq_id(). The new
223 landmark might be an ID, or another Das::SegmentI object.
227 sub ref { shift->seq_id }
233 Usage : $s->absolute([$new_value])
234 Function: get/set absolute addressing mode
236 Args : new flag (optional)
239 Turn on and off absolute-addressing mode. In absolute addressing
240 mode, coordinates are relative to some underlying "top level"
241 coordinate system (such as a chromosome). ref() returns the identity
242 of the top level landmark, and start() and end() return locations
243 relative to that landmark. In relative addressing mode, coordinates
244 are relative to the landmark sequence specified at the time of segment
245 creation or later modified by the ref() method.
247 The default is to return false and to do nothing in response to
248 attempts to set absolute addressing mode.
252 sub absolute
{ return }
257 Usage : @features = $s->features(@args)
258 Function: get features that overlap this segment
259 Returns : a list of Bio::SeqFeatureI objects
263 This method will find all features that intersect the segment in a
264 variety of ways and return a list of Bio::SeqFeatureI objects. The
265 feature locations will use coordinates relative to the reference
266 sequence in effect at the time that features() was called.
268 The returned list can be limited to certain types, attributes or
269 range intersection modes. Types of range intersection are one of:
271 "overlaps" the default
272 "contains" return features completely contained within the segment
273 "contained_in" return features that completely contain the segment
275 Two types of argument lists are accepted. In the positional argument
276 form, the arguments are treated as a list of feature types. In the
277 named parameter form, the arguments are a series of -name=E<gt>value
281 -------- ------------
283 -types An array reference to type names in the format
286 -attributes A hashref containing a set of attributes to match
288 -rangetype One of "overlaps", "contains", or "contained_in".
290 -iterator Return an iterator across the features.
292 -callback A callback to invoke on each feature
294 The -attributes argument is a hashref containing one or more
295 attributes to match against:
297 -attributes => { Gene => 'abc-1',
298 Note => 'confirmed' }
300 Attribute matching is simple string matching, and multiple attributes
301 are ANDed together. More complex filtering can be performed using the
302 -callback option (see below).
304 If -iterator is true, then the method returns an object reference that
305 implements the next_seq() method. Each call to next_seq() returns a
306 new Bio::SeqFeatureI object.
308 If -callback is passed a code reference, the code reference will be
309 invoked on each feature returned. The code will be passed two
310 arguments consisting of the current feature and the segment object
311 itself, and must return a true value. If the code returns a false
312 value, feature retrieval will be aborted.
314 -callback and -iterator are mutually exclusive options. If -iterator
315 is defined, then -callback is ignored.
317 NOTE: the following methods all build on top of features(), and do not
318 need to be explicitly implemented.
320 overlapping_features()
327 sub features
{shift->throw_not_implemented}
329 =head2 overlapping_features
331 Title : overlapping_features
332 Usage : @features = $s->overlapping_features(@args)
333 Function: get features that overlap this segment
334 Returns : a list of Bio::SeqFeatureI objects
338 This method is identical to features() except that it defaults to
339 finding overlapping features.
343 sub overlapping_features
{
345 my @args = $_[0] =~ /^-/ ?
(@_, -rangetype
=>'overlaps')
346 : (-types
=>\
@_,-rangetype
=>'overlaps');
347 $self->features(@args);
350 =head2 contained_features
352 Title : contained_features
353 Usage : @features = $s->contained_features(@args)
354 Function: get features that are contained in this segment
355 Returns : a list of Bio::SeqFeatureI objects
359 This method is identical to features() except that it defaults to
360 a range type of 'contained'.
364 sub contained_features
{
366 my @args = $_[0] =~ /^-/ ?
(@_, -rangetype
=>'contained')
367 : (-types
=>\
@_,-rangetype
=>'contained');
368 $self->features(@args);
374 Usage : @features = $s->contained_in(@args)
375 Function: get features that contain this segment
376 Returns : a list of Bio::SeqFeatureI objects
380 This method is identical to features() except that it defaults to
381 a range type of 'contained_in'.
387 my @args = $_[0] =~ /^-/ ?
(@_, -rangetype
=>'contained_in')
388 : (-types
=>\
@_,-rangetype
=>'contained_in');
389 $self->features(@args);
392 =head2 get_feature_stream
394 Title : get_feature_stream
395 Usage : $iterator = $s->get_feature_stream(@args)
396 Function: get an iterator across the segment
397 Returns : an object that implements next_seq()
401 This method is identical to features() except that it always generates
404 NOTE: This is defined in the interface in terms of features(). You do not
405 have to implement it.
409 sub get_feature_stream
{
411 my @args = defined $_[0] && $_[0] =~ /^-/ ?
(@_, -iterator
=>1)
412 : (-types
=>\
@_,-iterator
=>1);
413 $self->features(@args);
419 Usage : $factory = $s->factory
420 Function: return the segment factory
421 Returns : a Bio::DasI object
425 This method returns a Bio::DasI object that can be used to fetch
426 more segments. This is typically the Bio::DasI object from which
427 the segment was originally generated.
433 sub factory
{shift->throw_not_implemented}
438 Usage : $tag = $s->primary_tag
439 Function: identifies the segment as type "DasSegment"
440 Returns : a string named "DasSegment"
442 Status : Public, but see below
444 This method provides Bio::Das::Segment objects with a primary_tag()
445 field that identifies them as being of type "DasSegment". This allows
446 the Bio::Graphics engine to render segments just like a feature in order
449 This does not need to be implemented. It is defined by the interface.
455 sub primary_tag
{"DasSegment"}
460 Usage : $strand = $s->strand
461 Function: identifies the segment strand as 0
462 Returns : the number 0
464 Status : Public, but see below
466 This method provides Bio::Das::Segment objects with a strand() field
467 that identifies it as being strandless. This allows the Bio::Graphics
468 engine to render segments just like a feature in order nis way useful.
470 This does not need to be implemented. It is defined by the interface.