line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# BioPerl module for Bio::Annotation::TypeManager |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Cared for by Ewan Birney |
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::Annotation::TypeManager - Manages types for annotation collections |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# default type manager |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$tm = Bio::Annotation::TypeManager->new(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# $key is a string or a Bio::Ontology::TermI compliant object |
25
|
|
|
|
|
|
|
print "The type for $key is ",$tm->type_for_key($key),"\n"; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if( !$tm->is_valid($key,$object) ) { |
28
|
|
|
|
|
|
|
$self->throw("Invalid object for key $key"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Manages types for annotation collections. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 FEEDBACK |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 Mailing Lists |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this |
40
|
|
|
|
|
|
|
and other Bioperl modules. Send your comments and suggestions preferably |
41
|
|
|
|
|
|
|
to one of the Bioperl mailing lists. |
42
|
|
|
|
|
|
|
Your participation is much appreciated. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
bioperl-l@bioperl.org |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 Support |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
I |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
53
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
54
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
55
|
|
|
|
|
|
|
with code and data examples if at all possible. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 Reporting Bugs |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
60
|
|
|
|
|
|
|
the bugs and their resolution. |
61
|
|
|
|
|
|
|
Bug reports can be submitted via the web: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
https://github.com/bioperl/bioperl-live/issues |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR - Ewan Birney |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Email birney@ebi.ac.uk |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 APPENDIX |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Let the code begin... |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
package Bio::Annotation::TypeManager; |
80
|
187
|
|
|
187
|
|
1061
|
use strict; |
|
187
|
|
|
|
|
390
|
|
|
187
|
|
|
|
|
5246
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Object preamble - inherits from Bio::Root::Root |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
187
|
|
|
187
|
|
909
|
use base qw(Bio::Root::Root); |
|
187
|
|
|
|
|
445
|
|
|
187
|
|
|
|
|
53056
|
|
87
|
|
|
|
|
|
|
# new() can be inherited from Bio::Root::Root |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 new |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Title : new |
92
|
|
|
|
|
|
|
Usage : |
93
|
|
|
|
|
|
|
Function: |
94
|
|
|
|
|
|
|
Example : |
95
|
|
|
|
|
|
|
Returns : |
96
|
|
|
|
|
|
|
Args : |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub new{ |
102
|
2272
|
|
|
2272
|
1
|
3969
|
my ($class,@args) = @_; |
103
|
|
|
|
|
|
|
|
104
|
2272
|
|
|
|
|
4712
|
my $self = $class->SUPER::new(@args); |
105
|
|
|
|
|
|
|
|
106
|
2272
|
|
|
|
|
5066
|
$self->{'_type'} = {}; |
107
|
|
|
|
|
|
|
|
108
|
2272
|
|
|
|
|
5774
|
$self->_add_type_map('reference',"Bio::Annotation::Reference"); |
109
|
2272
|
|
|
|
|
4474
|
$self->_add_type_map('comment',"Bio::Annotation::Comment"); |
110
|
2272
|
|
|
|
|
3974
|
$self->_add_type_map('dblink',"Bio::Annotation::DBLink"); |
111
|
|
|
|
|
|
|
|
112
|
2272
|
|
|
|
|
6543
|
return $self; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 type_for_key |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Title : type_for_key |
119
|
|
|
|
|
|
|
Usage : |
120
|
|
|
|
|
|
|
Function: |
121
|
|
|
|
|
|
|
Example : |
122
|
|
|
|
|
|
|
Returns : |
123
|
|
|
|
|
|
|
Args : |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub type_for_key{ |
129
|
10770
|
|
|
10770
|
1
|
15169
|
my ($self,$key) = @_; |
130
|
|
|
|
|
|
|
|
131
|
10770
|
50
|
33
|
|
|
18400
|
$key = $key->name() if ref($key) && $key->isa("Bio::Ontology::TermI"); |
132
|
10770
|
|
|
|
|
25926
|
return $self->{'_type'}->{$key}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 is_valid |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Title : is_valid |
139
|
|
|
|
|
|
|
Usage : |
140
|
|
|
|
|
|
|
Function: |
141
|
|
|
|
|
|
|
Example : |
142
|
|
|
|
|
|
|
Returns : |
143
|
|
|
|
|
|
|
Args : |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub is_valid{ |
149
|
4151
|
|
|
4151
|
1
|
6539
|
my ($self,$key,$object) = @_; |
150
|
|
|
|
|
|
|
|
151
|
4151
|
50
|
33
|
|
|
13659
|
if( !defined $object || !ref $object ) { |
152
|
0
|
|
|
|
|
0
|
$self->throw("Cannot type an object [$object]!"); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
4151
|
50
|
|
|
|
7478
|
if( !$object->isa($self->type_for_key($key)) ) { |
156
|
0
|
|
|
|
|
0
|
return 0; |
157
|
|
|
|
|
|
|
} else { |
158
|
4151
|
|
|
|
|
11465
|
return 1; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 _add_type_map |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Title : _add_type_map |
166
|
|
|
|
|
|
|
Usage : |
167
|
|
|
|
|
|
|
Function: |
168
|
|
|
|
|
|
|
Example : |
169
|
|
|
|
|
|
|
Returns : |
170
|
|
|
|
|
|
|
Args : |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _add_type_map{ |
176
|
9284
|
|
|
9284
|
|
12509
|
my ($self,$key,$type) = @_; |
177
|
|
|
|
|
|
|
|
178
|
9284
|
50
|
33
|
|
|
15124
|
$key = $key->name() if ref($key) && $key->isa("Bio::Ontology::TermI"); |
179
|
9284
|
|
|
|
|
16329
|
$self->{'_type'}->{$key} = $type; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |