Bio/SeqFeature/Lite.pm

filter: Statementstmt 14.9% 55 / 368 Branchbran 10.0% 19 / 190 Conditioncond 12.8% 14 / 109 MC/DCmcdc 0.0% 0 / 58 Subroutinesub 7.0% 5 / 71 Podpod 59.0% 39 / 66 totaltotal 15.3% 132 / 862 CC 148 SCAR 46.1
CC
148
Cov
13%
add_segment
380.0
gff3_string
380.0
gff_string
210.0
CRAP 100.9
« Bio/DB/GFF/Util/Rearrange.pm ↑ Summary Bio/AlignIO/Handler/GenericAlignHandler.pm »
1 package Bio::SeqFeature::Lite;
2 2 $Bio::SeqFeature::Lite::VERSION = '1.7.7';
3 =head1 NAME
4  
5 Bio::SeqFeature::Lite - Lightweight Bio::SeqFeatureI class
6  
7 =head1 SYNOPSIS
8  
9 # create a simple feature with no internal structure
10 $f = Bio::SeqFeature::Lite->new(-start => 1000,
11 -stop => 2000,
12 -type => 'transcript',
13 -name => 'alpha-1 antitrypsin',
14 -desc => 'an enzyme inhibitor',
15 );
16  
17 # create a feature composed of multiple segments, all of type "similarity"
18 $f = Bio::SeqFeature::Lite->new(-segments => [[1000,1100],[1500,1550],[1800,2000]],
19 -name => 'ABC-3',
20 -type => 'gapped_alignment',
21 -subtype => 'similarity');
22  
23 # build up a gene exon by exon
24 $e1 = Bio::SeqFeature::Lite->new(-start=>1,-stop=>100,-type=>'exon');
25 $e2 = Bio::SeqFeature::Lite->new(-start=>150,-stop=>200,-type=>'exon');
26 $e3 = Bio::SeqFeature::Lite->new(-start=>300,-stop=>500,-type=>'exon');
27 $f = Bio::SeqFeature::Lite->new(-segments=>[$e1,$e2,$e3],-type=>'gene');
28  
29 =head1 DESCRIPTION
30  
31 This is a simple Bio::SeqFeatureI-compliant object that is compatible
32 with Bio::Graphics::Panel. With it you can create lightweight feature
33 objects for drawing.
34  
35 All methods are as described in L<Bio::SeqFeatureI> with the following additions:
36  
37 =head2 The new() Constructor
38  
39 $feature = Bio::SeqFeature::Lite->new(@args);
40  
41 This method creates a new feature object. You can create a simple
42 feature that contains no subfeatures, or a hierarchically nested object.
43  
44 Arguments are as follows:
45  
46 -seq_id the reference sequence
47 -start the start position of the feature
48 -end the stop position of the feature
49 -stop an alias for end
50 -name the feature name (returned by seqname())
51 -type the feature type (returned by primary_tag())
52 -primary_tag the same as -type
53 -source the source tag
54 -score the feature score (for GFF compatibility)
55 -desc a description of the feature
56 -segments a list of subfeatures (see below)
57 -subtype the type to use when creating subfeatures
58 -strand the strand of the feature (one of -1, 0 or +1)
59 -phase the phase of the feature (0..2)
60 -seq a dna or protein sequence string to attach to feature
61 -id an alias for -name
62 -seqname an alias for -name
63 -display_id an alias for -name
64 -display_name an alias for -name (do you get the idea the API has changed?)
65 -primary_id unique database ID
66 -url a URL to link to when rendered with Bio::Graphics
67 -attributes a hashref of tag value attributes, in which the key is the tag
68 and the value is an array reference of values
69 -factory a reference to a feature factory, used for compatibility with
70 more obscure parts of Bio::DB::GFF
71  
72 The subfeatures passed in -segments may be an array of
73 Bio::SeqFeature::Lite objects, or an array of [$start,$stop]
74 pairs. Each pair should be a two-element array reference. In the
75 latter case, the feature type passed in -subtype will be used when
76 creating the subfeatures.
77  
78 If no feature type is passed, then it defaults to "feature".
79  
80 =head2 Non-SeqFeatureI methods
81  
82 A number of new methods are provided for compatibility with
83 Ace::Sequence, which has a slightly different API from SeqFeatureI:
84  
85 =over 4
86  
87 =item url()
88  
89 Get/set the URL that the graphical rendering of this feature will link to.
90  
91 =item add_segment(@segments)
92  
93 Add one or more segments (a subfeature). Segments can either be
94 Feature objects, or [start,stop] arrays, as in the -segments argument
95 to new(). The feature endpoints are automatically adjusted.
96  
97 =item segments()
98  
99 An alias for sub_SeqFeature().
100  
101 =item get_SeqFeatures()
102  
103 Alias for sub_SeqFeature()
104  
105 =item get_all_SeqFeatures()
106  
107 Alias for sub_SeqFeature()
108  
109 =item merged_segments()
110  
111 Another alias for sub_SeqFeature().
112  
113 =item stop()
114  
115 An alias for end().
116  
117 =item name()
118  
119 An alias for seqname().
120  
121 =item exons()
122  
123 An alias for sub_SeqFeature() (you don't want to know why!)
124  
125 =back
126  
127 =cut
128  
129 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
130  
131 2 ▶use base qw(Bio::Root::Root Bio::SeqFeatureI Bio::LocationI Bio::SeqI);
Subroutine BEGIN: called CC=1 SCAR=0.0
132  
133 2 *stop = \&end;
134 2 *info = \&name;
135 2 *seqname = \&name;
136 2 *exons = *sub_SeqFeature = *merged_segments = \&segments;
137 2 *get_all_SeqFeatures = *get_SeqFeatures = \&segments;
138 2 *method = \&primary_tag;
139 2 *source = \&source_tag;
140 2 *get_tag_values = \&each_tag_value;
141 2 *add_SeqFeature = \&add_segment;
142 2 *get_all_tags = \&all_tags;
143 2 *abs_ref = \&ref;
144  
145 # implement Bio::SeqI and FeatureHolderI interface
146  
147 0 ▶sub primary_seq { return $_[0] }
Subroutine primary_seq: not called CC=1 SCAR=6.9
Pod documented
148 sub annotation {
149 0 ▶ my ($obj,$value) = @_;
Subroutine annotation: not called CC=4 SCAR=30.0
Pod documented
150 0 ▶ if( defined $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
elsif (not defined $obj->{'_annotation'}) { } 0 0 0
151 0 ▶ $obj->throw("object of class ".ref($value)." does not implement ".
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Bio::AnnotationCollectionI") 0 0 0
152 "Bio::AnnotationCollectionI. Too bad.")
153 unless $value->isa("Bio::AnnotationCollectionI");
154 0 $obj->{'_annotation'} = $value;
155 } elsif( ! defined $obj->{'_annotation'}) {
156 0 $obj->{'_annotation'} = Bio::Annotation::Collection->new();
157 }
158 0 return $obj->{'_annotation'};
159 }
160 sub species {
161 0 ▶ my ($self, $species) = @_;
Subroutine species: not called CC=2 SCAR=17.9
Pod documented
162 0 ▶ if ($species) {
Branch: 1 branch
BranchTrueFalseTotal
if ($species) { } 0 0 0
163 0 $self->{'species'} = $species;
164 } else {
165 0 return $self->{'species'};
166 }
167 }
168 0 ▶sub is_remote { return }
Subroutine is_remote: not called CC=1 SCAR=6.9
Pod documented
169 0 ▶sub feature_count { return scalar @{shift->{segments} || []} }
Subroutine feature_count: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->{"segments"} or [] 0 0 0
170  
171 0 ▶sub target { return; }
Subroutine target: not called CC=1 SCAR=6.9
Pod undocumented
172 0 ▶sub hit { shift->target }
Subroutine hit: not called CC=1 SCAR=6.9
Pod undocumented
173  
174 sub type {
175 0 ▶ my $self = shift;
Subroutine type: not called CC=2 SCAR=17.9
Pod undocumented
176 0 my $method = $self->primary_tag;
177 0 my $source = $self->source_tag;
178 0 ▶ return $source ne '' ? "$method:$source" : $method;
Branch: 1 branch
BranchTrueFalseTotal
$source ne '' ? : 0 0 0
179 }
180  
181 # usage:
182 # Bio::SeqFeature::Lite->new(
183 # -start => 1,
184 # -end => 100,
185 # -name => 'fred feature',
186 # -strand => +1);
187 #
188 # Alternatively, use -segments => [ [start,stop],[start,stop]...]
189 # to create a multisegmented feature.
190 sub new {
191 3 ▶ my $class= shift;
Subroutine new: called CC=29 SCAR=45.7
Pod documented
192 3 ▶ $class = ref($class) if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if CORE::ref $class 0 3 3
193 3 my %arg = @_;
194  
195 3 my $self = bless {},$class;
196  
197 3 ▶ $arg{-strand} ||= 0;
Condition50%1/2
$arg{"-strand"} ||= 0
l!l
30
MC/DC0%0/1
$arg{"-strand"} ||= 0
$arg{"-strand"}
Truth table50%1/2
A
A= $arg{"-strand"}
Aresult
11
00
198 3 ▶ if ($arg{-strand} =~ /^[\+\-\.]$/){
Branch: 1 branch
BranchTrueFalseTotal
if ($arg{'-strand'} =~ /^[\+\-\.]$/) { } 3 0 3
199 3 ▶ ($arg{-strand} eq "+") && ($self->{strand} = '1');
Branch: 1 branch
BranchTrueFalseTotal
$arg{"-strand"} eq "+" and $self->{"strand"} = 1 1 2 3
200 3 ▶ ($arg{-strand} eq "-") && ($self->{strand} = '-1');
Branch: 1 branch
BranchTrueFalseTotal
$arg{"-strand"} eq "-" and $self->{"strand"} = -1 1 2 3
201 3 ▶ ($arg{-strand} eq ".") && ($self->{strand} = '0');
Branch: 1 branch
BranchTrueFalseTotal
$arg{"-strand"} eq "." and $self->{"strand"} = 0 1 2 3
202 } else {
203 0 ▶ $self->{strand} = $arg{-strand} ? ($arg{-strand} >= 0 ? +1 : -1) : 0;
Branch: 2 branches
BranchTrueFalseTotal
$arg{'-strand'} ? : 0 0 0
$arg{'-strand'} >= 0 ? : 0 0 0
204 }
205 $self->{name} = $arg{-name} || $arg{-seqname} || $arg{-display_id}
206 3 ▶ || $arg{-display_name} || $arg{-id};
Condition33%4/12
$arg{'-name'} || $arg{'-seqname'} || $arg{'-display_id'} || $arg{'-display_name'} || $arg{'-id'}
l!l&&r!l&&!r
003
$arg{"-name"} or $arg{"-seqname"} or $arg{"-display_id"} or $arg{"-display_name"}
l!l&&r!l&&!r
003
$arg{"-name"} or $arg{"-seqname"} or $arg{"-display_id"}
l!l&&r!l&&!r
003
$arg{"-name"} or $arg{"-seqname"}
l!l&&r!l&&!r
003
MC/DC0%0/5
$arg{'-name'} || $arg{'-seqname'} || $arg{'-display_id'} || $arg{'-display_name'} || $arg{'-id'}
$arg{"-name"} $arg{"-seqname"} $arg{"-display_id"} $arg{"-display_name"} $arg{'-id'}
Truth table16%1/6
A or B or C or D || E
A= $arg{"-name"}B= $arg{"-seqname"}C= $arg{"-display_id"}D= $arg{"-display_name"}E= $arg{'-id'}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
207 3 ▶ $self->{type} = $arg{-type} || $arg{-primary_tag} || 'feature';
Condition40%2/5
$arg{'-type'} || $arg{'-primary_tag'} || 'feature'
l!l
03
$arg{"-type"} or $arg{"-primary_tag"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$arg{'-type'} || $arg{'-primary_tag'} || 'feature'
$arg{"-type"} $arg{"-primary_tag"}
Truth table33%1/3
A or B
A= $arg{"-type"}B= $arg{"-primary_tag"}
ABresult
1X1
011
000
208 3 ▶ $self->{subtype} = $arg{-subtype} if exists $arg{-subtype};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"-subtype"} 0 3 3
209 3 ▶ $self->{source} = $arg{-source} || $arg{-source_tag} || '';
Condition40%2/5
$arg{'-source'} || $arg{'-source_tag'} || ''
l!l
03
$arg{"-source"} or $arg{"-source_tag"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$arg{'-source'} || $arg{'-source_tag'} || ''
$arg{"-source"} $arg{"-source_tag"}
Truth table33%1/3
A or B
A= $arg{"-source"}B= $arg{"-source_tag"}
ABresult
1X1
011
000
210 3 ▶ $self->{score} = $arg{-score} if exists $arg{-score};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"-score"} 0 3 3
211 3 $self->{start} = $arg{-start};
212 3 ▶ $self->{stop} = exists $arg{-end} ? $arg{-end} : $arg{-stop};
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'-end'} ? : 1 2 3
213 3 ▶ $self->{ref} = $arg{-seq_id} || $arg{-ref};
Condition33%1/3
$arg{'-seq_id'} || $arg{'-ref'}
l!l&&r!l&&!r
003
MC/DC0%0/2
$arg{'-seq_id'} || $arg{'-ref'}
$arg{'-seq_id'} $arg{'-ref'}
Truth table33%1/3
A || B
A= $arg{'-seq_id'}B= $arg{'-ref'}
ABresult
1X1
011
000
214 3 ▶ $self->{attributes} = $arg{-attributes} || $arg{-tag};
Condition33%1/3
$arg{'-attributes'} || $arg{'-tag'}
l!l&&r!l&&!r
003
MC/DC0%0/2
$arg{'-attributes'} || $arg{'-tag'}
$arg{'-attributes'} $arg{'-tag'}
Truth table33%1/3
A || B
A= $arg{'-attributes'}B= $arg{'-tag'}
ABresult
1X1
011
000
215 3 for my $option (qw(class url seq phase desc primary_id)) {
216 18 ▶ $self->{$option} = $arg{"-$option"} if exists $arg{"-$option"};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"-$option"} 0 18 18
217 }
218  
219 # is_circular is needed for Bio::PrimarySeqI compliance
220 3 ▶ $self->{is_circular} = $arg{-is_circular} || 0;
Condition50%1/2
$arg{'-is_circular'} || 0
l!l
03
MC/DC0%0/1
$arg{'-is_circular'} || 0
$arg{'-is_circular'}
Truth table50%1/2
A
A= $arg{'-is_circular'}
Aresult
11
00
221  
222 # fix start, stop
223 3 ▶ if (defined $self->{stop} && defined $self->{start}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"stop"} and defined $self->{"start"} and $self->{"stop"} < $self->{"start"}) 0 3 3
Condition33%2/6
defined $self->{"stop"} and defined $self->{"start"} and $self->{"stop"} < $self->{"start"}
!ll&&!rl&&r
030
defined $self->{"stop"} and defined $self->{"start"}
!ll&&!rl&&r
003
MC/DC0%0/3
defined $self->{"stop"} and defined $self->{"start"} and $self->{"stop"} < $self->{"start"}
defined $self->{"stop"} defined $self->{"start"} $self->{"stop"} < $self->{"start"}
Truth table25%1/4
A and B and C
A= defined $self->{"stop"}B= defined $self->{"start"}C= $self->{"stop"} < $self->{"start"}
ABCresult
0XX0
10X0
1100
1111
224 && $self->{stop} < $self->{start}) {
225 0 @{$self}{'start','stop'} = @{$self}{'stop','start'};
226 0 $self->{strand} *= -1;
227 }
228  
229 3 my @segments;
230 3 ▶ if (my $s = $arg{-segments}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $arg{"-segments"}) 0 3 3
231 # NB: when $self ISA Bio::DB::SeqFeature the following invokes
232 # Bio::DB::SeqFeature::add_segment and not
233 # Bio::DB::SeqFeature::add_segment (as might be expected?)
234 0 $self->add_segment(@$s);
235 }
236  
237 3 $self;
238 }
239  
240 sub add_segment {
241 0 ▶ my $self = shift;
Subroutine add_segment: not called CC=19 SCAR=59.4
Pod documented
242 0 ▶ my $type = $self->{subtype} || $self->{type};
Condition0%0/3
$self->{'subtype'} || $self->{'type'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'subtype'} || $self->{'type'}
$self->{'subtype'} $self->{'type'}
Truth table0%0/3
A || B
A= $self->{'subtype'}B= $self->{'type'}
ABresult
1X1
011
000
243 0 ▶ $self->{segments} ||= [];
Condition0%0/2
$self->{"segments"} ||= []
l!l
00
MC/DC0%0/1
$self->{"segments"} ||= []
$self->{"segments"}
Truth table0%0/2
A
A= $self->{"segments"}
Aresult
11
00
244 0 my $ref = $self->seq_id;
245 0 my $name = $self->name;
246 0 my $class = $self->class;
247 0 my $source_tag = $self->source_tag;
248  
249 0 ▶ my $min_start = $self->start || 999_999_999_999;
Condition0%0/2
$self->start || 999999999999
l!l
00
MC/DC0%0/1
$self->start || 999999999999
$self->start
Truth table0%0/2
A
A= $self->start
Aresult
11
00
250 0 ▶ my $max_stop = $self->end || -999_999_999_999;
Condition0%0/2
$self->end || -999999999999
l!l
00
MC/DC0%0/1
$self->end || -999999999999
$self->end
Truth table0%0/2
A
A= $self->end
Aresult
11
00
251  
252 0 my @segments = @{$self->{segments}};
253  
254 0 for my $seg (@_) {
255 0 ▶ if (ref($seg) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (CORE::ref $seg eq 'ARRAY') { } 0 0 0
elsif (CORE::ref $seg) { } 0 0 0
256 0 my ($start,$stop) = @{$seg};
257 0 ▶ next unless defined $start && defined $stop; # fixes an obscure bug somewhere above us
Branch: 1 branch
BranchTrueFalseTotal
unless defined $start and defined $stop 0 0 0
Condition0%0/3
defined $start and defined $stop
!ll&&!rl&&r
000
MC/DC0%0/2
defined $start and defined $stop
defined $start defined $stop
Truth table0%0/3
A and B
A= defined $startB= defined $stop
ABresult
0X0
100
111
258 0 my $strand = $self->{strand};
259  
260 0 ▶ if ($start > $stop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start > $stop) 0 0 0
261 0 ($start,$stop) = ($stop,$start);
262 0 $strand = -1;
263 }
264  
265 push @segments,$self->new(-start => $start,
266 -stop => $stop,
267 -strand => $strand,
268 -ref => $ref,
269 -type => $type,
270 -name => $name,
271 -class => $class,
272 -phase => $self->{phase},
273 -score => $self->{score},
274 -source_tag => $source_tag,
275 -attributes => $self->{attributes},
276 0 );
277 0 ▶ $min_start = $start if $start < $min_start;
Branch: 1 branch
BranchTrueFalseTotal
if $start < $min_start 0 0 0
278 0 ▶ $max_stop = $stop if $stop > $max_stop;
Branch: 1 branch
BranchTrueFalseTotal
if $stop > $max_stop 0 0 0
279  
280 } elsif (ref $seg) {
281 0 push @segments,$seg;
282  
283 0 ▶ $min_start = $seg->start if ($seg->start && $seg->start < $min_start);
Branch: 1 branch
BranchTrueFalseTotal
if $seg->start and $seg->start < $min_start 0 0 0
Condition0%0/3
$seg->start and $seg->start < $min_start
!ll&&!rl&&r
000
MC/DC0%0/2
$seg->start and $seg->start < $min_start
$seg->start $seg->start < $min_start
Truth table0%0/3
A and B
A= $seg->startB= $seg->start < $min_start
ABresult
0X0
100
111
284 0 ▶ $max_stop = $seg->end if ($seg->end && $seg->end > $max_stop);
Branch: 1 branch
BranchTrueFalseTotal
if $seg->end and $seg->end > $max_stop 0 0 0
Condition0%0/3
$seg->end and $seg->end > $max_stop
!ll&&!rl&&r
000
MC/DC0%0/2
$seg->end and $seg->end > $max_stop
$seg->end $seg->end > $max_stop
Truth table0%0/3
A and B
A= $seg->endB= $seg->end > $max_stop
ABresult
0X0
100
111
285 }
286 }
287 0 ▶ if (@segments) {
Branch: 1 branch
BranchTrueFalseTotal
if (@segments) 0 0 0
288 0 local $^W = 0; # some warning of an uninitialized variable...
289 0 $self->{segments} = \@segments;
290 0 ▶ $self->{ref} ||= $self->{segments}[0]->seq_id;
Condition0%0/3
$self->{"ref"} ||= $self->{"segments"}[0]->seq_id
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"ref"} ||= $self->{"segments"}[0]->seq_id
$self->{"ref"} $self->{"segments"}[0]->seq_id
Truth table0%0/3
A ||= B
A= $self->{"ref"}B= $self->{"segments"}[0]->seq_id
ABresult
1X1
011
000
291 0 $self->{start} = $min_start;
292 0 $self->{stop} = $max_stop;
293 }
294 }
295  
296 sub segments {
297 0 ▶ my $self = shift;
Subroutine segments: not called CC=3 SCAR=24.8
Pod documented
298 0 ▶ my $s = $self->{segments} or return wantarray ? () : 0;
Branch: 2 branches
BranchTrueFalseTotal
my $s = $self->{"segments"} or return wantarray ? () : 0 0 0 0
wantarray ? : 0 0 0
299 0 @$s;
300 }
301 sub score {
302 0 ▶ my $self = shift;
Subroutine score: not called CC=2 SCAR=17.9
Pod undocumented
303 0 my $d = $self->{score};
304 0 ▶ $self->{score} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
305 0 $d;
306 }
307 sub primary_tag {
308 0 ▶ my $self = shift;
Subroutine primary_tag: not called CC=2 SCAR=17.9
Pod documented
309 0 my $d = $self->{type};
310 0 ▶ $self->{type} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
311 0 $d;
312 }
313 sub name {
314 0 ▶ my $self = shift;
Subroutine name: not called CC=2 SCAR=17.9
Pod documented
315 0 my $d = $self->{name};
316 0 ▶ $self->{name} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
317 0 $d;
318 }
319 0 ▶sub seq_id { shift->ref(@_) }
Subroutine seq_id: not called CC=1 SCAR=6.9
Pod documented
320 sub ref {
321 0 ▶ my $self = shift;
Subroutine ref: not called CC=2 SCAR=17.9
Pod undocumented
322 0 my $d = $self->{ref};
323 0 ▶ $self->{ref} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
324 0 $d;
325 }
326 sub start {
327 0 ▶ my $self = shift;
Subroutine start: not called CC=5 SCAR=34.0
Pod documented
328 0 my $d = $self->{start};
329 0 ▶ $self->{start} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
330 0 ▶ if (my $rs = $self->{refseq}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rs = $self->{'refseq'}) { } 0 0 0
331 0 ▶ my $strand = $rs->strand || 1;
Condition0%0/2
$rs->strand || 1
l!l
00
MC/DC0%0/1
$rs->strand || 1
$rs->strand
Truth table0%0/2
A
A= $rs->strand
Aresult
11
00
332 0 ▶ return $strand >= 0 ? ($d - $rs->start + 1) : ($rs->end - $d + 1);
Branch: 1 branch
BranchTrueFalseTotal
$strand >= 0 ? : 0 0 0
333 } else {
334 0 return $d;
335 }
336 }
337 sub end {
338 2 ▶ my $self = shift;
Subroutine end: called CC=5 SCAR=21.7
Pod documented
339 2 my $d = $self->{stop};
340 2 ▶ $self->{stop} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
341 2 ▶ if (my $rs = $self->{refseq}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rs = $self->{"refseq"}) 0 2 2
342 0 ▶ my $strand = $rs->strand || 1;
Condition0%0/2
$rs->strand || 1
l!l
00
MC/DC0%0/1
$rs->strand || 1
$rs->strand
Truth table0%0/2
A
A= $rs->strand
Aresult
11
00
343 0 ▶ return $strand >= 0 ? ($d - $rs->start + 1) : ($rs->end - $d + 1);
Branch: 1 branch
BranchTrueFalseTotal
$strand >= 0 ? : 0 0 0
344 }
345 2 $d;
346 }
347 sub strand {
348 3 ▶ my $self = shift;
Subroutine strand: called CC=6 SCAR=27.1
Pod documented
349 3 my $d = $self->{strand};
350 3 ▶ $self->{strand} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 3 3
351 3 ▶ if (my $rs = $self->{refseq}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rs = $self->{"refseq"}) 0 3 3
352 0 my $rstrand = $rs->strand;
353 0 ▶ return 0 unless $d;
Branch: 1 branch
BranchTrueFalseTotal
unless $d 0 0 0
354 0 ▶ return 1 if $rstrand == $d;
Branch: 1 branch
BranchTrueFalseTotal
if $rstrand == $d 0 0 0
355 0 ▶ return -1 if $rstrand != $d;
Branch: 1 branch
BranchTrueFalseTotal
if $rstrand != $d 0 0 0
356 }
357 3 $d;
358 }
359  
360 # this does nothing, but it is here for compatibility reasons
361 sub absolute {
362 0 ▶ my $self = shift;
Subroutine absolute: not called CC=2 SCAR=17.9
Pod undocumented
363 0 my $d = $self->{absolute};
364 0 ▶ $self->{absolute} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
365 0 $d;
366 }
367  
368 sub abs_start {
369 0 ▶ my $self = shift;
Subroutine abs_start: not called CC=1 SCAR=6.9
Pod undocumented
370 0 local $self->{refseq} = undef;
371 0 $self->start(@_);
372 }
373 sub abs_end {
374 0 ▶ my $self = shift;
Subroutine abs_end: not called CC=1 SCAR=6.9
Pod undocumented
375 0 local $self->{refseq} = undef;
376 0 $self->end(@_);
377 }
378 sub abs_strand {
379 0 ▶ my $self = shift;
Subroutine abs_strand: not called CC=1 SCAR=6.9
Pod undocumented
380 0 local $self->{refseq} = undef;
381 0 $self->strand(@_);
382 }
383  
384 sub length {
385 0 ▶ my $self = shift;
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
386 0 return $self->end - $self->start + 1;
387 }
388  
389 #is_circular is needed for Bio::PrimarySeqI
390 sub is_circular {
391 0 ▶ my $self = shift;
Subroutine is_circular: not called CC=2 SCAR=17.9
Pod documented
392 0 my $d = $self->{is_circular};
393 0 ▶ $self->{is_circular} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
394 0 $d;
395 }
396  
397  
398 sub seq {
399 0 ▶ my $self = shift;
Subroutine seq: not called CC=2 SCAR=17.9
Pod documented
400 0 ▶ my $seq = exists $self->{seq} ? $self->{seq} : '';
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'seq'} ? : 0 0 0
401 0 return $seq;
402 }
403  
404 sub dna {
405 0 ▶ my $seq = shift->seq;
Subroutine dna: not called CC=2 SCAR=17.9
Pod undocumented
406 0 ▶ $seq = $seq->seq if CORE::ref($seq);
Branch: 1 branch
BranchTrueFalseTotal
if CORE::ref $seq 0 0 0
407 0 return $seq;
408 }
409  
410 =head2 display_name
411  
412 Title : display_name
413 Usage : $id = $obj->display_name or $obj->display_name($newid);
414 Function: Gets or sets the display id, also known as the common name of
415 the Seq object.
416  
417 The semantics of this is that it is the most likely string
418 to be used as an identifier of the sequence, and likely to
419 have "human" readability. The id is equivalent to the LOCUS
420 field of the GenBank/EMBL databanks and the ID field of the
421 Swissprot/sptrembl database. In fasta format, the >(\S+) is
422 presumed to be the id, though some people overload the id
423 to embed other information. Bioperl does not use any
424 embedded information in the ID field, and people are
425 encouraged to use other mechanisms (accession field for
426 example, or extending the sequence object) to solve this.
427  
428 Notice that $seq->id() maps to this function, mainly for
429 legacy/convenience issues.
430 Returns : A string
431 Args : None or a new id
432  
433  
434 =cut
435  
436 0 ▶sub display_name { shift->name(@_) }
Subroutine display_name: not called CC=1 SCAR=6.9
Pod documented
437  
438 2 *display_id = \&display_name;
439  
440 =head2 accession_number
441  
442 Title : accession_number
443 Usage : $unique_biological_key = $obj->accession_number;
444 Function: Returns the unique biological id for a sequence, commonly
445 called the accession_number. For sequences from established
446 databases, the implementors should try to use the correct
447 accession number. Notice that primary_id() provides the
448 unique id for the implementation, allowing multiple objects
449 to have the same accession number in a particular implementation.
450  
451 For sequences with no accession number, this method should return
452 "unknown".
453 Returns : A string
454 Args : None
455  
456  
457 =cut
458  
459 sub accession_number {
460 0 ▶ return 'unknown';
Subroutine accession_number: not called CC=1 SCAR=6.9
Pod documented
461 }
462  
463 =head2 alphabet
464  
465 Title : alphabet
466 Usage : if( $obj->alphabet eq 'dna' ) { /Do Something/ }
467 Function: Returns the type of sequence being one of
468 'dna', 'rna' or 'protein'. This is case sensitive.
469  
470 This is not called <type> because this would cause
471 upgrade problems from the 0.5 and earlier Seq objects.
472  
473 Returns : a string either 'dna','rna','protein'. NB - the object must
474 make a call of the type - if there is no type specified it
475 has to guess.
476 Args : none
477 Status : Virtual
478  
479  
480 =cut
481  
482 sub alphabet{
483 0 ▶ return 'dna'; # no way this will be anything other than dna!
Subroutine alphabet: not called CC=1 SCAR=6.9
Pod documented
484 }
485  
486  
487  
488 =head2 desc
489  
490 Title : desc
491 Usage : $seqobj->desc($string) or $seqobj->desc()
492 Function: Sets or gets the description of the sequence
493 Example :
494 Returns : The description
495 Args : The description or none
496  
497  
498 =cut
499  
500 sub desc {
501 0 ▶ my $self = shift;
Subroutine desc: not called CC=2 SCAR=17.9
Pod documented
502 0 my ($d) = $self->notes;
503 0 ▶ $self->{desc} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
504 0 $d;
505 }
506  
507 sub attributes {
508 0 ▶ my $self = shift;
Subroutine attributes: not called CC=3 SCAR=24.8
Pod undocumented
509 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
510 0 return $self->get_tag_values(@_);
511 } else {
512 0 ▶ return $self->{attributes} ? %{$self->{attributes}} : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'attributes'} ? : 0 0 0
513 }
514 }
515  
516 sub primary_id {
517 0 ▶ my $self = shift;
Subroutine primary_id: not called CC=2 SCAR=17.9
Pod documented
518 0 my $d = $self->{primary_id};
519 0 ▶ $self->{primary_id} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
520 0 return $d;
521 # return $d if defined $d;
522 # return (overload::StrVal($self) =~ /0x([a-f0-9]+)/)[0];
523 }
524  
525 sub notes {
526 0 ▶ my $self = shift;
Subroutine notes: not called CC=2 SCAR=17.9
Pod undocumented
527 0 my $notes = $self->{desc};
528 0 ▶ return $notes if defined $notes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $notes 0 0 0
529 0 return $self->attributes('Note');
530 }
531  
532 sub aliases {
533 0 ▶ my $self = shift;
Subroutine aliases: not called CC=1 SCAR=6.9
Pod undocumented
534 0 return $self->attributes('Alias');
535 }
536  
537 sub low {
538 0 ▶ my $self = shift;
Subroutine low: not called CC=2 SCAR=17.9
Pod undocumented
539 0 ▶ return $self->start < $self->end ? $self->start : $self->end;
Branch: 1 branch
BranchTrueFalseTotal
$self->start < $self->end ? : 0 0 0
540 }
541  
542 sub high {
543 0 ▶ my $self = shift;
Subroutine high: not called CC=2 SCAR=17.9
Pod undocumented
544 0 ▶ return $self->start > $self->end ? $self->start : $self->end;
Branch: 1 branch
BranchTrueFalseTotal
$self->start > $self->end ? : 0 0 0
545 }
546  
547 =head2 location
548  
549 Title : location
550 Usage : my $location = $seqfeature->location()
551 Function: returns a location object suitable for identifying location
552 of feature on sequence or parent feature
553 Returns : Bio::LocationI object
554 Args : none
555  
556 =cut
557  
558 sub location {
559 0 ▶ my $self = shift;
Subroutine location: not called CC=4 SCAR=30.0
Pod documented
560 0 ▶ require Bio::Location::Split unless Bio::Location::Split->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::Location::Split"->can("new") 0 0 0
561 0 my $location;
562 0 ▶ if (my @segments = $self->segments) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@segments) = $self->segments) { } 0 0 0
563 0 $location = Bio::Location::Split->new();
564 0 foreach (@segments) {
565 0 $location->add_sub_Location($_);
566 }
567 } else {
568 0 $location = $self;
569 }
570 0 $location;
571 }
572  
573 sub each_Location {
574 0 ▶ my $self = shift;
Subroutine each_Location: not called CC=3 SCAR=24.8
Pod documented
575 0 ▶ require Bio::Location::Simple unless Bio::Location::Simple->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::Location::Simple"->can("new") 0 0 0
576 0 ▶ if (my @segments = $self->segments) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@segments) = $self->segments) { } 0 0 0
577 return map {
578 0 Bio::Location::Simple->new(-start => $_->start,
579 -end => $_->end,
580 -strand => $_->strand);
581 } @segments;
582 } else {
583 0 return Bio::Location::Simple->new(-start => $self->start,
584 -end => $self->end,
585 -strand => $self->strand);
586 }
587 }
588  
589 =head2 location_string
590  
591 Title : location_string
592 Usage : my $string = $seqfeature->location_string()
593 Function: Returns a location string in a format recognized by gbrowse
594 Returns : a string
595 Args : none
596  
597 This is a convenience function used by the generic genome browser. It
598 returns the location of the feature and its subfeatures in the compact
599 form "start1..end1,start2..end2,...". Use
600 $seqfeature-E<gt>location()-E<gt>toFTString() to obtain a standard
601 GenBank/EMBL location representation.
602  
603 =cut
604  
605 sub location_string {
606 0 ▶ my $self = shift;
Subroutine location_string: not called CC=2 SCAR=17.9
Pod documented
607 0 ▶ my @segments = $self->segments or return $self->to_FTstring;
Branch: 1 branch
BranchTrueFalseTotal
my(@segments) = $self->segments or return $self->to_FTstring 0 0 0
608 0 join ',',map {$_->to_FTstring} @segments;
609 }
610  
611 sub coordinate_policy {
612 0 ▶ require Bio::Location::WidestCoordPolicy unless Bio::Location::WidestCoordPolicy->can('new');
Subroutine coordinate_policy: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::Location::WidestCoordPolicy"->can("new") 0 0 0
613 0 return Bio::Location::WidestCoordPolicy->new();
614 }
615  
616 0 ▶sub min_start { shift->low }
Subroutine min_start: not called CC=1 SCAR=6.9
Pod documented
617 0 ▶sub max_start { shift->low }
Subroutine max_start: not called CC=1 SCAR=6.9
Pod documented
618 0 ▶sub min_end { shift->high }
Subroutine min_end: not called CC=1 SCAR=6.9
Pod documented
619 0 ▶sub max_end { shift->high}
Subroutine max_end: not called CC=1 SCAR=6.9
Pod documented
620 0 ▶sub start_pos_type { 'EXACT' }
Subroutine start_pos_type: not called CC=1 SCAR=6.9
Pod documented
621 0 ▶sub end_pos_type { 'EXACT' }
Subroutine end_pos_type: not called CC=1 SCAR=6.9
Pod documented
622 sub to_FTstring {
623 0 ▶ my $self = shift;
Subroutine to_FTstring: not called CC=4 SCAR=30.0
Pod documented
624 0 my $low = $self->min_start;
625 0 my $high = $self->max_end;
626 0 my $strand = $self->strand;
627 0 ▶ my $str = defined $strand && $strand<0 ? "complement($low..$high)" : "$low..$high";
Branch: 1 branch
BranchTrueFalseTotal
defined $strand && $strand < 0 ? : 0 0 0
Condition0%0/3
defined $strand and $strand < 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $strand and $strand < 0
defined $strand $strand < 0
Truth table0%0/3
A and B
A= defined $strandB= $strand < 0
ABresult
0X0
100
111
628 0 ▶ if (my $id = $self->seq_id()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $id = $self->seq_id) 0 0 0
629 0 $str = $id . ":" . $str;
630 }
631 0 $str;
632 }
633 sub phase {
634 0 ▶ my $self = shift;
Subroutine phase: not called CC=2 SCAR=17.9
Pod documented
635 0 my $d = $self->{phase};
636 0 ▶ $self->{phase} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
637 0 $d;
638 }
639  
640 sub class {
641 0 ▶ my $self = shift;
Subroutine class: not called CC=3 SCAR=24.8
Pod undocumented
642 0 my $d = $self->{class};
643 0 ▶ $self->{class} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
644 0 ▶ return defined($d) ? $d : 'Sequence'; # acedb is still haunting me - LS
Branch: 1 branch
BranchTrueFalseTotal
defined $d ? : 0 0 0
645 }
646  
647 # set GFF dumping version
648 sub version {
649 0 ▶ my $self = shift;
Subroutine version: not called CC=3 SCAR=24.8
Pod undocumented
650 0 ▶ my $d = $self->{gff3_version} || 2;
Condition0%0/2
$self->{'gff3_version'} || 2
l!l
00
MC/DC0%0/1
$self->{'gff3_version'} || 2
$self->{'gff3_version'}
Truth table0%0/2
A
A= $self->{'gff3_version'}
Aresult
11
00
651 0 ▶ $self->{gff3_version} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
652 0 $d;
653 }
654  
655 sub gff_string {
656 0 ▶ my $self = shift;
Subroutine gff_string: not called CC=14 SCAR=53.5
Pod documented
657
658 0 ▶ if ($self->version == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version == 3) 0 0 0
659 0 return $self->gff3_string(@_);
660 }
661
662 0 my $recurse = shift;
663 0 my $name = $self->name;
664 0 my $class = $self->class;
665 0 ▶ my $group = "$class $name" if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 0 0
666 0 my $strand = ('-','.','+')[$self->strand+1];
667 0 my $string;
668 0 ▶ $string .= join("\t",
Branch: 2 branches
BranchTrueFalseTotal
defined $self->score ? : 0 0 0
defined $self->phase ? : 0 0 0
Condition0%0/14
$self->ref || '.'
l!l
00
$self->source || '.'
l!l
00
$self->method || '.'
l!l
00
$self->start || '.'
l!l
00
$self->stop || '.'
l!l
00
$strand || '.'
l!l
00
$group || ''
l!l
00
MC/DC0%0/1
$self->ref || '.'
$self->ref
MC/DC0%0/1
$self->source || '.'
$self->source
MC/DC0%0/1
$self->method || '.'
$self->method
MC/DC0%0/1
$self->start || '.'
$self->start
MC/DC0%0/1
$self->stop || '.'
$self->stop
MC/DC0%0/1
$strand || '.'
$strand
MC/DC0%0/1
$group || ''
$group
Truth table0%0/2
A
A= $self->ref
Aresult
11
00
Truth table0%0/2
A
A= $self->source
Aresult
11
00
Truth table0%0/2
A
A= $self->method
Aresult
11
00
Truth table0%0/2
A
A= $self->start
Aresult
11
00
Truth table0%0/2
A
A= $self->stop
Aresult
11
00
Truth table0%0/2
A
A= $strand
Aresult
11
00
Truth table0%0/2
A
A= $group
Aresult
11
00
669 $self->ref||'.',$self->source||'.',$self->method||'.',
670 $self->start||'.',$self->stop||'.',
671 defined($self->score) ? $self->score : '.',
672 $strand||'.',
673 defined($self->phase) ? $self->phase : '.',
674 $group||''
675 );
676 0 $string .= "\n";
677 0 ▶ if ($recurse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recurse) 0 0 0
678 0 foreach ($self->sub_SeqFeature) {
679 0 $string .= $_->gff_string($recurse);
680 }
681 }
682 0 $string;
683 }
684  
685 # Suggested strategy for dealing with the multiple parentage issue.
686 # First recurse through object tree and record parent tree.
687 # Then recurse again, skipping objects we've seen before.
688 sub gff3_string {
689 0 ▶ my ($self,$recurse,$parent_tree,$seenit,$force_id) = @_;
Subroutine gff3_string: not called CC=19 SCAR=59.4
Pod undocumented
690 0 ▶ $parent_tree ||= {};
Condition0%0/2
$parent_tree ||= {}
l!l
00
MC/DC0%0/1
$parent_tree ||= {}
$parent_tree
Truth table0%0/2
A
A= $parent_tree
Aresult
11
00
691 0 ▶ $seenit ||= {};
Condition0%0/2
$seenit ||= {}
l!l
00
MC/DC0%0/1
$seenit ||= {}
$seenit
Truth table0%0/2
A
A= $seenit
Aresult
11
00
692 0 my @rsf = ();
693 0 my @parent_ids;
694  
695 0 ▶ if ($recurse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recurse) 0 0 0
696 0 ▶ $self->_traverse($parent_tree) unless %$parent_tree; # this will record parents of all children
Branch: 1 branch
BranchTrueFalseTotal
unless %$parent_tree 0 0 0
697 0 ▶ my $primary_id = defined $force_id ? $force_id : $self->_real_or_dummy_id;
Branch: 1 branch
BranchTrueFalseTotal
defined $force_id ? : 0 0 0
698  
699 0 ▶ return if $seenit->{$primary_id}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seenit->{$primary_id}++ 0 0 0
700  
701 0 @rsf = $self->get_SeqFeatures;
702 0 ▶ if (@rsf) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rsf) 0 0 0
703 # Detect case in which we have a split location feature. In this case we
704 # skip to the grandchildren and trick them into thinking that our parent is theirs.
705 0 my %types = map {$_->primary_tag=>1} @rsf;
706 0 my @types = keys %types;
707 0 ▶ if (@types == 1 && $types[0] eq $self->primary_tag) {
Branch: 1 branch
BranchTrueFalseTotal
if (@types == 1 and $types[0] eq $self->primary_tag) 0 0 0
Condition0%0/3
@types == 1 and $types[0] eq $self->primary_tag
!ll&&!rl&&r
000
MC/DC0%0/2
@types == 1 and $types[0] eq $self->primary_tag
@types == 1 $types[0] eq $self->primary_tag
Truth table0%0/3
A and B
A= @types == 1B= $types[0] eq $self->primary_tag
ABresult
0X0
100
111
708 0 return join ("\n",map {$_->gff3_string(1,$parent_tree,{},$primary_id)} @rsf);
709 }
710 }
711  
712 0 @parent_ids = keys %{$parent_tree->{$primary_id}};
713 }
714  
715 0 my $group = $self->format_attributes(\@parent_ids,$force_id);
716 0 my $name = $self->name;
717  
718 0 my $class = $self->class;
719 0 my $strand = ('-','.','+')[$self->strand+1];
720 0 ▶ my $p = join("\t",
Branch: 2 branches
BranchTrueFalseTotal
defined $self->score ? : 0 0 0
defined $self->phase ? : 0 0 0
Condition0%0/14
$self->seq_id || '.'
l!l
00
$self->source || '.'
l!l
00
$self->method || '.'
l!l
00
$self->start || '.'
l!l
00
$self->stop || '.'
l!l
00
$strand || '.'
l!l
00
$group || ''
l!l
00
MC/DC0%0/1
$self->seq_id || '.'
$self->seq_id
MC/DC0%0/1
$self->source || '.'
$self->source
MC/DC0%0/1
$self->method || '.'
$self->method
MC/DC0%0/1
$self->start || '.'
$self->start
MC/DC0%0/1
$self->stop || '.'
$self->stop
MC/DC0%0/1
$strand || '.'
$strand
MC/DC0%0/1
$group || ''
$group
Truth table0%0/2
A
A= $self->seq_id
Aresult
11
00
Truth table0%0/2
A
A= $self->source
Aresult
11
00
Truth table0%0/2
A
A= $self->method
Aresult
11
00
Truth table0%0/2
A
A= $self->start
Aresult
11
00
Truth table0%0/2
A
A= $self->stop
Aresult
11
00
Truth table0%0/2
A
A= $strand
Aresult
11
00
Truth table0%0/2
A
A= $group
Aresult
11
00
721 $self->seq_id||'.',
722 $self->source||'.',
723 $self->method||'.',
724 $self->start||'.',
725 $self->stop||'.',
726 defined($self->score) ? $self->score : '.',
727 $strand||'.',
728 defined($self->phase) ? $self->phase : '.',
729 $group||'');
730 return join("\n",
731 $p,
732 0 map {$_->gff3_string(1,$parent_tree,$seenit)} @rsf);
733 }
734  
735 sub _real_or_dummy_id {
736 0 ▶ my $self = shift;
Subroutine _real_or_dummy_id: not called CC=2 SCAR=17.9
737 0 my $id = $self->primary_id;
738 0 ▶ return $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 0 0
739 0 return return (overload::StrVal($self) =~ /0x([a-f0-9]+)/)[0];
740 }
741  
742 sub _traverse {
743 0 ▶ my $self = shift;
Subroutine _traverse: not called CC=4 SCAR=30.0
744 0 my $tree = shift; # tree => {$child}{$parent} = 1
745 0 my $parent = shift;
746 0 my $id = $self->_real_or_dummy_id;
747 0 ▶ defined $id or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $id or return 0 0 0
748 0 ▶ $tree->{$id}{$parent->_real_or_dummy_id}++ if $parent;
Branch: 1 branch
BranchTrueFalseTotal
if $parent 0 0 0
749 0 $_->_traverse($tree,$self) foreach $self->get_SeqFeatures;
750 }
751  
752 0 ▶sub db { return }
Subroutine db: not called CC=1 SCAR=6.9
Pod undocumented
753  
754 sub source_tag {
755 0 ▶ my $self = shift;
Subroutine source_tag: not called CC=2 SCAR=17.9
Pod documented
756 0 my $d = $self->{source};
757 0 ▶ $self->{source} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
758 0 $d;
759 }
760  
761 # This probably should be deleted. Not sure why it's here, but might
762 # have been added for Ace::Sequence::Feature-compliance.
763 sub introns {
764 0 ▶ my $self = shift;
Subroutine introns: not called CC=1 SCAR=6.9
Pod undocumented
765 0 return;
766 }
767  
768 sub has_tag {
769 0 ▶ my $self = shift;
Subroutine has_tag: not called CC=1 SCAR=6.9
Pod documented
770 0 my $tag = shift;
771 0 return exists $self->{attributes}{$tag};
772 }
773  
774 sub escape {
775 0 ▶ my $self = shift;
Subroutine escape: not called CC=1 SCAR=6.9
Pod undocumented
776 0 my $toencode = shift;
777 0 $toencode =~ s/([^a-zA-Z0-9_.:?^*\(\)\[\]@!+-])/uc sprintf("%%%02x",ord($1))/eg;
778 0 $toencode;
779 }
780  
781 sub all_tags {
782 0 ▶ my $self = shift;
Subroutine all_tags: not called CC=1 SCAR=6.9
Pod undocumented
783 0 return keys %{$self->{attributes}};
784 }
785  
786 sub add_tag_value {
787 0 ▶ my $self = shift;
Subroutine add_tag_value: not called CC=1 SCAR=6.9
Pod undocumented
788 0 my ($tag_name,@tag_values) = @_;
789 0 push @{$self->{attributes}{$tag_name}},@tag_values;
790 }
791  
792 sub remove_tag {
793 0 ▶ my $self = shift;
Subroutine remove_tag: not called CC=1 SCAR=6.9
Pod undocumented
794 0 my $tag_name = shift;
795 0 delete $self->{attributes}{$tag_name};
796 }
797  
798 sub each_tag_value {
799 0 ▶ my $self = shift;
Subroutine each_tag_value: not called CC=4 SCAR=30.0
Pod undocumented
800 0 my $tag = shift;
801 0 ▶ my $value = $self->{attributes}{$tag} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $value = $self->{"attributes"}{$tag} or return 0 0 0
802 0 my $ref = CORE::ref $value;
803 0 return $ref && $ref eq 'ARRAY' ? @{$self->{attributes}{$tag}}
804 0 ▶ : $self->{attributes}{$tag};
Branch: 1 branch
BranchTrueFalseTotal
$ref && $ref eq 'ARRAY' ? : 0 0 0
Condition0%0/3
$ref and $ref eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$ref and $ref eq "ARRAY"
$ref $ref eq "ARRAY"
Truth table0%0/3
A and B
A= $refB= $ref eq "ARRAY"
ABresult
0X0
100
111
805 }
806  
807 sub get_Annotations {
808 0 ▶ my $self = shift;
Subroutine get_Annotations: not called CC=2 SCAR=17.9
Pod undocumented
809 0 my $tag = shift;
810 0 my @values = $self->get_tag_values($tag);
811 0 ▶ return $values[0] if @values == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @values == 1 0 0 0
812 0 return @values;
813 }
814  
815 sub format_attributes {
816 0 ▶ my $self = shift;
Subroutine format_attributes: not called CC=8 SCAR=42.8
Pod undocumented
817 0 my $parent = shift;
818 0 my $fallback_id = shift;
819  
820 0 my @tags = $self->get_all_tags;
821 0 my @result;
822 0 for my $t (@tags) {
823 0 my @values = $self->get_tag_values($t);
824 0 ▶ push @result,join '=',$self->escape($t),join(',', map {$self->escape($_)} @values) if @values;
Branch: 1 branch
BranchTrueFalseTotal
if @values 0 0 0
825 }
826 #my $id = $self->escape($self->_real_or_dummy_id) || $fallback_id;
827 0 ▶ my $id = $fallback_id || $self->escape($self->_real_or_dummy_id);
Condition0%0/3
$fallback_id || $self->escape($self->_real_or_dummy_id)
l!l&&r!l&&!r
000
MC/DC0%0/2
$fallback_id || $self->escape($self->_real_or_dummy_id)
$fallback_id $self->escape($self->_real_or_dummy_id)
Truth table0%0/3
A || B
A= $fallback_idB= $self->escape($self->_real_or_dummy_id)
ABresult
1X1
011
000
828  
829 0 my $parent_id;
830 0 ▶ if (@$parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$parent) 0 0 0
831 0 $parent_id = join (',',map {$self->escape($_)} @$parent);
832 }
833  
834 0 my $name = $self->display_name;
835 0 ▶ unshift @result,"ID=".$id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 0 0
836 0 ▶ unshift @result,"Parent=".$parent_id if defined $parent_id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $parent_id 0 0 0
837 0 ▶ unshift @result,"Name=".$self->escape($name) if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
838 0 return join ';',@result;
839 }
840  
841 =head2 clone
842  
843 Title : clone
844 Usage : my $feature = $seqfeature->clone
845 Function: Create a deep copy of the feature
846 Returns : A copy of the feature
847 Args : none
848  
849 =cut
850  
851 sub clone {
852 0 ▶ my $self = shift;
Subroutine clone: not called CC=2 SCAR=17.9
Pod documented
853 0 my %clone = %$self;
854 # overwrite attributes
855 0 my $clone = bless \%clone,CORE::ref($self);
856 0 $clone{attributes} = {};
857 0 for my $k (keys %{$self->{attributes}}) {
858 0 @{$clone{attributes}{$k}} = @{$self->{attributes}{$k}};
859 }
860 0 return $clone;
861 }
862  
863 =head2 refseq
864  
865 Title : refseq
866 Usage : $ref = $s->refseq([$newseq] [,$newseqclass])
867 Function: get/set reference sequence
868 Returns : current reference sequence
869 Args : new reference sequence and class (optional)
870 Status : Public
871  
872 This method will get or set the reference sequence. Called with no
873 arguments, it returns the current reference sequence. Called with any
874 Bio::SeqFeatureI object that provides the seq_id(), start(), end() and
875 strand() methods.
876  
877 The method will generate an exception if you attempt to set the
878 reference sequence to a sequence that has a different seq_id from the
879 current feature.
880  
881 =cut
882  
883 sub refseq {
884 0 ▶ my $self = shift;
Subroutine refseq: not called CC=3 SCAR=24.8
Pod documented
885 0 my $d = $self->{refseq};
886 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
887 0 my $newref = shift;
888 0 ▶ $self->throw("attempt to set refseq using a feature that does not share the same seq_id")
Branch: 1 branch
BranchTrueFalseTotal
unless $newref->seq_id eq $self->seq_id 0 0 0
889 unless $newref->seq_id eq $self->seq_id;
890 0 $self->{refseq} = $newref;
891 }
892 0 return $d;
893 }
894  
895 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
896  
897 2 1;
898  
899 __END__
« Bio/DB/GFF/Util/Rearrange.pm ↑ Summary Bio/AlignIO/Handler/GenericAlignHandler.pm »