Bio/SeqFeature/Generic.pm

filter: Statementstmt 75.6% 211 / 279 Branchbran 71.5% 103 / 144 Conditioncond 55.4% 46 / 83 MC/DCmcdc 28.2% 13 / 46 Subroutinesub 86.6% 39 / 45 Podpod 85.2% 29 / 34 totaltotal 69.8% 441 / 631 CC 107 SCAR 25.2
CC
107
Cov
71%
start
37.6
end
37.6
set_attributes
25.1
CRAP 12.4
« Bio/AlignIO/maf.pm ↑ Summary Bio/Tools/EMBOSS/Palindrome.pm »
1 #
2 # BioPerl module for Bio::SeqFeature::Generic
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Ewan Birney <birney@sanger.ac.uk>
7 #
8 # Copyright Ewan Birney
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::SeqFeature::Generic - Generic SeqFeature
17  
18 =head1 SYNOPSIS
19  
20 $feat = Bio::SeqFeature::Generic->new(
21 -start => 10,
22 -end => 100,
23 -strand => -1,
24 -primary => 'repeat', # -primary_tag is a synonym
25 -source_tag => 'repeatmasker',
26 -display_name => 'alu family',
27 -score => 1000,
28 -tag => { new => 1,
29 author => 'someone',
30 sillytag => 'this is silly!' } );
31  
32 $feat = Bio::SeqFeature::Generic->new( -gff_string => $string );
33 # if you want explicitly GFF1
34 $feat = Bio::SeqFeature::Generic->new( -gff1_string => $string );
35  
36 # add it to an annotated sequence
37  
38 $annseq->add_SeqFeature($feat);
39  
40 =head1 DESCRIPTION
41  
42 Bio::SeqFeature::Generic is a generic implementation for the
43 Bio::SeqFeatureI interface, providing a simple object to provide all
44 the information for a feature on a sequence.
45  
46 For many Features, this is all you will need to use (for example, this
47 is fine for Repeats in DNA sequence or Domains in protein
48 sequence). For other features, which have more structure, this is a
49 good base class to extend using inheritance to have new things: this
50 is what is done in the L<Bio::SeqFeature::Gene>,
51 L<Bio::SeqFeature::Transcript> and L<Bio::SeqFeature::Exon>, which provide
52 well coordinated classes to represent genes on DNA sequence (for
53 example, you can get the protein sequence out from a transcript
54 class).
55  
56 For many Features, you want to add some piece of information, for
57 example a common one is that this feature is 'new' whereas other
58 features are 'old'. The tag system, which here is implemented using a
59 hash can be used here. You can use the tag system to extend the
60 L<Bio::SeqFeature::Generic> programmatically: that is, you know that you have
61 read in more information into the tag 'mytag' which you can then
62 retrieve. This means you do not need to know how to write inherited
63 Perl to provide more complex information on a feature, and/or, if you
64 do know but you do not want to write a new class every time you need
65 some extra piece of information, you can use the tag system to easily
66 store and then retrieve information.
67  
68 The tag system can be written in/out of GFF format, and also into EMBL
69 format via the L<Bio::SeqIO> system
70  
71 =head1 Implemented Interfaces
72  
73 This class implements the following interfaces.
74  
75 =over 4
76  
77 =item L<Bio::SeqFeatureI>
78  
79 Note that this includes implementing Bio::RangeI.
80  
81 =item L<Bio::AnnotatableI>
82  
83 =item L<Bio::FeatureHolderI>
84  
85 Features held by a feature are essentially sub-features.
86  
87 =back
88  
89 =head1 FEEDBACK
90  
91 =head2 Mailing Lists
92  
93 User feedback is an integral part of the evolution of this and other
94 Bioperl modules. Send your comments and suggestions preferably to one
95 of the Bioperl mailing lists. Your participation is much appreciated.
96  
97 bioperl-l@bioperl.org - General discussion
98 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
99  
100 =head2 Support
101  
102 Please direct usage questions or support issues to the mailing list:
103  
104 I<bioperl-l@bioperl.org>
105  
106 rather than to the module maintainer directly. Many experienced and
107 reponsive experts will be able look at the problem and quickly
108 address it. Please include a thorough description of the problem
109 with code and data examples if at all possible.
110  
111 =head2 Reporting Bugs
112  
113 Report bugs to the Bioperl bug tracking system to help us keep track
114 the bugs and their resolution. Bug reports can be submitted via
115 the web:
116  
117 https://github.com/bioperl/bioperl-live/issues
118  
119 =head1 AUTHOR - Ewan Birney
120  
121 Ewan Birney E<lt>birney@sanger.ac.ukE<gt>
122  
123 =head1 DEVELOPERS
124  
125 This class has been written with an eye out for inheritance. The fields
126 the actual object hash are:
127  
128 _gsf_tag_hash = reference to a hash for the tags
129 _gsf_sub_array = reference to an array for subfeatures
130  
131 =head1 APPENDIX
132  
133 The rest of the documentation details each of the object
134 methods. Internal methods are usually preceded with a _
135  
136 =cut
137  
138  
139 # Let the code begin...
140  
141  
142 package Bio::SeqFeature::Generic;
143 239 $Bio::SeqFeature::Generic::VERSION = '1.7.8';
144 239 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
145  
146 239 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
147  
148 239 ▶use Bio::Annotation::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
149 239 ▶use Bio::Location::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
150 239 ▶use Bio::Location::Split;
Subroutine BEGIN: called CC=1 SCAR=0.0
151 239 ▶use Bio::Tools::GFF;
Subroutine BEGIN: called CC=1 SCAR=0.0
152 #use Tie::IxHash;
153  
154 239 ▶use base qw(Bio::Root::Root Bio::SeqFeatureI Bio::FeatureHolderI Bio::AnnotatableI);
Subroutine BEGIN: called CC=1 SCAR=0.0
155  
156 31948 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
157 31948 my ( $caller, @args) = @_;
158 31948 my ($self) = $caller->SUPER::new(@args);
159 31948 $self->_register_for_cleanup(\&cleanup_generic);
160 31948 $self->{'_parse_h'} = {};
161 31948 $self->{'_gsf_tag_hash'} = {};
162  
163 # bulk-set attributes
164 31948 $self->set_attributes(@args);
165  
166 # done - we hope
167 31948 return $self;
168 }
169  
170 =head2 set_attributes
171  
172 Title : set_attributes
173 Usage :
174 Function: Sets a whole array of parameters at once.
175 Example :
176 Returns : none
177 Args : Named parameters, in the form as they would otherwise be passed
178 to new(). Currently recognized are:
179  
180 -start start position
181 -end end position
182 -strand strand
183 -phase the phase of the feature (0..2)
184 -primary_tag primary tag
185 -primary (synonym for -primary_tag)
186 -source_tag source tag
187 -source (synonym for -source_tag)
188 -frame frame
189 -score score value
190 -tag a reference to a tag/value hash
191 -gff_string GFF v.2 string to initialize from
192 -gff1_string GFF v.1 string to initialize from
193 -seq_id the display name of the sequence
194 -annotation the AnnotationCollectionI object
195 -location the LocationI object
196  
197 =cut
198  
199 34152 ▶sub set_attributes {
Subroutine set_attributes: called CC=23 SCAR=32.2
Pod documented
200 34152 my ($self,@args) = @_;
201 34152 my ($start, $end, $strand, $primary_tag, $source_tag, $primary,
202 $source, $frame, $score, $tag, $gff_string, $gff1_string,
203 $seqname, $seqid, $annot, $location, $display_name, $pid, $phase) =
204 $self->_rearrange([qw(START
205 END
206 STRAND
207 PRIMARY_TAG
208 SOURCE_TAG
209 PRIMARY
210 SOURCE
211 FRAME
212 SCORE
213 TAG
214 GFF_STRING
215 GFF1_STRING
216 SEQNAME
217 SEQ_ID
218 ANNOTATION
219 LOCATION
220 DISPLAY_NAME
221 PRIMARY_ID
222 PHASE
223 )], @args);
224 34152 ▶ $location && $self->location($location);
Branch: 1 branch
BranchTrueFalseTotal
$location and $self->location($location) 18340 15812 34152
225 34152 ▶ $gff_string && $self->_from_gff_string($gff_string);
Branch: 1 branch
BranchTrueFalseTotal
$gff_string and $self->_from_gff_string($gff_string) 0 34152 34152
226 34152 ▶ $gff1_string && do {
Branch: 1 branch
BranchTrueFalseTotal
$gff1_string and do { $self->gff_format("Bio::Tools::GFF"->new("-gff_version", 1)); $self->_from_gff_stream($gff1_string) } 0 34152 34152
227 0 $self->gff_format(Bio::Tools::GFF->new('-gff_version' => 1));
228 0 $self->_from_gff_stream($gff1_string);
229 };
230
231 34152 ▶ $pid && $self->primary_id($pid);
Branch: 1 branch
BranchTrueFalseTotal
$pid and $self->primary_id($pid) 0 34152 34152
232 34152 ▶ $primary_tag && $self->primary_tag($primary_tag);
Branch: 1 branch
BranchTrueFalseTotal
$primary_tag and $self->primary_tag($primary_tag) 19603 14549 34152
233 34152 ▶ $source_tag && $self->source_tag($source_tag);
Branch: 1 branch
BranchTrueFalseTotal
$source_tag and $self->source_tag($source_tag) 1262 32890 34152
234 34152 ▶ $primary && $self->primary_tag($primary);
Branch: 1 branch
BranchTrueFalseTotal
$primary and $self->primary_tag($primary) 219 33933 34152
235 34152 ▶ $source && $self->source_tag($source);
Branch: 1 branch
BranchTrueFalseTotal
$source and $self->source_tag($source) 370 33782 34152
236 34152 ▶ $annot && $self->annotation($annot);
Branch: 1 branch
BranchTrueFalseTotal
$annot and $self->annotation($annot) 0 34152 34152
237 34152 ▶ defined $start && $self->start($start);
Branch: 1 branch
BranchTrueFalseTotal
defined $start and $self->start($start) 10114 24038 34152
238 34152 ▶ defined $end && $self->end($end);
Branch: 1 branch
BranchTrueFalseTotal
defined $end and $self->end($end) 10113 24039 34152
239 34152 ▶ defined $strand && $self->strand($strand);
Branch: 1 branch
BranchTrueFalseTotal
defined $strand and $self->strand($strand) 10098 24054 34152
240 34152 ▶ defined $frame && $self->frame($frame);
Branch: 1 branch
BranchTrueFalseTotal
defined $frame and $self->frame($frame) 92 34060 34152
241 34152 ▶ defined $display_name && $self->display_name($display_name);
Branch: 1 branch
BranchTrueFalseTotal
defined $display_name and $self->display_name($display_name) 82 34070 34152
242 34152 ▶ defined $score && $self->score($score);
Branch: 1 branch
BranchTrueFalseTotal
defined $score and $self->score($score) 565 33587 34152
243 34152 ▶ defined $phase && $self->phase($phase);
Branch: 1 branch
BranchTrueFalseTotal
defined $phase and $self->phase($phase) 2 34150 34152
244  
245 34152 ▶ if($seqname) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqname) 0 34152 34152
246 0 $self->warn("-seqname is deprecated. Please use -seq_id instead.");
247 0 ▶ $seqid = $seqname unless $seqid;
Branch: 1 branch
BranchTrueFalseTotal
unless $seqid 0 0 0
248 }
249 34152 ▶ $self->seq_id($seqid) if (defined($seqid));
Branch: 1 branch
BranchTrueFalseTotal
if defined $seqid 1484 32668 34152
250 34152 ▶ $tag && do {
Branch: 1 branch
BranchTrueFalseTotal
$tag and do { foreach my $t (keys %$tag) { $self->add_tag_value($t, UNIVERSAL::isa($tag->{$t}, "ARRAY") ? @{$$tag{$t};} : $tag->{$t}); } } 1970 32182 34152
251 1970 foreach my $t ( keys %$tag ) {
252 4976 ▶ $self->add_tag_value($t, UNIVERSAL::isa($tag->{$t}, "ARRAY") ? @{$tag->{$t}} : $tag->{$t});
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($tag->{$t}, 'ARRAY') ? : 197 4779 4976
253 }
254 };
255 }
256  
257  
258 =head2 direct_new
259  
260 Title : direct_new
261 Usage : my $feat = Bio::SeqFeature::Generic->direct_new;
262 Function: create a blessed hash - for performance improvement in
263 object creation
264 Returns : Bio::SeqFeature::Generic object
265 Args : none
266  
267 =cut
268  
269 9596 ▶sub direct_new {
Subroutine direct_new: called CC=1 SCAR=0.0
Pod documented
270 9596 my ( $class) = @_;
271 9596 my ($self) = {};
272  
273 9596 bless $self,$class;
274  
275 9596 return $self;
276 }
277  
278  
279 =head2 location
280  
281 Title : location
282 Usage : my $location = $feat->location();
283 Function: returns a location object suitable for identifying location
284 of feature on sequence or parent feature
285 Returns : Bio::LocationI object
286 Args : [optional] Bio::LocationI object to set the value to.
287  
288 =cut
289  
290 583062 ▶sub location {
Subroutine location: called CC=5 SCAR=16.8
Pod documented
291 583062 my($self, $value ) = @_;
292  
293 583062 ▶ if (defined($value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) { } 29978 553084 583062
elsif (not $self->{'_location'}) { } 12184 540900 553084
294 29978 ▶ unless (ref($value) and $value->isa('Bio::LocationI')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value and $value->isa("Bio::LocationI")) 0 29978 29978
Condition33%1/3
ref $value and $value->isa("Bio::LocationI")
!ll&&!rl&&r
0029978
MC/DC0%0/2
ref $value and $value->isa("Bio::LocationI")
ref $value $value->isa("Bio::LocationI")
Truth table33%1/3
A and B
A= ref $valueB= $value->isa("Bio::LocationI")
ABresult
0X0
100
111
295 0 $self->throw("object $value pretends to be a location but ".
296 "does not implement Bio::LocationI");
297 }
298 29978 $self->{'_location'} = $value;
299 }
300 elsif (! $self->{'_location'}) {
301 # guarantees a real location object is returned every time
302 12184 $self->{'_location'} = Bio::Location::Simple->new();
303 }
304 583062 return $self->{'_location'};
305 }
306  
307  
308 =head2 start
309  
310 Title : start
311 Usage : my $start = $feat->start;
312 $feat->start(20);
313 Function: Get/set on the start coordinate of the feature
314 Returns : integer
315 Args : none
316  
317 =cut
318  
319 184317 ▶sub start {
Subroutine start: called CC=10 SCAR=36.3
Pod documented
320 184317 my ($self, $value) = @_;
321 # Return soon if setting value
322 184317 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 30677 153640 184317
323 30677 return $self->location->start($value);
324 }
325  
326 153640 ▶ return $self->location->start() if not defined $self->{'_gsf_seq'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_gsf_seq"} 87432 66208 153640
327 # Check circular sequences cut by origin
328 66208 my $start;
329 66208 ▶ if ( $self->{'_gsf_seq'}->is_circular
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_gsf_seq'}->is_circular and $self->location->isa('Bio::Location::SplitLocationI')) { } 0 66208 66208
Condition66%2/3
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI")
!ll&&!rl&&r
661001080
MC/DC0%0/2
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI")
$self->{"_gsf_seq"}->is_circular $self->location->isa("Bio::Location::SplitLocationI")
Truth table66%2/3
A and B
A= $self->{"_gsf_seq"}->is_circularB= $self->location->isa("Bio::Location::SplitLocationI")
ABresult
0X0
100
111
330 and $self->location->isa('Bio::Location::SplitLocationI')
331 ) {
332 0 my $primary_seq_length = $self->{'_gsf_seq'}->length;
333 0 my @sublocs = $self->location->sub_Location;
334  
335 0 my $cut_by_origin = 0;
336 0 my ($a_end, $a_strand) = (0, 0);
337 0 my ($b_start, $b_strand) = (0, 0);
338 0 ▶ for (my $i = 1; $i < scalar @sublocs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @sublocs) 0 0 0
339 0 $a_end = $sublocs[$i-1]->end;
340 0 $a_strand = $sublocs[$i-1]->strand;
341 0 $b_start = $sublocs[$i]->start;
342 0 $b_strand = $sublocs[$i]->strand;
343 # cut by origin condition
344 0 ▶ if ( $a_end == $primary_seq_length
Branch: 1 branch
BranchTrueFalseTotal
if ($a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand) 0 0 0
Condition0%0/6
$a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand
!ll&&!rl&&r
000
$a_end == $primary_seq_length and $b_start == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand
$a_end == $primary_seq_length $b_start == 1 $a_strand == $b_strand
Truth table0%0/4
A and B and C
A= $a_end == $primary_seq_lengthB= $b_start == 1C= $a_strand == $b_strand
ABCresult
0XX0
10X0
1100
1111
345 and $b_start == 1
346 and $a_strand == $b_strand
347 ) {
348 0 $cut_by_origin = 1;
349 0 last;
350 }
351 }
352 0 ▶ $start = ($cut_by_origin == 1) ? ($sublocs[0]->start) : ($self->location->start);
Branch: 1 branch
BranchTrueFalseTotal
$cut_by_origin == 1 ? : 0 0 0
353 }
354 else {
355 66208 $start = $self->location->start;
356 }
357 66208 return $start;
358 }
359  
360  
361 =head2 end
362  
363 Title : end
364 Usage : my $end = $feat->end;
365 $feat->end($end);
366 Function: get/set on the end coordinate of the feature
367 Returns : integer
368 Args : none
369  
370 =cut
371  
372 184118 ▶sub end {
Subroutine end: called CC=10 SCAR=36.3
Pod documented
373 184118 my ($self, $value) = @_;
374 # Return soon if setting value
375 184118 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 30674 153444 184118
376 30674 return $self->location->end($value);
377 }
378  
379 153444 ▶ return $self->location->end() if not defined $self->{'_gsf_seq'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_gsf_seq"} 87487 65957 153444
380 # Check circular sequences cut by origin
381 65957 my $end;
382 65957 ▶ if ( $self->{'_gsf_seq'}->is_circular
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_gsf_seq'}->is_circular and $self->location->isa('Bio::Location::SplitLocationI')) { } 0 65957 65957
Condition66%2/3
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI")
!ll&&!rl&&r
658491080
MC/DC0%0/2
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI")
$self->{"_gsf_seq"}->is_circular $self->location->isa("Bio::Location::SplitLocationI")
Truth table66%2/3
A and B
A= $self->{"_gsf_seq"}->is_circularB= $self->location->isa("Bio::Location::SplitLocationI")
ABresult
0X0
100
111
383 and $self->location->isa('Bio::Location::SplitLocationI')
384 ) {
385 0 my $primary_seq_length = $self->{'_gsf_seq'}->length;
386 0 my @sublocs = $self->location->sub_Location;
387  
388 0 my $cut_by_origin = 0;
389 0 my ($a_end, $a_strand) = (0, 0);
390 0 my ($b_start, $b_strand) = (0, 0);
391 0 ▶ for (my $i = 1; $i < scalar @sublocs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @sublocs) 0 0 0
392 0 $a_end = $sublocs[$i-1]->end;
393 0 $a_strand = $sublocs[$i-1]->strand;
394 0 $b_start = $sublocs[$i]->start;
395 0 $b_strand = $sublocs[$i]->strand;
396 # cut by origin condition
397 0 ▶ if ( $a_end == $primary_seq_length
Branch: 1 branch
BranchTrueFalseTotal
if ($a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand) 0 0 0
Condition0%0/6
$a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand
!ll&&!rl&&r
000
$a_end == $primary_seq_length and $b_start == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$a_end == $primary_seq_length and $b_start == 1 and $a_strand == $b_strand
$a_end == $primary_seq_length $b_start == 1 $a_strand == $b_strand
Truth table0%0/4
A and B and C
A= $a_end == $primary_seq_lengthB= $b_start == 1C= $a_strand == $b_strand
ABCresult
0XX0
10X0
1100
1111
398 and $b_start == 1
399 and $a_strand == $b_strand
400 ) {
401 0 $cut_by_origin = 1;
402 0 last;
403 }
404 }
405 0 ▶ $end = ($cut_by_origin == 1) ? ($sublocs[-1]->end) : ($self->location->end);
Branch: 1 branch
BranchTrueFalseTotal
$cut_by_origin == 1 ? : 0 0 0
406 }
407 else {
408 65957 $end = $self->location->end;
409 }
410 65957 return $end;
411 }
412  
413  
414 =head2 length
415  
416 Title : length
417 Usage : my $len = $feat->length;
418 Function: Get the feature length computed as:
419 $feat->end - $feat->start + 1
420 Returns : integer
421 Args : none
422  
423 =cut
424  
425 2523 ▶sub length {
Subroutine length: called CC=3 SCAR=12.7
Pod documented
426 2523 my $self = shift;
427 2523 my $length = $self->end() - $self->start() + 1;
428  
429 # In circular sequences cut by origin $start > $end,
430 # e.g., join(5075..5386,1..51)), $start = 5075, $end = 51,
431 # then adjust using the primary_seq length (5386)
432 2523 ▶ if ($length < 0 and defined $self->{'_gsf_seq'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length < 0 and defined $self->{"_gsf_seq"}) 0 2523 2523
Condition33%1/3
$length < 0 and defined $self->{"_gsf_seq"}
!ll&&!rl&&r
252300
MC/DC0%0/2
$length < 0 and defined $self->{"_gsf_seq"}
$length < 0 defined $self->{"_gsf_seq"}
Truth table33%1/3
A and B
A= $length < 0B= defined $self->{"_gsf_seq"}
ABresult
0X0
100
111
433 0 $length += $self->{'_gsf_seq'}->length;
434 }
435 2523 return $length;
436 }
437  
438  
439 =head2 strand
440  
441 Title : strand
442 Usage : my $strand = $feat->strand();
443 $feat->strand($strand);
444 Function: get/set on strand information, being 1,-1 or 0
445 Returns : -1,1 or 0
446 Args : none
447  
448 =cut
449  
450 141004 ▶sub strand {
Subroutine strand: called CC=1 SCAR=0.0
Pod documented
451 141004 my $self = shift;
452 141004 return $self->location->strand(@_);
453 }
454  
455  
456 =head2 score
457  
458 Title : score
459 Usage : my $score = $feat->score();
460 $feat->score($score);
461 Function: get/set on score information
462 Returns : float
463 Args : none if get, the new value if set
464  
465 =cut
466  
467 2437 ▶sub score {
Subroutine score: called CC=9 SCAR=24.0
Pod documented
468 2437 my $self = shift;
469  
470 2437 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2240 197 2437
471 2240 my $value = shift;
472  
473 2240 ▶ if ( defined $value && $value && $value !~ /^[A-Za-z]+$/ &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and $value and not $value =~ /^[A-Za-z]+$/ and not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/ and $value != 0) 0 2240 2240
Condition66%8/12
defined $value and $value and not $value =~ /^[A-Za-z]+$/ and not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/ and $value != 0
!ll&&!rl&&r
224000
defined $value and $value and not $value =~ /^[A-Za-z]+$/ and not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/
!ll&&!rl&&r
67615640
defined $value and $value and not $value =~ /^[A-Za-z]+$/
!ll&&!rl&&r
67601564
defined $value and $value
!ll&&!rl&&r
638381564
MC/DC0%0/5
defined $value and $value and not $value =~ /^[A-Za-z]+$/ and not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/ and $value != 0
defined $value $value not $value =~ /^[A-Za-z]+$/ not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/ $value != 0
Truth table50%3/6
A and B and not(C) and not(D) and E
A= defined $valueB= $valueC= not $value =~ /^[A-Za-z]+$/D= not $value =~ /^[+-]?\d+\.?\d*(e-\d+)?/E= $value != 0
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
474 $value !~ /^[+-]?\d+\.?\d*(e-\d+)?/ and $value != 0) {
475 0 $self->throw(-class=>'Bio::Root::BadParameter',
476 -text=>"'$value' is not a valid score",
477 -value=>$value);
478 }
479 2240 ▶ if ($self->has_tag('score')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_tag("score")) 0 2240 2240
480 0 $self->warn("Removing score value(s)");
481 0 $self->remove_tag('score');
482 }
483 2240 $self->add_tag_value('score',$value);
484 }
485 2437 ▶ my ($score) = $self->has_tag('score') ? $self->get_tag_values('score') : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->has_tag('score') ? : 2433 4 2437
486 2437 return $score;
487 }
488  
489  
490 =head2 frame
491  
492 Title : frame
493 Usage : my $frame = $feat->frame();
494 $feat->frame($frame);
495 Function: get/set on frame information
496 Returns : 0,1,2, '.'
497 Args : none if get, the new value if set
498  
499 =cut
500  
501 2449 ▶sub frame {
Subroutine frame: called CC=6 SCAR=18.7
Pod documented
502 2449 my $self = shift;
503  
504 2449 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1708 741 2449
505 1708 my $value = shift;
506 1708 ▶ if ( defined $value &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and not $value =~ /^[0-2.]$/) 0 1708 1708
Condition33%1/3
defined $value and not $value =~ /^[0-2.]$/
!ll&&!rl&&r
017080
MC/DC0%0/2
defined $value and not $value =~ /^[0-2.]$/
defined $value not $value =~ /^[0-2.]$/
Truth table33%1/3
A and not(B)
A= defined $valueB= not $value =~ /^[0-2.]$/
ABresult
0X0
100
111
507 $value !~ /^[0-2.]$/ ) {
508 0 $self->throw("'$value' is not a valid frame");
509 }
510 1708 ▶ if( defined $value && $value eq '.' ) { $value = '.' }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and $value eq ".") 8 1700 1708
Condition66%2/3
defined $value and $value eq "."
!ll&&!rl&&r
017008
MC/DC50%1/2
defined $value and $value eq "."
defined $value $value eq "."
Truth table66%2/3
A and B
A= defined $valueB= $value eq "."
ABresult
0X0
100
111
511 1708 return $self->{'_gsf_frame'} = $value;
512 }
513 741 return $self->{'_gsf_frame'};
514 }
515  
516  
517 =head2 primary_tag
518  
519 Title : primary_tag
520 Usage : my $tag = $feat->primary_tag();
521 $feat->primary_tag('exon');
522 Function: get/set on the primary tag for a feature,
523 eg 'exon'
524 Returns : a string
525 Args : none
526  
527 =cut
528  
529 130098 ▶sub primary_tag {
Subroutine primary_tag: called CC=3 SCAR=11.0
Pod documented
530 130098 my $self = shift;
531 130098 ▶ return $self->{'_primary_tag'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 31348 98750 130098
532 98750 ▶ return $self->{'_primary_tag'} || '';
Condition100%2/2
$self->{'_primary_tag'} || ''
l!l
955003250
MC/DC100%1/1
$self->{'_primary_tag'} || ''
$self->{'_primary_tag'}
Truth table100%2/2
A
A= $self->{'_primary_tag'}
Aresult
11
00
533 }
534  
535  
536 =head2 source_tag
537  
538 Title : source_tag
539 Usage : my $tag = $feat->source_tag();
540 $feat->source_tag('genscan');
541 Function: Returns the source tag for a feature,
542 eg, 'genscan'
543 Returns : a string
544 Args : none
545  
546 =cut
547  
548 67990 ▶sub source_tag {
Subroutine source_tag: called CC=3 SCAR=11.0
Pod documented
549 67990 my $self = shift;
550 67990 ▶ return $self->{'_source_tag'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 31319 36671 67990
551 36671 ▶ return $self->{'_source_tag'} || '';
Condition100%2/2
$self->{'_source_tag'} || ''
l!l
366701
MC/DC100%1/1
$self->{'_source_tag'} || ''
$self->{'_source_tag'}
Truth table100%2/2
A
A= $self->{'_source_tag'}
Aresult
11
00
552 }
553  
554  
555 =head2 has_tag
556  
557 Title : has_tag
558 Usage : my $value = $feat->has_tag('some_tag');
559 Function: Tests whether a feature containings a tag
560 Returns : TRUE if the SeqFeature has the tag,
561 and FALSE otherwise.
562 Args : The name of a tag
563  
564 =cut
565  
566 50710 ▶sub has_tag {
Subroutine has_tag: called CC=1 SCAR=0.0
Pod documented
567 50710 my ($self, $tag) = @_;
568 50710 return exists $_[0]->{'_gsf_tag_hash'}->{$tag};
569 }
570  
571  
572 =head2 add_tag_value
573  
574 Title : add_tag_value
575 Usage : $feat->add_tag_value('note',"this is a note");
576 Returns : TRUE on success
577 Args : tag (string) and one or more values (any scalar(s))
578  
579 =cut
580  
581 106618 ▶sub add_tag_value {
Subroutine add_tag_value: called CC=2 SCAR=6.9
Pod documented
582 106618 my $self = shift;
583 106618 my $tag = shift;
584 106618 ▶ $self->{'_gsf_tag_hash'}->{$tag} ||= [];
Condition100%2/2
$self->{"_gsf_tag_hash"}{$tag} ||= []
l!l
1662989989
MC/DC100%1/1
$self->{"_gsf_tag_hash"}{$tag} ||= []
$self->{"_gsf_tag_hash"}{$tag}
Truth table100%2/2
A
A= $self->{"_gsf_tag_hash"}{$tag}
Aresult
11
00
585 106618 push(@{$self->{'_gsf_tag_hash'}->{$tag}},@_);
586 }
587  
588  
589 =head2 get_tag_values
590  
591 Title : get_tag_values
592 Usage : my @values = $feat->get_tag_values('note');
593 Function: Returns a list of all the values stored
594 under a particular tag.
595 Returns : A list of scalars
596 Args : The name of the tag
597  
598 =cut
599  
600 50827 ▶sub get_tag_values {
Subroutine get_tag_values: called CC=3 SCAR=12.3
Pod documented
601 50827 my ($self, $tag) = @_;
602  
603 0 ▶ if( ! defined $tag ) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tag) 0 50827 50827
604 50827 ▶ if ( ! exists $self->{'_gsf_tag_hash'}->{$tag} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_gsf_tag_hash"}{$tag}) 0 50827 50827
605 0 $self->throw("asking for tag value that does not exist $tag");
606 }
607 50827 return @{$self->{'_gsf_tag_hash'}->{$tag}};
608 }
609  
610  
611 =head2 get_all_tags
612  
613 Title : get_all_tags
614 Usage : my @tags = $feat->get_all_tags();
615 Function: Get a list of all the tags in a feature
616 Returns : An array of tag names
617 Args : none
618  
619 # added a sort so that tags will be returned in a predictable order
620 # I still think we should be able to specify a sort function
621 # to the object at some point
622 # -js
623  
624 =cut
625  
626 18879 ▶sub get_all_tags {
Subroutine get_all_tags: called CC=1 SCAR=0.0
Pod documented
627 18879 my ($self, @args) = @_;
628 18879 return sort keys %{ $self->{'_gsf_tag_hash'}};
629 }
630  
631  
632 =head2 remove_tag
633  
634 Title : remove_tag
635 Usage : $feat->remove_tag('some_tag');
636 Function: removes a tag from this feature
637 Returns : the array of values for this tag before removing it
638 Args : tag (string)
639  
640 =cut
641  
642 6 ▶sub remove_tag {
Subroutine remove_tag: called CC=2 SCAR=7.1
Pod documented
643 6 my ($self, $tag) = @_;
644  
645 6 ▶ if ( ! exists $self->{'_gsf_tag_hash'}->{$tag} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_gsf_tag_hash"}{$tag}) 0 6 6
646 0 $self->throw("trying to remove a tag that does not exist: $tag");
647 }
648 6 my @vals = @{$self->{'_gsf_tag_hash'}->{$tag}};
649 6 delete $self->{'_gsf_tag_hash'}->{$tag};
650 6 return @vals;
651 }
652  
653  
654 =head2 attach_seq
655  
656 Title : attach_seq
657 Usage : $feat->attach_seq($seq);
658 Function: Attaches a Bio::Seq object to this feature. This
659 Bio::Seq object is for the *entire* sequence: ie
660 from 1 to 10000
661 Example :
662 Returns : TRUE on success
663 Args : a Bio::PrimarySeqI compliant object
664  
665 =cut
666  
667 15993 ▶sub attach_seq {
Subroutine attach_seq: called CC=5 SCAR=18.9
Pod documented
668 15993 my ($self, $seq) = @_;
669  
670 15993 ▶ if ( ! ($seq && ref($seq) && $seq->isa("Bio::PrimarySeqI")) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seq and ref $seq and $seq->isa("Bio::PrimarySeqI")) 0 15993 15993
Condition33%2/6
$seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
0015993
$seq and ref $seq
!ll&&!rl&&r
0015993
MC/DC0%0/3
$seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
$seq ref $seq $seq->isa("Bio::PrimarySeqI")
Truth table25%1/4
A and B and C
A= $seqB= ref $seqC= $seq->isa("Bio::PrimarySeqI")
ABCresult
0XX0
10X0
1100
1111
671 0 $self->throw("Must attach Bio::PrimarySeqI objects to SeqFeatures but got '".ref($seq)."'");
672 }
673  
674 15993 $self->{'_gsf_seq'} = $seq;
675  
676 # attach to sub features if they want it
677 15993 foreach ( $self->sub_SeqFeature() ) {
678 4034 $_->attach_seq($seq);
679 }
680 15993 return 1;
681 }
682  
683  
684 =head2 seq
685  
686 Title : seq
687 Usage : my $tseq = $feat->seq();
688 Function: returns the truncated sequence (if there) for this
689 Example :
690 Returns : sub seq (a Bio::PrimarySeqI compliant object) on attached sequence
691 bounded by start & end, or undef if there is no sequence attached.
692 If the strand is defined and set to -1, the returned sequence is
693 the reverse-complement of the region
694 Args : none
695  
696 =cut
697  
698 228 ▶sub seq {
Subroutine seq: called CC=8 SCAR=23.0
Pod documented
699 228 my ($self, $arg) = @_;
700  
701 228 ▶ if ( defined $arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg) 0 228 228
702 0 $self->throw("Calling SeqFeature::Generic->seq with an argument. You probably want attach_seq");
703 }
704  
705 228 ▶ if ( ! exists $self->{'_gsf_seq'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_gsf_seq"}) 1 227 228
706 1 return;
707 }
708  
709 # assumming our seq object is sensible, it should not have to yank
710 # the entire sequence out here.
711 227 my $seq;
712 227 my $start = $self->start;
713 227 my $end = $self->end;
714 # Check circular sequences cut by origin (e.g. join(2006035..2007700,1..257))
715 227 ▶ if ( $self->{'_gsf_seq'}->is_circular
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_gsf_seq'}->is_circular and $self->location->isa('Bio::Location::SplitLocationI') and $start > $end) { } 0 227 227
Condition50%3/6
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI") and $start > $end
!ll&&!rl&&r
22700
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI")
!ll&&!rl&&r
1191080
MC/DC0%0/3
$self->{"_gsf_seq"}->is_circular and $self->location->isa("Bio::Location::SplitLocationI") and $start > $end
$self->{"_gsf_seq"}->is_circular $self->location->isa("Bio::Location::SplitLocationI") $start > $end
Truth table50%2/4
A and B and C
A= $self->{"_gsf_seq"}->is_circularB= $self->location->isa("Bio::Location::SplitLocationI")C= $start > $end
ABCresult
0XX0
10X0
1100
1111
716 and $self->location->isa('Bio::Location::SplitLocationI')
717 and $start > $end
718 ) {
719 0 my $primary_seq_length = $self->{'_gsf_seq'}->length;
720  
721 # Get duplicate object with the first sequence piece using trunc()
722 0 $seq = $self->{'_gsf_seq'}->trunc($start, $primary_seq_length);
723  
724 # Get post-origin sequence and build the complete sequence
725 0 my $post_origin = $self->{'_gsf_seq'}->subseq(1, $end);
726 0 my $complete_seq = $seq->seq() . $post_origin;
727  
728 # Add complete sequence to object
729 0 $seq->seq($complete_seq);
730 }
731 else {
732 227 $seq = $self->{'_gsf_seq'}->trunc($start, $end);
733 }
734  
735 227 ▶ if ( defined $self->strand && $self->strand == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->strand and $self->strand == -1) 142 85 227
Condition100%3/3
defined $self->strand and $self->strand == -1
!ll&&!rl&&r
976142
MC/DC100%2/2
defined $self->strand and $self->strand == -1
defined $self->strand $self->strand == -1
Truth table100%3/3
A and B
A= defined $self->strandB= $self->strand == -1
ABresult
0X0
100
111
736 142 $seq = $seq->revcom;
737 }
738  
739 227 return $seq;
740 }
741  
742  
743 =head2 entire_seq
744  
745 Title : entire_seq
746 Usage : my $whole_seq = $feat->entire_seq();
747 Function: gives the entire sequence that this seqfeature is attached to
748 Example :
749 Returns : a Bio::PrimarySeqI compliant object, or undef if there is no
750 sequence attached
751 Args :
752  
753 =cut
754  
755 733 ▶sub entire_seq {
Subroutine entire_seq: called CC=1 SCAR=0.0
Pod documented
756 733 return shift->{'_gsf_seq'};
757 }
758  
759  
760 =head2 seq_id
761  
762 Title : seq_id
763 Usage : $feat->seq_id($newval)
764 Function: There are many cases when you make a feature that you
765 do know the sequence name, but do not know its actual
766 sequence. This is an attribute such that you can store
767 the ID (e.g., display_id) of the sequence.
768  
769 This attribute should *not* be used in GFF dumping, as
770 that should come from the collection in which the seq
771 feature was found.
772 Returns : value of seq_id
773 Args : newvalue (optional)
774  
775 =cut
776  
777 67762 ▶sub seq_id {
Subroutine seq_id: called CC=2 SCAR=6.9
Pod documented
778 67762 my $obj = shift;
779 67762 ▶ return $obj->{'_gsf_seq_id'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 30995 36767 67762
780 36767 return $obj->{'_gsf_seq_id'};
781 }
782  
783  
784 =head2 display_name
785  
786 Title : display_name
787 Usage : my $featname = $feat->display_name;
788 Function: Implements the display_name() method, which is a human-readable
789 name for the feature.
790 Returns : value of display_name (a string)
791 Args : Optionally, on set the new value or undef
792  
793 =cut
794  
795 86 ▶sub display_name {
Subroutine display_name: called CC=3 SCAR=11.0
Pod documented
796 86 my $self = shift;
797 86 ▶ return $self->{'display_name'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 83 3 86
798 3 ▶ return $self->{'display_name'} || '';
Condition100%2/2
$self->{'display_name'} || ''
l!l
21
MC/DC100%1/1
$self->{'display_name'} || ''
$self->{'display_name'}
Truth table100%2/2
A
A= $self->{'display_name'}
Aresult
11
00
799 }
800  
801  
802 =head1 Methods for implementing Bio::AnnotatableI
803  
804 =head2 annotation
805  
806 Title : annotation
807 Usage : $feat->annotation($annot_obj);
808 Function: Get/set the annotation collection object for annotating this
809 feature.
810  
811 Example :
812 Returns : A Bio::AnnotationCollectionI object
813 Args : newvalue (optional)
814  
815 =cut
816  
817 2349 ▶sub annotation {
Subroutine annotation: called CC=4 SCAR=14.0
Pod documented
818 2349 my ($obj,$value) = @_;
819  
820 # we are smart if someone references the object and there hasn't been
821 # one set yet
822 2349 ▶ if(defined $value || ! defined $obj->{'annotation'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $obj->{"annotation"}) 1498 851 2349
Condition66%2/3
defined $value or not defined $obj->{"annotation"}
l!l&&r!l&&!r
01498851
MC/DC50%1/2
defined $value or not defined $obj->{"annotation"}
defined $value not defined $obj->{"annotation"}
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $obj->{"annotation"}
ABresult
1X1
011
000
823 1498 ▶ $value = Bio::Annotation::Collection->new() unless ( defined $value );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1498 0 1498
824 1498 $obj->{'annotation'} = $value;
825 }
826 2349 return $obj->{'annotation'};
827 }
828  
829  
830 =head1 Methods to implement Bio::FeatureHolderI
831  
832 This includes methods for retrieving, adding, and removing
833 features. Since this is already a feature, features held by this
834 feature holder are essentially sub-features.
835  
836 =head2 get_SeqFeatures
837  
838 Title : get_SeqFeatures
839 Usage : my @feats = $feat->get_SeqFeatures();
840 Function: Returns an array of sub Sequence Features
841 Returns : An array
842 Args : none
843  
844 =cut
845  
846 29019 ▶sub get_SeqFeatures {
Subroutine get_SeqFeatures: called CC=2 SCAR=6.9
Pod documented
847 29019 ▶ return @{ shift->{'_gsf_sub_array'} || []};
Condition100%2/2
+(shift())->{'_gsf_sub_array'} || []
l!l
632922690
MC/DC100%1/1
+(shift())->{'_gsf_sub_array'} || []
+(shift())->{'_gsf_sub_array'}
Truth table100%2/2
A
A= +(shift())->{'_gsf_sub_array'}
Aresult
11
00
848 }
849  
850  
851 =head2 add_SeqFeature
852  
853 Title : add_SeqFeature
854 Usage : $feat->add_SeqFeature($subfeat);
855 $feat->add_SeqFeature($subfeat,'EXPAND');
856 Function: Adds a SeqFeature into the subSeqFeature array.
857 With no 'EXPAND' qualifer, subfeat will be tested
858 as to whether it lies inside the parent, and throw
859 an exception if not.
860  
861 If EXPAND is used, the parent's start/end/strand will
862 be adjusted so that it grows to accommodate the new
863 subFeature
864  
865 !IMPORTANT! The coordinates of the subfeature should not be relative
866 to the parent feature it is attached to, but relative to the sequence
867 the parent feature is located on.
868  
869 Returns : nothing
870 Args : An object which has the SeqFeatureI interface
871  
872 =cut
873  
874 22649 ▶sub add_SeqFeature {
Subroutine add_SeqFeature: called CC=7 SCAR=21.3
Pod documented
875 22649 my ($self,$feat,$expand) = @_;
876 22649 ▶ unless( defined $feat ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $feat) 0 22649 22649
877 0 $self->warn("Called add_SeqFeature with no feature, ignoring");
878 0 return;
879 }
880 22649 ▶ if ( !$feat->isa('Bio::SeqFeatureI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($feat->isa("Bio::SeqFeatureI")) 0 22649 22649
881 0 $self->warn("$feat does not implement Bio::SeqFeatureI. Will add it anyway, but beware...");
882 }
883  
884 22649 ▶ if($expand && ($expand eq 'EXPAND')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expand and $expand eq 'EXPAND') { } 18328 4321 22649
Condition66%2/3
$expand and $expand eq "EXPAND"
!ll&&!rl&&r
4321018328
MC/DC50%1/2
$expand and $expand eq "EXPAND"
$expand $expand eq "EXPAND"
Truth table66%2/3
A and B
A= $expandB= $expand eq "EXPAND"
ABresult
0X0
100
111
885 18328 $self->_expand_region($feat);
886 } else {
887 4321 ▶ if ( !$self->contains($feat) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->contains($feat)) 0 4321 4321
888 0 $self->throw("$feat is not contained within parent feature, and expansion is not valid");
889 }
890 }
891  
892 22649 ▶ $self->{'_gsf_sub_array'} = [] unless exists($self->{'_gsf_sub_array'});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_gsf_sub_array"} 3796 18853 22649
893 22649 push(@{$self->{'_gsf_sub_array'}},$feat);
894  
895 }
896  
897  
898 =head2 remove_SeqFeatures
899  
900 Title : remove_SeqFeatures
901 Usage : $feat->remove_SeqFeatures;
902 Function: Removes all SeqFeatures
903  
904 If you want to remove only a subset of features then remove that
905 subset from the returned array, and add back the rest.
906 Example :
907 Returns : The array of Bio::SeqFeatureI implementing features that was
908 deleted.
909 Args : none
910  
911 =cut
912  
913 48 ▶sub remove_SeqFeatures {
Subroutine remove_SeqFeatures: called CC=2 SCAR=6.9
Pod documented
914 48 my ($self) = @_;
915 48 ▶ my @subfeats = @{$self->{'_gsf_sub_array'} || []};
Condition100%2/2
$self->{'_gsf_sub_array'} || []
l!l
2424
MC/DC100%1/1
$self->{'_gsf_sub_array'} || []
$self->{'_gsf_sub_array'}
Truth table100%2/2
A
A= $self->{'_gsf_sub_array'}
Aresult
11
00
916 48 $self->{'_gsf_sub_array'} = []; # zap the array implicitly.
917 48 return @subfeats;
918 }
919  
920  
921 =head1 GFF-related methods
922  
923 =head2 gff_format
924  
925 Title : gff_format
926 Usage : # get:
927 my $gffio = $feat->gff_format();
928 # set (change the default version of GFF2):
929 $feat->gff_format(Bio::Tools::GFF->new(-gff_version => 1));
930 Function: Get/set the GFF format interpreter. This object is supposed to
931 format and parse GFF. See Bio::Tools::GFF for the interface.
932  
933 If this method is called as class method, the default for all
934 newly created instances will be changed. Otherwise only this
935 instance will be affected.
936 Example :
937 Returns : a Bio::Tools::GFF compliant object
938 Args : On set, an instance of Bio::Tools::GFF or a derived object.
939  
940 =cut
941  
942 1 ▶sub gff_format {
Subroutine gff_format: called CC=5 SCAR=23.4
Pod documented
943 1 my ($self, $gffio) = @_;
944 1 ▶ if(defined($gffio)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $gffio) 0 1 1
945 0 ▶ if(ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
946 0 $self->{'_gffio'} = $gffio;
947 } else {
948 0 $Bio::SeqFeatureI::static_gff_formatter = $gffio;
949 }
950 }
951 return (ref($self) && exists($self->{'_gffio'}) ?
952 1 ▶ $self->{'_gffio'} : $self->_static_gff_formatter);
Branch: 1 branch
BranchTrueFalseTotal
ref $self && exists $self->{'_gffio'} ? : 0 1 1
Condition33%1/3
ref $self and exists $self->{"_gffio"}
!ll&&!rl&&r
010
MC/DC0%0/2
ref $self and exists $self->{"_gffio"}
ref $self exists $self->{"_gffio"}
Truth table33%1/3
A and B
A= ref $selfB= exists $self->{"_gffio"}
ABresult
0X0
100
111
953 }
954  
955  
956 =head2 gff_string
957  
958 Title : gff_string
959 Usage : my $str = $feat->gff_string;
960 my $str = $feat->gff_string($gff_formatter);
961 Function: Provides the feature information in GFF format.
962  
963 We override this here from Bio::SeqFeatureI in order to use the
964 formatter returned by gff_format().
965  
966 Returns : A string
967 Args : Optionally, an object implementing gff_string().
968  
969 =cut
970  
971 8 ▶sub gff_string {
Subroutine gff_string: called CC=2 SCAR=6.9
Pod documented
972 8 my ($self,$formatter) = @_;
973 8 ▶ $formatter = $self->gff_format() unless $formatter;
Branch: 1 branch
BranchTrueFalseTotal
unless $formatter 1 7 8
974 8 return $formatter->gff_string($self);
975 }
976  
977  
978 =head2 slurp_gff_file
979  
980 Title : slurp_file
981 Usage : my @features = Bio::SeqFeature::Generic::slurp_gff_file(\*FILE);
982 Function: Sneaky function to load an entire file as in memory objects.
983 Beware of big files.
984  
985 This method is deprecated. Use Bio::Tools::GFF instead, which can
986 also handle large files.
987  
988 Example :
989 Returns :
990 Args :
991  
992 =cut
993  
994 0 ▶sub slurp_gff_file {
Subroutine slurp_gff_file: not called CC=1 SCAR=6.9
Pod documented
995 0 Carp::croak("Bio::SeqFeature::Generic->slurp_gff_file has been removed."
996 . " Use Bio::Tools::GFF instead.");
997 }
998  
999  
1000 =head2 _from_gff_string
1001  
1002 Title : _from_gff_string
1003 Usage :
1004 Function: Set feature properties from GFF string.
1005  
1006 This method uses the object returned by gff_format() for the
1007 actual interpretation of the string. Set a different GFF format
1008 interpreter first if you need a specific version, like GFF1. (The
1009 default is GFF2.)
1010 Example :
1011 Returns :
1012 Args : a GFF-formatted string
1013  
1014 =cut
1015  
1016 0 ▶sub _from_gff_string {
Subroutine _from_gff_string: not called CC=1 SCAR=6.9
1017 0 my ($self, $string) = @_;
1018 0 $self->gff_format()->from_gff_string($self, $string);
1019 }
1020  
1021  
1022 =head2 _expand_region
1023  
1024 Title : _expand_region
1025 Usage : $feat->_expand_region($feature);
1026 Function: Expand the total region covered by this feature to
1027 accommodate for the given feature.
1028  
1029 May be called whenever any kind of subfeature is added to this
1030 feature. add_SeqFeature() already does this.
1031 Returns :
1032 Args : A Bio::SeqFeatureI implementing object.
1033  
1034 =cut
1035  
1036 18873 ▶sub _expand_region {
Subroutine _expand_region: called CC=4 SCAR=13.9
1037 18873 my ($self, $feat) = @_;
1038 18873 ▶ if(! $feat->isa('Bio::SeqFeatureI')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($feat->isa("Bio::SeqFeatureI")) 0 18873 18873
1039 0 $self->warn("$feat does not implement Bio::SeqFeatureI");
1040 }
1041 # if this doesn't have start set - forget it!
1042 # changed to reflect sanity checks for LocationI
1043 18873 ▶ if(!$self->location->valid_Location) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->location->valid_Location) { } 2102 16771 18873
1044 2102 $self->start($feat->start);
1045 2102 $self->end($feat->end);
1046 2102 ▶ $self->strand($feat->strand) unless $self->strand;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->strand 2009 93 2102
1047 } else {
1048 16771 my ($start,$end,$strand) = $self->union($feat);
1049 16771 $self->start($start);
1050 16771 $self->end($end);
1051 16771 $self->strand($strand);
1052 }
1053 }
1054  
1055  
1056 =head2 _parse
1057  
1058 Title : _parse
1059 Usage :
1060 Function: Parsing hints
1061 Example :
1062 Returns :
1063 Args :
1064  
1065 =cut
1066  
1067 0 ▶sub _parse {
Subroutine _parse: not called CC=1 SCAR=6.9
1068 0 my ($self) = @_;
1069 0 return $self->{'_parse_h'};
1070 }
1071  
1072  
1073 =head2 _tag_value
1074  
1075 Title : _tag_value
1076 Usage :
1077 Function: For internal use only. Convenience method for those tags that
1078 may only have a single value.
1079 Returns : The first value under the given tag as a scalar (string)
1080 Args : The tag as a string. Optionally, the value on set.
1081  
1082 =cut
1083  
1084 5373 ▶sub _tag_value {
Subroutine _tag_value: called CC=4 SCAR=13.9
1085 5373 my $self = shift;
1086 5373 my $tag = shift;
1087  
1088 5373 ▶ if(@_ || (! $self->has_tag($tag))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ or not $self->has_tag($tag)) 5152 221 5373
Condition66%2/3
@_ or not $self->has_tag($tag)
l!l&&r!l&&!r
51520221
MC/DC50%1/2
@_ or not $self->has_tag($tag)
@_ not $self->has_tag($tag)
Truth table66%2/3
A or not(B)
A= @_B= not $self->has_tag($tag)
ABresult
1X1
011
000
1089 5152 ▶ $self->remove_tag($tag) if($self->has_tag($tag));
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_tag($tag) 6 5146 5152
1090 5152 $self->add_tag_value($tag, @_);
1091 }
1092 5373 return ($self->get_tag_values($tag))[0];
1093 }
1094  
1095  
1096 #######################################################################
1097 # aliases for methods that changed their names in an attempt to make #
1098 # bioperl names more consistent #
1099 #######################################################################
1100  
1101 0 ▶sub seqname {
Subroutine seqname: not called CC=1 SCAR=6.9
Pod undocumented
1102 0 my $self = shift;
1103 0 $self->warn("SeqFeatureI::seqname() is deprecated. Please use seq_id() instead.");
1104 0 return $self->seq_id(@_);
1105 }
1106  
1107 0 ▶sub display_id {
Subroutine display_id: not called CC=1 SCAR=6.9
Pod undocumented
1108 0 my $self = shift;
1109 0 $self->warn("SeqFeatureI::display_id() is deprecated. Please use display_name() instead.");
1110 0 return $self->display_name(@_);
1111 }
1112  
1113 # this is towards consistent naming
1114 0 ▶sub each_tag_value { return shift->get_tag_values(@_); }
Subroutine each_tag_value: not called CC=1 SCAR=6.9
Pod undocumented
1115 9 ▶sub all_tags { return shift->get_all_tags(@_); }
Subroutine all_tags: called CC=1 SCAR=0.0
Pod undocumented
1116  
1117 # we revamped the feature containing property to implementing
1118 # Bio::FeatureHolderI
1119 239 *sub_SeqFeature = \&get_SeqFeatures;
1120 239 *add_sub_SeqFeature = \&add_SeqFeature;
1121 239 *flush_sub_SeqFeatures = \&remove_SeqFeatures;
1122 # this one is because of inconsistent naming ...
1123 239 *flush_sub_SeqFeature = \&remove_SeqFeatures;
1124  
1125 31970 ▶sub cleanup_generic {
Subroutine cleanup_generic: called CC=4 SCAR=13.9
Pod undocumented
1126 31970 my $self = shift;
1127 31970 ▶ foreach my $f ( @{$self->{'_gsf_sub_array'} || []} ) {
Condition100%2/2
$self->{'_gsf_sub_array'} || []
l!l
33231638
MC/DC100%1/1
$self->{'_gsf_sub_array'} || []
$self->{'_gsf_sub_array'}
Truth table100%2/2
A
A= $self->{'_gsf_sub_array'}
Aresult
11
00
1128 583 $f = undef;
1129 }
1130 31970 $self->{'_gsf_seq'} = undef;
1131 31970 foreach my $t ( keys %{$self->{'_gsf_tag_hash'} } ) {
1132 46532 $self->{'_gsf_tag_hash'}->{$t} = undef;
1133 46532 delete($self->{'_gsf_tag_hash'}->{$t}); # bug 1720 fix
1134 }
1135 }
1136  
1137 239 1;
« Bio/AlignIO/maf.pm ↑ Summary Bio/Tools/EMBOSS/Palindrome.pm »