line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: base.pm,v 1.5 2004/11/24 02:28:00 cmungall Exp $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This GO module is maintained by Chris Mungall |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# see also - http://www.geneontology.org |
6
|
|
|
|
|
|
|
# - http://www.godatabase.org/dev |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
GO::Handlers::base - |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use GO::Handlers::base |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Default Handler, other handlers inherit from this class |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
this class catches events (start, end and body) and allows the |
25
|
|
|
|
|
|
|
subclassing module to intercept these. unintercepted events get pushed |
26
|
|
|
|
|
|
|
into a tree |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
See GO::Parser for details on parser/handler architecture |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 PUBLIC METHODS - |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package GO::Handlers::base; |
35
|
|
|
|
|
|
|
|
36
|
17
|
|
|
17
|
|
119
|
use strict; |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
661
|
|
37
|
17
|
|
|
17
|
|
93
|
use Exporter; |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
630
|
|
38
|
17
|
|
|
17
|
|
91
|
use Carp; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
1539
|
|
39
|
17
|
|
|
17
|
|
254
|
use GO::Model::Root; |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
500
|
|
40
|
17
|
|
|
17
|
|
84
|
use vars qw(@ISA @EXPORT_OK @EXPORT); |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
1355
|
|
41
|
17
|
|
|
17
|
|
172
|
use base qw(Data::Stag::Writer Exporter); |
|
17
|
|
|
|
|
61
|
|
|
17
|
|
|
|
|
19431
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
@EXPORT_OK = qw(lookup); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
0
|
sub EMITS { () } |
46
|
|
|
|
|
|
|
sub CONSUMES { |
47
|
0
|
|
|
0
|
1
|
0
|
qw( |
48
|
|
|
|
|
|
|
header |
49
|
|
|
|
|
|
|
source |
50
|
|
|
|
|
|
|
term |
51
|
|
|
|
|
|
|
typedef |
52
|
|
|
|
|
|
|
prod |
53
|
|
|
|
|
|
|
) |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
0
|
0
|
sub is_transform { 0 } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 strictorder |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Usage - $handler->strictorder(1); |
61
|
|
|
|
|
|
|
Returns - |
62
|
|
|
|
|
|
|
Args - |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
boolean accessor; if set, then terms passed must be in order |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub strictorder { |
69
|
128
|
|
|
128
|
1
|
193
|
my $self = shift; |
70
|
128
|
50
|
|
|
|
317
|
$self->{_strictorder} = shift if @_; |
71
|
128
|
|
|
|
|
931
|
return $self->{_strictorder}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub proddb { |
75
|
35
|
|
|
35
|
0
|
16378
|
my $self = shift; |
76
|
35
|
100
|
|
|
|
120
|
$self->{_proddb} = shift if @_; |
77
|
35
|
|
|
|
|
429
|
return $self->{_proddb}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub ontology_type { |
81
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
82
|
0
|
0
|
|
|
|
0
|
$self->{_ontology_type} = shift if @_; |
83
|
0
|
|
|
|
|
0
|
return $self->{_ontology_type}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub root_to_be_added { |
87
|
1369
|
|
|
1369
|
0
|
1992
|
my $self = shift; |
88
|
1369
|
50
|
|
|
|
2976
|
$self->{_root_to_be_added} = shift if @_; |
89
|
1369
|
|
|
|
|
4705
|
return $self->{_root_to_be_added}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# DEPRECATED |
95
|
|
|
|
|
|
|
sub messages { |
96
|
19
|
|
|
19
|
0
|
1203
|
my $self = shift; |
97
|
19
|
50
|
|
|
|
104
|
$self->{_messages} = shift if @_; |
98
|
19
|
|
|
|
|
74
|
return $self->{_messages}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
*error_list = \&messages; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub message { |
104
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
105
|
0
|
|
|
|
|
0
|
push(@{$self->messages}, |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
shift); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub lookup { |
111
|
0
|
|
|
0
|
0
|
0
|
my $tree = shift; |
112
|
0
|
|
|
|
|
0
|
my $k = shift; |
113
|
|
|
|
|
|
|
# use Data::Dumper; |
114
|
|
|
|
|
|
|
# print Dumper $tree; |
115
|
|
|
|
|
|
|
# confess; |
116
|
0
|
0
|
|
|
|
0
|
if (!ref($tree)) { |
117
|
0
|
|
|
|
|
0
|
confess($tree); |
118
|
|
|
|
|
|
|
} |
119
|
0
|
|
|
|
|
0
|
my @v = map {$_->[1]} grep {$_->[0] eq $k} @$tree; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
120
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
121
|
0
|
|
|
|
|
0
|
return @v; |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
|
|
0
|
$v[0]; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#sub print { |
128
|
|
|
|
|
|
|
# my $self = shift; |
129
|
|
|
|
|
|
|
# print "@_"; |
130
|
|
|
|
|
|
|
#} |
131
|
249
|
|
|
249
|
0
|
779
|
sub print {shift->addtext(@_)} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub printf { |
134
|
906
|
|
|
906
|
0
|
1142
|
my $self = shift; |
135
|
906
|
|
|
|
|
1052
|
my $fmt = shift; |
136
|
906
|
|
|
|
|
4618
|
$self->addtext(sprintf($fmt, @_)); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub throw { |
140
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my @msg = @_; |
142
|
0
|
|
|
|
|
|
confess("@msg"); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
sub warn { |
145
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
146
|
0
|
|
|
|
|
|
my @msg = @_; |
147
|
0
|
|
|
|
|
|
warn("@msg"); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub dbxref2str { |
151
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
152
|
0
|
|
|
|
|
|
my $dbxref = shift; |
153
|
|
|
|
|
|
|
return |
154
|
0
|
|
|
|
|
|
$dbxref->sget_dbname . ':' . $dbxref->sget_acc; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub xslt { |
158
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
159
|
0
|
0
|
|
|
|
|
$self->{_xslt} = shift if @_; |
160
|
0
|
|
|
|
|
|
return $self->{_xslt}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |