GFF/Typename.pm

filter: Statementstmt 93.0% 40 / 43 Branchbran 57.1% 8 / 14 Conditioncond 43.4% 10 / 23 MC/DCmcdc 8.3% 1 / 12 Subroutinesub 100% 9 / 9 Podpod 100% 6 / 6 totaltotal 69.1% 74 / 107 CC 17 SCAR 21.0
CC
17
Cov
72%
match
15.6
new
7.8
asString
2.1
CRAP 8.1
« GFF.pm ↑ Summary GFF/Aggregator.pm »
1 =head1 NAME
2  
3 Bio::DB::GFF::Typename -- The name of a feature type
4  
5 =head1 SYNOPSIS
6  
7 use Bio::DB::GFF;
8  
9 my $type = Bio::DB::GFF::Typename->new(similarity => 'BLAT_EST_GENOME');
10 my $segment = $segment->features($type);
11  
12 =head1 DESCRIPTION
13  
14 Bio::DB::GFF::Typename objects encapsulate the combination of feature
15 method and source used by the GFF flat file format. They can be used
16 in the Bio::DB::GFF modules wherever a feature type is called for.
17  
18 Since there are relatively few types and many features, this module
19 maintains a memory cache of unique types so that two features of the
20 same type will share the same Bio::DB::GFF::Typename object.
21  
22 =head1 METHODS
23  
24 =cut
25  
26 package Bio::DB::GFF::Typename;
27 37 $Bio::DB::GFF::Typename::VERSION = '1.7.4';
28 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 use overload
30 37 ▶ '""' => 'asString',
Subroutine BEGIN: called CC=1 SCAR=0.0
31 37 fallback => 1;
32  
33  
34 37 ▶use base qw(Bio::Root::Root Bio::Das::FeatureTypeI);
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 # cut down on the number of equivalent objects we have to create
37 37 my %OBJECT_CACHE;
38  
39 =head2 new
40  
41 Title : new
42 Usage : $type = Bio::DB::GFF::Typename->new($method,$source)
43 Function: create a new Bio::DB::GFF::Typename object
44 Returns : a new Bio::DB::GFF::Typename object
45 Args : method and source
46 Status : Public
47  
48 =cut
49  
50 1434 ▶sub new {
Subroutine new: called CC=6 SCAR=20.5
Pod documented
51 1434 my $package = shift;
52 1434 my ($method,$source) = @_;
53 1434 ▶ $method ||= '';
Condition50%1/2
$method ||= ""
l!l
14340
MC/DC0%0/1
$method ||= ""
$method
Truth table50%1/2
A
A= $method
Aresult
11
00
54 1434 ▶ $source ||= '';
Condition50%1/2
$source ||= ""
l!l
14340
MC/DC0%0/1
$source ||= ""
$source
Truth table50%1/2
A
A= $source
Aresult
11
00
55 1434 ▶ if ($source eq '' && $method =~ /^([\w\-\.]+):([\w\-\.]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source eq "" and $method =~ /^([\w\-\.]+):([\w\-\.]*)$/) 0 1434 1434
Condition33%1/3
$source eq "" and $method =~ /^([\w\-\.]+):([\w\-\.]*)$/
!ll&&!rl&&r
143400
MC/DC0%0/2
$source eq "" and $method =~ /^([\w\-\.]+):([\w\-\.]*)$/
$source eq "" $method =~ /^([\w\-\.]+):([\w\-\.]*)$/
Truth table33%1/3
A and B
A= $source eq ""B= $method =~ /^([\w\-\.]+):([\w\-\.]*)$/
ABresult
0X0
100
111
56 0 $method = $1;
57 0 $source = $2;
58 }
59 1434 ▶ return $OBJECT_CACHE{"$method:$source"} ||= bless [$method,$source],$package;
Condition100%2/2
$OBJECT_CACHE{"${method}:$source"} ||= bless([$method, $source], $package)
l!l
140133
MC/DC100%1/1
$OBJECT_CACHE{"${method}:$source"} ||= bless([$method, $source], $package)
$OBJECT_CACHE{"${method}:$source"}
Truth table100%2/2
A
A= $OBJECT_CACHE{"${method}:$source"}
Aresult
11
00
60 }
61  
62 =head2 method
63  
64 Title : method
65 Usage : $method = $type->method([$newmethod])
66 Function: get or set the method
67 Returns : a method name
68 Args : new method name (optional)
69 Status : Public
70  
71 =cut
72  
73 1029 ▶sub method {
Subroutine method: called CC=2 SCAR=6.9
Pod documented
74 1029 my $self = shift;
75 1029 my $d = $self->[0];
76 1029 ▶ $self->[0] = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 107 922 1029
77 1029 $d;
78 }
79  
80  
81 =head2 source
82  
83 Title : source
84 Usage : $source = $type->source([$newsource])
85 Function: get or set the source
86 Returns : a source name
87 Args : new source name (optional)
88 Status : Public
89  
90 =cut
91  
92 332 ▶sub source {
Subroutine source: called CC=2 SCAR=7.0
Pod documented
93 332 my $self = shift;
94 332 my $d = $self->[1];
95 332 ▶ $self->[1] = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 332 332
96 332 $d;
97 }
98  
99 =head2 asString
100  
101 Title : asString
102 Usage : $string = $type->asString
103 Function: get the method and source as a string
104 Returns : a string in "method:source" format
105 Args : none
106 Status : Public
107  
108 This method is used by operator overloading to overload the '""'
109 operator.
110  
111 =cut
112  
113 3732 ▶sub asString {
Subroutine asString: called CC=2 SCAR=7.2
Pod documented
114 3732 ▶ $_[0]->[1] ? join ':',@{$_[0]} : $_[0]->[0];
Branch: 1 branch
BranchTrueFalseTotal
$_[0][1] ? : 3732 0 3732
115 }
116  
117 =head2 clone
118  
119 Title : clone
120 Usage : $new_clone = $type->clone;
121 Function: clone this object
122 Returns : a new Bio::DB::GFF::Typename object
123 Args : none
124 Status : Public
125  
126 This method creates an exact copy of the object.
127  
128 =cut
129  
130 107 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
131 107 my $self = shift;
132 107 return bless [@$self],ref $self;
133 }
134  
135 =head2 match
136  
137 Title : match
138 Usage : $boolean = $type->match($type_or_string)
139 Function: fuzzy match on types
140 Returns : a flag indicating that the argument matches the object
141 Args : a Bio::DB::GFF::typename object, or a string in method:source format
142 Status : Public
143  
144 This match allows Sequence:Link and Sequence: to match, but not
145 Sequence:Link and Sequence:Genomic_canonical.
146  
147 =cut
148  
149 25 ▶sub match {
Subroutine match: called CC=9 SCAR=27.5
Pod documented
150 25 my $self = shift;
151 25 my $target = shift;
152 25 my ($method,$source);
153  
154 25 ▶ if (UNIVERSAL::isa($target,'Bio::DB::GFF::Typename')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($target, 'Bio::DB::GFF::Typename')) { } 0 25 25
155 0 ($method,$source) = ($target->method,$target->source);
156 } else {
157 25 ($method,$source) = split /:/,$target;
158 }
159  
160 25 ▶ $source ||= ''; # quash uninit variable warnings
Condition50%1/2
$source ||= ""
l!l
250
MC/DC0%0/1
$source ||= ""
$source
Truth table50%1/2
A
A= $source
Aresult
11
00
161  
162 25 ▶ return if $method ne '' && $self->method ne '' && $method ne $self->method;
Branch: 1 branch
BranchTrueFalseTotal
if $method ne "" and $self->method ne "" and $method ne $self->method 0 25 25
Condition33%2/6
$method ne "" and $self->method ne "" and $method ne $self->method
!ll&&!rl&&r
0250
$method ne "" and $self->method ne ""
!ll&&!rl&&r
0025
MC/DC0%0/3
$method ne "" and $self->method ne "" and $method ne $self->method
$method ne "" $self->method ne "" $method ne $self->method
Truth table25%1/4
A and B and C
A= $method ne ""B= $self->method ne ""C= $method ne $self->method
ABCresult
0XX0
10X0
1100
1111
163 25 ▶ return if $source ne '' && $self->source ne '' && $source ne $self->source;
Branch: 1 branch
BranchTrueFalseTotal
if $source ne "" and $self->source ne "" and $source ne $self->source 0 25 25
Condition33%2/6
$source ne "" and $self->source ne "" and $source ne $self->source
!ll&&!rl&&r
0250
$source ne "" and $self->source ne ""
!ll&&!rl&&r
0025
MC/DC0%0/3
$source ne "" and $self->source ne "" and $source ne $self->source
$source ne "" $self->source ne "" $source ne $self->source
Truth table25%1/4
A and B and C
A= $source ne ""B= $self->source ne ""C= $source ne $self->source
ABCresult
0XX0
10X0
1100
1111
164 25 1;
165 }
166  
167 37 1;
168  
169 =head1 BUGS
170  
171 This module is still under development.
172  
173 =head1 SEE ALSO
174  
175 L<bioperl>, L<Bio::DB::GFF>, L<Bio::DB::RelSegment>
176  
177 =head1 AUTHOR
178  
179 Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
180  
181 Copyright (c) 2001 Cold Spring Harbor Laboratory.
182  
183 This library is free software; you can redistribute it and/or modify
184 it under the same terms as Perl itself.
185  
186 =cut
187  
188 37 1;
« GFF.pm ↑ Summary GFF/Aggregator.pm »