GFF/Segment.pm

filter: Statementstmt 49.6% 70 / 141 Branchbran 18.9% 11 / 58 Conditioncond 29.4% 5 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 42.5% 17 / 40 Podpod 100% 36 / 36 totaltotal 46.0% 139 / 302 CC 36 SCAR 19.6
CC
36
Cov
40%
annotation
20.0
seq
12.0
overlaps
12.0
CRAP 7.1
« GFF/Aggregator.pm ↑ Summary GFF/Adaptor/memory/iterator.pm »
1 =head1 NAME
2  
3 Bio::DB::GFF::Segment -- Simple DNA segment object
4  
5 =head1 SYNOPSIS
6  
7 See L<Bio::DB::GFF>.
8  
9 =head1 DESCRIPTION
10  
11 Bio::DB::GFF::Segment provides the basic representation of a range of
12 DNA contained in a GFF database. It is the base class from which the
13 Bio::DB::GFF::RelSegment and Bio::DB::GFF::Feature classes are
14 derived.
15  
16 Generally, you will not create or manipulate Bio::DB::GFF::Segment
17 objects directly, but use those that are returned by the Bio::DB::GFF
18 module.
19  
20 =cut
21  
22 package Bio::DB::GFF::Segment;
23 38 $Bio::DB::GFF::Segment::VERSION = '1.7.4';
24 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 38 ▶use Bio::Annotation::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 38 ▶use base qw(Bio::Root::Root Bio::RangeI Bio::SeqI Bio::Das::SegmentI);
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 use overload
30 38 ▶ '""' => 'asString',
Subroutine BEGIN: called CC=1 SCAR=0.0
31 eq => 'equals',
32 38 fallback => 1;
33  
34 =head1 API
35  
36 The remainder of this document describes the API for
37 Bio::DB::GFF::Segment.
38  
39 =cut
40  
41 =head2 new
42  
43 Title : new
44 Usage : $s = Bio::DB::GFF::Segment->new(@args)
45 Function: create a new segment
46 Returns : a new Bio::DB::GFF::Segment object
47 Args : see below
48 Status : Public
49  
50 This method creates a new Bio::DB::GFF::Segment object. Generally
51 this is called automatically by the Bio::DB::GFF module and
52 derivatives.
53  
54 There are five positional arguments:
55  
56 $factory a Bio::DB::GFF::Adaptor to use for database access
57 $sourceseq ID of the source sequence
58 $sourceclass class of the source sequence
59 $start start of the desired segment relative to source sequence
60 $stop stop of the desired segment relative to source sequence
61  
62 =cut
63  
64 159 ▶sub new {
Subroutine new: called CC=6 SCAR=19.9
Pod documented
65 159 my $class = shift;
66 159 my ($factory,$segclass,$segname,$start,$stop) = @_;
67 159 ▶ $segclass = $segname->class if ref($segname) && $segname->can('class');
Branch: 1 branch
BranchTrueFalseTotal
if CORE::ref $segname and $segname->can("class") 0 159 159
Condition33%1/3
CORE::ref $segname and $segname->can("class")
!ll&&!rl&&r
15900
MC/DC0%0/2
CORE::ref $segname and $segname->can("class")
CORE::ref $segname $segname->can("class")
Truth table33%1/3
A and B
A= CORE::ref $segnameB= $segname->can("class")
ABresult
0X0
100
111
68 159 ▶ $segclass ||= 'Sequence';
Condition50%1/2
$segclass ||= "Sequence"
l!l
1590
MC/DC0%0/1
$segclass ||= "Sequence"
$segclass
Truth table50%1/2
A
A= $segclass
Aresult
11
00
69  
70 159 ▶ $factory or $class->throw("->new(): provide a factory argument");
Branch: 1 branch
BranchTrueFalseTotal
$factory or $class->throw("->new(): provide a factory argument") 159 0 159
71 159 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if CORE::ref $class 0 159 159
72 159 return bless { factory => $factory,
73 sourceseq => $segname,
74 class => $segclass,
75 start => $start,
76 stop => $stop,
77 strand => 0,
78 },$class;
79 }
80  
81 # read-only accessors
82  
83 =head2 factory
84  
85 Title : factory
86 Usage : $s->factory
87 Function: get the factory object
88 Returns : a Bio::DB::GFF::Adaptor
89 Args : none
90 Status : Public
91  
92 This is a read-only accessor for the Bio::DB::GFF::Adaptor object used
93 to create the segment.
94  
95 =cut
96  
97 265 ▶sub factory { shift->{factory} }
Subroutine factory: called CC=1 SCAR=0.0
Pod documented
98  
99 # start, stop, length
100  
101 =head2 start
102  
103 Title : start
104 Usage : $s->start
105 Function: start of segment
106 Returns : integer
107 Args : none
108 Status : Public
109  
110 This is a read-only accessor for the start of the segment.
111  
112 =cut
113  
114 120 ▶sub start { shift->{start} }
Subroutine start: called CC=1 SCAR=0.0
Pod documented
115  
116 =head2 end
117  
118 Title : end
119 Usage : $s->end
120 Function: end of segment
121 Returns : integer
122 Args : none
123 Status : Public
124  
125 This is a read-only accessor for the end of the segment.
126  
127 =cut
128  
129 140 ▶sub end { shift->{stop} }
Subroutine end: called CC=1 SCAR=0.0
Pod documented
130  
131 =head2 stop
132  
133 Title : stop
134 Usage : $s->stop
135 Function: stop of segment
136 Returns : integer
137 Args : none
138 Status : Public
139  
140 This is an alias for end(), provided for AcePerl compatibility.
141  
142 =cut
143  
144 38 *stop = \&end;
145  
146 =head2 length
147  
148 Title : length
149 Usage : $s->length
150 Function: length of segment
151 Returns : integer
152 Args : none
153 Status : Public
154  
155 Returns the length of the segment. Always a positive number.
156  
157 =cut
158  
159 0 ▶sub length { abs($_[0]->{start} - $_[0]->{stop})+1 }
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
160  
161  
162 =head2 strand
163  
164 Title : strand
165 Usage : $s->strand
166 Function: strand of segment
167 Returns : +1,0,-1
168 Args : none
169 Status : Public
170  
171 Returns the strand on which the segment resides, either +1, 0 or -1.
172  
173 =cut
174  
175 0 ▶sub strand {
Subroutine strand: not called CC=1 SCAR=6.9
Pod documented
176 0 my $self = shift;
177 0 0;
178 }
179  
180 =head2 low
181  
182 Title : low
183 Usage : $s->low
184 Function: return lower coordinate
185 Returns : lower coordinate
186 Args : none
187 Status : Public
188  
189 Returns the lower coordinate, either start or end.
190  
191 =cut
192  
193 0 ▶sub low {
Subroutine low: not called CC=2 SCAR=17.9
Pod documented
194 0 my $self = shift;
195 0 my ($start,$stop) = ($self->start,$self->stop);
196 0 ▶ return $start < $stop ? $start : $stop;
Branch: 1 branch
BranchTrueFalseTotal
$start < $stop ? : 0 0 0
197 }
198 38 *abs_low = \&low;
199  
200 =head2 high
201  
202 Title : high
203 Usage : $s->high
204 Function: return higher coordinate
205 Returns : higher coordinate
206 Args : none
207 Status : Public
208  
209 Returns the higher coordinate, either start or end.
210  
211 =cut
212  
213 0 ▶sub high {
Subroutine high: not called CC=2 SCAR=17.9
Pod documented
214 0 my $self = shift;
215 0 my ($start,$stop) = ($self->start,$self->stop);
216 0 ▶ return $start > $stop ? $start : $stop;
Branch: 1 branch
BranchTrueFalseTotal
$start > $stop ? : 0 0 0
217 }
218 38 *abs_high = \&high;
219  
220 =head2 sourceseq
221  
222 Title : sourceseq
223 Usage : $s->sourceseq
224 Function: get the segment source
225 Returns : a string
226 Args : none
227 Status : Public
228  
229 Returns the name of the source sequence for this segment.
230  
231 =cut
232  
233 348 ▶sub sourceseq { shift->{sourceseq} }
Subroutine sourceseq: called CC=1 SCAR=0.0
Pod documented
234  
235 =head2 class
236  
237 Title : class
238 Usage : $s->class([$newclass])
239 Function: get the source sequence class
240 Returns : a string
241 Args : new class (optional)
242 Status : Public
243  
244 Gets or sets the class for the source sequence for this segment.
245  
246 =cut
247  
248 224 ▶sub class {
Subroutine class: called CC=2 SCAR=7.0
Pod documented
249 224 my $self = shift;
250 224 my $d = $self->{class};
251 224 ▶ $self->{class} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 224 224
252 224 $d;
253 }
254  
255 =head2 subseq
256  
257 Title : subseq
258 Usage : $s->subseq($start,$stop)
259 Function: generate a subsequence
260 Returns : a Bio::DB::GFF::Segment object
261 Args : start and end of subsequence
262 Status : Public
263  
264 This method generates a new segment from the start and end positions
265 given in the arguments. If stop E<lt> start, then the strand is reversed.
266  
267 =cut
268  
269 35 ▶sub subseq {
Subroutine subseq: called CC=2 SCAR=6.9
Pod documented
270 35 my $self = shift;
271 35 my ($newstart,$newstop) = @_;
272 my ($refseq,$start,$stop,$class) = ($self->{sourceseq},
273 $self->{start},$self->{stop},
274 35 $self->class);
275  
276 # We deliberately force subseq to return objects of type RelSegment
277 # Otherwise, when we get a subsequence from a Feature object,
278 # its method and source go along for the ride, which is incorrect.
279 35 my $new = $self->new_from_segment($self);
280 35 ▶ if ($start <= $stop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start <= $stop) { } 20 15 35
281 20 @{$new}{qw(start stop)} = ($start + $newstart - 1, $start + $newstop - 1);
282 } else {
283 15 @{$new}{qw(start stop)} = ($start - ($newstart - 1), $start - ($newstop - 1)),
284  
285 }
286  
287 35 $new;
288 }
289  
290 =head2 seq
291  
292 Title : seq
293 Usage : $s->seq
294 Function: get the sequence string for this segment
295 Returns : a Bio::PrimarySeq
296 Args : none
297 Status : Public
298  
299 Returns the sequence for this segment as a Bio::PrimarySeq. (-)
300 strand segments are automatically reverse complemented
301  
302 The method is called dna() return the data as a simple sequence
303 string.
304  
305 =cut
306  
307 0 ▶sub seq {
Subroutine seq: not called CC=3 SCAR=24.8
Pod documented
308 0 my $self = shift;
309 0 my $dna = $self->dna;
310 0 ▶ require Bio::PrimarySeq unless Bio::PrimarySeq->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::PrimarySeq"->can("new") 0 0 0
311 0 ▶ return Bio::PrimarySeq->new(-id => $self->display_name) unless $dna;
Branch: 1 branch
BranchTrueFalseTotal
unless $dna 0 0 0
312 0 return Bio::PrimarySeq->new(-seq => $dna,
313 -id => $self->display_name);
314 }
315  
316 =head2 dna
317  
318 Title : dna
319 Usage : $s->dna
320 Function: get the DNA string for this segment
321 Returns : a string
322 Args : none
323 Status : Public
324  
325 Returns the sequence for this segment as a simple string. (-) strand
326 segments are automatically reverse complemented
327  
328 The method is also called protein().
329  
330 =cut
331  
332 115 ▶sub dna {
Subroutine dna: called CC=1 SCAR=0.0
Pod documented
333 115 my $self = shift;
334 my ($ref,$class,$start,$stop,$strand)
335 115 = @{$self}{qw(sourceseq class start stop strand)};
336 115 return $self->factory->dna($ref,$start,$stop,$class);
337 }
338  
339 38 *protein = \&dna;
340  
341  
342 =head2 primary_seq
343  
344 Title : primary_seq
345 Usage : $s->primary_seq
346 Function: returns a Bio::PrimarySeqI compatible object
347 Returns : a Bio::PrimarySeqI object
348 Args : none
349 Status : Public
350  
351 This is for compatibility with BioPerl's separation of SeqI
352 from PrimarySeqI. It just returns itself.
353  
354 =cut
355  
356 #'
357  
358 0 ▶sub primary_seq { shift }
Subroutine primary_seq: not called CC=1 SCAR=6.9
Pod documented
359  
360 =head2 type
361  
362 Title : type
363 Usage : $s->type
364 Function: return the string "feature"
365 Returns : the string "feature"
366 Args : none
367 Status : Public
368  
369 This is for future sequence ontology-compatibility and
370 represents the default type of a feature on the genome
371  
372 =cut
373  
374 0 ▶sub type { "feature" }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
375  
376 =head2 equals
377  
378 Title : equals
379 Usage : $s->equals($d)
380 Function: segment equality
381 Returns : true, if two segments are equal
382 Args : another segment
383 Status : Public
384  
385 Returns true if the two segments have the same source sequence, start and stop.
386  
387 =cut
388  
389 15 ▶sub equals {
Subroutine equals: called CC=6 SCAR=22.1
Pod documented
390 15 my $self = shift;
391 15 my $peer = shift;
392 15 ▶ return unless defined $peer;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $peer 0 15 15
393 15 ▶ return $self->asString eq $peer unless ref($peer) && $peer->isa('Bio::DB::GFF::Segment');
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::ref $peer and $peer->isa("Bio::DB::GFF::Segment") 0 15 15
Condition33%1/3
CORE::ref $peer and $peer->isa("Bio::DB::GFF::Segment")
!ll&&!rl&&r
0015
MC/DC0%0/2
CORE::ref $peer and $peer->isa("Bio::DB::GFF::Segment")
CORE::ref $peer $peer->isa("Bio::DB::GFF::Segment")
Truth table33%1/3
A and B
A= CORE::ref $peerB= $peer->isa("Bio::DB::GFF::Segment")
ABresult
0X0
100
111
394 return $self->{start} eq $peer->{start}
395 && $self->{stop} eq $peer->{stop}
396 15 ▶ && $self->{sourceseq} eq $peer->{sourceseq};
Condition33%2/6
$self->{'start'} eq $peer->{'start'} && $self->{'stop'} eq $peer->{'stop'} && $self->{'sourceseq'} eq $peer->{'sourceseq'}
!ll&&!rl&&r
0015
$self->{"start"} eq $peer->{"start"} and $self->{"stop"} eq $peer->{"stop"}
!ll&&!rl&&r
0015
MC/DC0%0/3
$self->{'start'} eq $peer->{'start'} && $self->{'stop'} eq $peer->{'stop'} && $self->{'sourceseq'} eq $peer->{'sourceseq'}
$self->{"start"} eq $peer->{"start"} $self->{"stop"} eq $peer->{"stop"} $self->{'sourceseq'} eq $peer->{'sourceseq'}
Truth table25%1/4
A and B && C
A= $self->{"start"} eq $peer->{"start"}B= $self->{"stop"} eq $peer->{"stop"}C= $self->{'sourceseq'} eq $peer->{'sourceseq'}
ABCresult
0XX0
10X0
1100
1111
397 }
398  
399 =head2 asString
400  
401 Title : asString
402 Usage : $s->asString
403 Function: human-readable string for segment
404 Returns : a string
405 Args : none
406 Status : Public
407  
408 Returns a human-readable string representing this sequence. Format
409 is:
410  
411 sourceseq/start,stop
412  
413 =cut
414  
415 0 ▶sub asString {
Subroutine asString: not called CC=1 SCAR=6.9
Pod documented
416 0 my $self = shift;
417 0 my $label = $self->refseq;
418 0 my $start = $self->start;
419 0 my $stop = $self->stop;
420 0 return "$label:$start,$stop";
421 }
422  
423 =head2 clone
424  
425 Title : clone
426 Usage : $copy = $s->clone
427 Function: make a copy of this segment
428 Returns : a Bio::DB::GFF::Segment object
429 Args : none
430 Status : Public
431  
432 This method creates a copy of the segment and returns it.
433  
434 =cut
435  
436 # deep copy of the thing
437 107 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
438 107 my $self = shift;
439 107 my %h = %$self;
440 107 return bless \%h,ref($self);
441 }
442  
443 =head2 error
444  
445 Title : error
446 Usage : $error = $s->error([$new_error])
447 Function: get or set the last error
448 Returns : a string
449 Args : an error message (optional)
450 Status : Public
451  
452 In case of a fault, this method can be used to obtain the last error
453 message. Internally it is called to set the error message.
454  
455 =cut
456  
457 0 ▶sub error {
Subroutine error: not called CC=2 SCAR=17.9
Pod documented
458 0 my $self = shift;
459 0 my $g = $self->{error};
460 0 ▶ $self->{error} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
461 0 $g;
462 }
463  
464 =head1 Relative Addressing Methods
465  
466 The following methods are provided for compatibility with
467 Bio::DB::GFF::RelSegment, which provides relative addressing
468 functions.
469  
470 =head2 abs_start
471  
472 Title : abs_start
473 Usage : $s->abs_start
474 Function: the absolute start of the segment
475 Returns : an integer
476 Args : none
477 Status : Public
478  
479 This is an alias to start(), and provided for API compatibility with
480 Bio::DB::GFF::RelSegment.
481  
482 =cut
483  
484 38 *abs_start = \&start;
485  
486 =head2 abs_end
487  
488 Title : abs_end
489 Usage : $s->abs_end
490 Function: the absolute stop of the segment
491 Returns : an integer
492 Args : none
493 Status : Public
494  
495 This is an alias to stop(), and provided for API compatibility with
496 Bio::DB::GFF::RelSegment.
497  
498 =cut
499  
500 38 *abs_stop = \&stop;
501 38 *abs_end = \&stop;
502  
503 =head2 abs_strand
504  
505 Title : abs_strand
506 Usage : $s->abs_strand
507 Function: the absolute strand of the segment
508 Returns : +1,0,-1
509 Args : none
510 Status : Public
511  
512 This is an alias to strand(), and provided for API compatibility with
513 Bio::DB::GFF::RelSegment.
514  
515 =cut
516  
517 35 ▶sub abs_strand {
Subroutine abs_strand: called CC=1 SCAR=0.0
Pod documented
518 35 my $self = shift;
519 35 return $self->abs_end <=> $self->abs_start;
520 }
521  
522 =head2 abs_ref
523  
524 Title : abs_ref
525 Usage : $s->abs_ref
526 Function: the reference sequence for this segment
527 Returns : a string
528 Args : none
529 Status : Public
530  
531 This is an alias to sourceseq(), and is here to provide API
532 compatibility with Bio::DB::GFF::RelSegment.
533  
534 =cut
535  
536 38 *abs_ref = \&sourceseq;
537  
538 =head2 refseq
539  
540 Title : refseq
541 Usage : $s->refseq
542 Function: get or set the reference sequence
543 Returns : a string
544 Args : none
545 Status : Public
546  
547 Examine or change the reference sequence. This is an alias to
548 sourceseq(), provided here for API compatibility with
549 Bio::DB::GFF::RelSegment.
550  
551 =cut
552  
553 38 *refseq = \&sourceseq;
554  
555 =head2 ref
556  
557 Title : ref
558 Usage : $s->refseq
559 Function: get or set the reference sequence
560 Returns : a string
561 Args : none
562 Status : Public
563  
564 An alias for refseq()
565  
566 =cut
567  
568 93 ▶sub ref { shift->refseq(@_) }
Subroutine ref: called CC=1 SCAR=0.0
Pod documented
569  
570 =head2 seq_id
571  
572 Title : seq_id
573 Usage : $ref = $s->seq_id
574 Function: get the reference sequence in a LocationI-compatible way
575 Returns : a string
576 Args : none
577 Status : Public
578  
579 An alias for refseq() but only allows reading.
580  
581 =cut
582  
583 0 ▶sub seq_id { shift->refseq }
Subroutine seq_id: not called CC=1 SCAR=6.9
Pod documented
584 38 *seqname = \&seq_id;
585  
586 =head2 truncated
587  
588 Title : truncated
589 Usage : $truncated = $s->truncated
590 Function: Flag indicating that the segment was truncated during creation
591 Returns : A boolean flag
592 Args : none
593 Status : Public
594  
595 This indicates that the sequence was truncated during creation. The
596 returned flag is undef if no truncation occurred. If truncation did
597 occur, the flag is actually an array ref in which the first element is
598 true if truncation occurred on the left, and the second element
599 occurred if truncation occurred on the right.
600  
601 =cut
602  
603 15 ▶sub truncated {
Subroutine truncated: called CC=3 SCAR=11.0
Pod documented
604 15 my $self = shift;
605 15 ▶ my $hash = $self->{truncated} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $hash = $self->{"truncated"} or return 5 10 15
606 5 ▶ CORE::ref($hash) eq 'HASH' or return [1,1]; # paranoia -- not that this would ever happen ;-)
Branch: 1 branch
BranchTrueFalseTotal
CORE::ref $hash eq "HASH" or return [1, 1] 5 0 5
607 5 return [$hash->{start},$hash->{stop}];
608 }
609  
610 =head2 Bio::RangeI Methods
611  
612 The following Bio::RangeI methods are supported:
613  
614 overlaps(), contains(), equals(),intersection(),union(),overlap_extent()
615  
616 =cut
617  
618 0 ▶sub overlaps {
Subroutine overlaps: not called CC=3 SCAR=24.8
Pod documented
619 0 my $self = shift;
620 0 my($other,$so) = @_;
621 0 ▶ if ($other->isa('Bio::DB::GFF::RelSegment')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Bio::DB::GFF::RelSegment")) 0 0 0
622 0 ▶ return if $self->abs_ref ne $other->abs_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $self->abs_ref ne $other->abs_ref 0 0 0
623 }
624 0 $self->SUPER::overlaps(@_);
625 }
626  
627 0 ▶sub contains {
Subroutine contains: not called CC=3 SCAR=24.8
Pod documented
628 0 my $self = shift;
629 0 my($other,$so) = @_;
630 0 ▶ if ($other->isa('Bio::DB::GFF::RelSegment')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Bio::DB::GFF::RelSegment")) 0 0 0
631 0 ▶ return if $self->abs_ref ne $other->abs_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $self->abs_ref ne $other->abs_ref 0 0 0
632 }
633 0 $self->SUPER::contains(@_);
634 }
635 #sub equals {
636 # my $self = shift;
637 # my($other,$so) = @_;
638 # if ($other->isa('Bio::DB::GFF::RelSegment')) {
639 # return if $self->abs_ref ne $other->abs_ref;
640 # }
641 # $self->SUPER::equals(@_);
642 #}
643 0 ▶sub intersection {
Subroutine intersection: not called CC=3 SCAR=24.8
Pod documented
644 0 my $self = shift;
645 0 my($other,$so) = @_;
646 0 ▶ if ($other->isa('Bio::DB::GFF::RelSegment')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Bio::DB::GFF::RelSegment")) 0 0 0
647 0 ▶ return if $self->abs_ref ne $other->abs_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $self->abs_ref ne $other->abs_ref 0 0 0
648 }
649 0 $self->SUPER::intersection(@_);
650 }
651 0 ▶sub union {
Subroutine union: not called CC=3 SCAR=24.8
Pod documented
652 0 my $self = shift;
653 0 my($other) = @_;
654 0 ▶ if ($other->isa('Bio::DB::GFF::RelSegment')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Bio::DB::GFF::RelSegment")) 0 0 0
655 0 ▶ return if $self->abs_ref ne $other->abs_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $self->abs_ref ne $other->abs_ref 0 0 0
656 }
657 0 $self->SUPER::union(@_);
658 }
659  
660 0 ▶sub overlap_extent {
Subroutine overlap_extent: not called CC=3 SCAR=24.8
Pod documented
661 0 my $self = shift;
662 0 my($other) = @_;
663 0 ▶ if ($other->isa('Bio::DB::GFF::RelSegment')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Bio::DB::GFF::RelSegment")) 0 0 0
664 0 ▶ return if $self->abs_ref ne $other->abs_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $self->abs_ref ne $other->abs_ref 0 0 0
665 }
666 0 $self->SUPER::overlap_extent(@_);
667 }
668  
669  
670 =head2 Bio::SeqI implementation
671  
672 =cut
673  
674 =head2 primary_id
675  
676 Title : primary_id
677 Usage : $unique_implementation_key = $obj->primary_id;
678 Function: Returns the unique id for this object in this
679 implementation. This allows implementations to manage their
680 own object ids in a way the implementation can control
681 clients can expect one id to map to one object.
682  
683 For sequences with no accession number, this method should
684 return a stringified memory location.
685  
686 Returns : A string
687 Args : None
688 Status : Virtual
689  
690  
691 =cut
692  
693 0 ▶sub primary_id {
Subroutine primary_id: not called CC=3 SCAR=24.8
Pod documented
694 0 my ($obj,$value) = @_;
695  
696 0 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
697 0 $obj->{'primary_id'} = $value;
698 }
699 0 ▶ if( ! exists $obj->{'primary_id'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $obj->{"primary_id"}) 0 0 0
700 0 return "$obj";
701 }
702 0 return $obj->{'primary_id'};
703 }
704  
705  
706 =head2 display_name
707  
708 Title : display_name
709 Usage : $id = $obj->display_name or $obj->display_name($newid);
710 Function: Gets or sets the display id, also known as the common name of
711 the Seq object.
712  
713 The semantics of this is that it is the most likely string
714 to be used as an identifier of the sequence, and likely to
715 have "human" readability. The id is equivalent to the LOCUS
716 field of the GenBank/EMBL databanks and the ID field of the
717 Swissprot/sptrembl database. In fasta format, the >(\S+) is
718 presumed to be the id, though some people overload the id
719 to embed other information. Bioperl does not use any
720 embedded information in the ID field, and people are
721 encouraged to use other mechanisms (accession field for
722 example, or extending the sequence object) to solve this.
723  
724 Notice that $seq->id() maps to this function, mainly for
725 legacy/convenience issues.
726 Returns : A string
727 Args : None or a new id
728  
729 Note, this used to be called display_id(), and this name is preserved for
730 backward compatibility. The default is to return the seq_id().
731  
732 =cut
733  
734 0 ▶sub display_name { shift->seq_id }
Subroutine display_name: not called CC=1 SCAR=6.9
Pod documented
735 38 *display_id = \&display_name;
736  
737 =head2 accession_number
738  
739 Title : accession_number
740 Usage : $unique_biological_key = $obj->accession_number;
741 Function: Returns the unique biological id for a sequence, commonly
742 called the accession_number. For sequences from established
743 databases, the implementors should try to use the correct
744 accession number. Notice that primary_id() provides the
745 unique id for the implementation, allowing multiple objects
746 to have the same accession number in a particular implementation.
747  
748 For sequences with no accession number, this method should return
749 "unknown".
750 Returns : A string
751 Args : None
752  
753  
754 =cut
755  
756 0 ▶sub accession_number {
Subroutine accession_number: not called CC=1 SCAR=6.9
Pod documented
757 0 return 'unknown';
758 }
759  
760 =head2 alphabet
761  
762 Title : alphabet
763 Usage : if( $obj->alphabet eq 'dna' ) { /Do Something/ }
764 Function: Returns the type of sequence being one of
765 'dna', 'rna' or 'protein'. This is case sensitive.
766  
767 This is not called <type> because this would cause
768 upgrade problems from the 0.5 and earlier Seq objects.
769  
770 Returns : a string either 'dna','rna','protein'. NB - the object must
771 make a call of the type - if there is no type specified it
772 has to guess.
773 Args : none
774 Status : Virtual
775  
776  
777 =cut
778  
779 0 ▶sub alphabet{
Subroutine alphabet: not called CC=1 SCAR=6.9
Pod documented
780 0 return 'dna'; # no way this will be anything other than dna!
781 }
782  
783 =head2 desc
784  
785 Title : desc
786 Usage : $seqobj->desc($string) or $seqobj->desc()
787 Function: Sets or gets the description of the sequence
788 Example :
789 Returns : The description
790 Args : The description or none
791  
792  
793 =cut
794  
795 0 ▶sub desc { shift->asString }
Subroutine desc: not called CC=1 SCAR=6.9
Pod documented
796  
797 38 *description = \&desc;
798  
799 =head2 species
800  
801 Title : species
802 Usage : $species = $seq->species() or $seq->species($species)
803 Function: Gets or sets the species
804 Example :
805 Returns : Bio::Species object
806 Args : None or Bio::Species object
807  
808 See L<Bio::Species> for more information
809  
810 =cut
811  
812 0 ▶sub species {
Subroutine species: not called CC=2 SCAR=17.9
Pod documented
813 0 my ($self, $species) = @_;
814 0 ▶ if ($species) {
Branch: 1 branch
BranchTrueFalseTotal
if ($species) { } 0 0 0
815 0 $self->{'species'} = $species;
816 } else {
817 0 return $self->{'species'};
818 }
819 }
820  
821 =head2 annotation
822  
823 Title : annotation
824 Usage : $ann = $seq->annotation or $seq->annotation($annotation)
825 Function: Gets or sets the annotation
826 Example :
827 Returns : Bio::Annotation object
828 Args : None or Bio::Annotation object
829  
830 See L<Bio::Annotation> for more information
831  
832 =cut
833  
834 0 ▶sub annotation {
Subroutine annotation: not called CC=4 SCAR=30.0
Pod documented
835 0 my ($obj,$value) = @_;
836 0 ▶ if( defined $value || ! defined $obj->{'annotation'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $obj->{"annotation"}) 0 0 0
Condition0%0/3
defined $value or not defined $obj->{"annotation"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $value or not defined $obj->{"annotation"}
defined $value not defined $obj->{"annotation"}
Truth table0%0/3
A or not(B)
A= defined $valueB= not defined $obj->{"annotation"}
ABresult
1X1
011
000
837 0 ▶ $value = Bio::Annotation::Collection->new() unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
838 0 $obj->{'annotation'} = $value;
839 }
840 0 return $obj->{'annotation'};
841  
842 }
843  
844 =head2 is_circular
845  
846 Title : is_circular
847 Usage : if( $obj->is_circular) { /Do Something/ }
848 Function: Returns true if the molecule is circular
849 Returns : Boolean value
850 Args : none
851  
852 =cut
853  
854 0 ▶sub is_circular{
Subroutine is_circular: not called CC=1 SCAR=6.9
Pod documented
855 0 return 0;
856 }
857  
858  
859 38 1;
860 __END__
« GFF/Aggregator.pm ↑ Summary GFF/Adaptor/memory/iterator.pm »