line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Tools::EUtilities::Summary::Item; |
2
|
|
|
|
|
|
|
$Bio::Tools::EUtilities::Summary::Item::VERSION = '1.76'; |
3
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
31
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(Bio::Root::Root Bio::Tools::EUtilities::EUtilDataI); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1818
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Simple layered object for DocSum item data. |
9
|
|
|
|
|
|
|
# AUTHOR: Chris Fields |
10
|
|
|
|
|
|
|
# OWNER: 2006-2013 Chris Fields |
11
|
|
|
|
|
|
|
# LICENSE: Perl_5 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
160
|
|
|
160
|
1
|
1588
|
my ($class, @args) = @_; |
17
|
160
|
|
|
|
|
376
|
my $self = $class->SUPER::new(@args); |
18
|
160
|
|
|
|
|
4023
|
my ($type) = $self->_rearrange(['DATATYPE'],@args); |
19
|
160
|
|
50
|
|
|
3344
|
$type ||= 'item'; |
20
|
160
|
|
|
|
|
420
|
$self->datatype($type); |
21
|
160
|
|
|
|
|
422
|
$self->eutil('esummary'); |
22
|
160
|
|
|
|
|
408
|
$self->rewind('recursive'); |
23
|
160
|
|
|
|
|
352
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_ids { |
28
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
29
|
0
|
|
|
|
|
0
|
return ($self->{'_id'}); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_id { |
34
|
9
|
|
|
9
|
1
|
4271
|
my $self = shift; |
35
|
9
|
|
|
|
|
45
|
return $self->{'_id'}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub next_ListItem { |
40
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
41
|
0
|
0
|
|
|
|
0
|
unless ($self->{'_lists_it'}) { |
42
|
0
|
|
|
|
|
0
|
my @lists = $self->get_ListItems; |
43
|
|
|
|
|
|
|
# reset the structure iterator (required!) |
44
|
0
|
0
|
|
|
|
0
|
delete $self->{'_structures_it'} if $self->{'_structures_it'}; |
45
|
0
|
|
|
0
|
|
0
|
$self->{'_lists_it'} = sub {return shift @lists} |
46
|
0
|
|
|
|
|
0
|
} |
47
|
0
|
|
|
|
|
0
|
return $self->{'_lists_it'}->(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_ListItems { |
52
|
59
|
|
|
59
|
1
|
92
|
my $self = shift; |
53
|
59
|
100
|
|
|
|
108
|
my @items = $self->get_type eq 'List' ? $self->get_subItems : (); |
54
|
59
|
|
|
|
|
145
|
return @items; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub next_StructureItem { |
59
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
60
|
0
|
0
|
|
|
|
0
|
unless ($self->{'_structures_it'}) { |
61
|
0
|
|
|
|
|
0
|
my @structs = $self->get_StructureItems; |
62
|
0
|
|
|
0
|
|
0
|
$self->{'_structures_it'} = sub {return shift @structs} |
63
|
0
|
|
|
|
|
0
|
} |
64
|
0
|
|
|
|
|
0
|
return $self->{'_structures_it'}->(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_StructureItems { |
69
|
18
|
|
|
18
|
1
|
1482
|
my $self = shift; |
70
|
18
|
50
|
|
|
|
41
|
my @items = $self->get_type eq 'Structure' ? $self->get_subItems : (); |
71
|
18
|
|
|
|
|
56
|
return @items; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub next_subItem { |
76
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
77
|
0
|
0
|
|
|
|
0
|
unless ($self->{'_subitem_it'}) { |
78
|
0
|
|
|
|
|
0
|
my @structs = $self->get_subItems; |
79
|
0
|
|
|
0
|
|
0
|
$self->{'_subitem_it'} = sub {return shift @structs} |
80
|
0
|
|
|
|
|
0
|
} |
81
|
0
|
|
|
|
|
0
|
return $self->{'_subitem_it'}->(); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub get_subItems { |
86
|
21
|
|
|
21
|
1
|
38
|
my $self = shift; |
87
|
21
|
50
|
|
|
|
55
|
ref $self->{'_items'} ? return @{ $self->{'_items'} } : return (); |
|
21
|
|
|
|
|
59
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_name { |
92
|
281
|
|
|
281
|
1
|
405
|
my $self = shift; |
93
|
281
|
|
|
|
|
660
|
return $self->{'_itemname'}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub get_type { |
98
|
91
|
|
|
91
|
1
|
135
|
my $self = shift; |
99
|
91
|
|
|
|
|
274
|
return $self->{'_itemtype'}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_content { |
104
|
28
|
|
|
28
|
1
|
46
|
my $self = shift; |
105
|
28
|
|
|
|
|
91
|
return $self->{'_itemcontent'}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub rewind { |
110
|
160
|
|
|
160
|
1
|
260
|
my ($self, $request) = @_; |
111
|
160
|
50
|
33
|
|
|
532
|
if ($request && $request eq 'all') { |
112
|
0
|
|
|
|
|
0
|
map {$_->rewind()} $self->get_ListItems; |
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
} |
114
|
160
|
50
|
|
|
|
306
|
delete $self->{"_lists_it"} if $self->{"_lists_it"}; |
115
|
160
|
50
|
|
|
|
311
|
delete $self->{"_structures_it"} if $self->{"_structures_it"}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub next_Item { |
121
|
0
|
|
|
0
|
1
|
0
|
my ($self, $request) = @_; |
122
|
0
|
0
|
|
|
|
0
|
unless ($self->{"_items_it"}) { |
123
|
|
|
|
|
|
|
#my @items = $self->get_Items; |
124
|
0
|
0
|
0
|
|
|
0
|
my @items = ($request && $request eq 'flatten') ? |
125
|
|
|
|
|
|
|
$self->get_all_Items : |
126
|
|
|
|
|
|
|
$self->get_Items ; |
127
|
0
|
|
|
0
|
|
0
|
$self->{"_items_it"} = sub {return shift @items} |
128
|
0
|
|
|
|
|
0
|
} |
129
|
0
|
|
|
|
|
0
|
$self->{'_items_it'}->(); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub get_Items { |
134
|
1
|
|
|
1
|
1
|
744
|
my $self = shift; |
135
|
1
|
50
|
|
|
|
8
|
return ref $self->{'_items'} ? @{ $self->{'_items'} } : return (); |
|
1
|
|
|
|
|
6
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub get_all_Items { |
140
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
141
|
0
|
0
|
|
|
|
0
|
unless ($self->{'_ordered_items'}) { |
142
|
0
|
|
|
|
|
0
|
for my $item ($self->get_Items) { |
143
|
0
|
|
|
|
|
0
|
push @{$self->{'_ordered_items'}}, $item; |
|
0
|
|
|
|
|
0
|
|
144
|
0
|
|
|
|
|
0
|
for my $ls ($item->get_ListItems) { |
145
|
0
|
|
|
|
|
0
|
push @{$self->{'_ordered_items'}}, $ls; |
|
0
|
|
|
|
|
0
|
|
146
|
0
|
|
|
|
|
0
|
for my $st ($ls->get_StructureItems) { |
147
|
0
|
|
|
|
|
0
|
push @{$self->{'_ordered_items'}}, $st; |
|
0
|
|
|
|
|
0
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
0
|
|
|
|
|
0
|
return @{$self->{'_ordered_items'}}; |
|
0
|
|
|
|
|
0
|
|
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub get_all_names { |
157
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
158
|
0
|
|
|
|
|
0
|
my %tmp; |
159
|
0
|
|
|
|
|
0
|
my @data = grep {!$tmp{$_}++} |
160
|
0
|
|
|
|
|
0
|
map {$_->get_name} $self->get_all_Items; |
|
0
|
|
|
|
|
0
|
|
161
|
0
|
|
|
|
|
0
|
return @data; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub get_Items_by_name { |
166
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
167
|
0
|
0
|
|
|
|
0
|
return unless $key; |
168
|
0
|
|
|
|
|
0
|
my @data = grep {$_->get_name eq $key} |
|
0
|
|
|
|
|
0
|
|
169
|
|
|
|
|
|
|
$self->get_all_Items; |
170
|
0
|
|
|
|
|
0
|
return @data; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub get_contents_by_name { |
175
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
176
|
0
|
0
|
|
|
|
0
|
return unless $key; |
177
|
0
|
|
|
|
|
0
|
my @data = map {$_->get_content} |
178
|
0
|
|
|
|
|
0
|
grep {$_->get_name eq $key} |
|
0
|
|
|
|
|
0
|
|
179
|
|
|
|
|
|
|
$self->get_all_Items; |
180
|
0
|
|
|
|
|
0
|
return @data; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub get_type_by_name { |
185
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
186
|
0
|
0
|
|
|
|
0
|
return unless $key; |
187
|
0
|
|
|
|
|
0
|
my ($it) = grep {$_->get_name eq $key} $self->get_all_Items; |
|
0
|
|
|
|
|
0
|
|
188
|
0
|
|
|
|
|
0
|
return $it->get_type; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# private data method |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub _add_data { |
194
|
160
|
|
|
160
|
|
281
|
my ($self, $data) = @_; |
195
|
160
|
100
|
|
|
|
312
|
if ($data->{Item}) { |
196
|
18
|
|
|
|
|
46
|
my $objtype = lc $data->{Type}.'_item'; |
197
|
18
|
50
|
|
|
|
48
|
$self->{'_id'} = $data->{Id} if exists $data->{Id}; |
198
|
18
|
|
|
|
|
29
|
for my $sd (@{ $data->{Item} } ) { |
|
18
|
|
|
|
|
39
|
|
199
|
96
|
50
|
|
|
|
231
|
$sd->{Id} = $data->{Id} if exists $data->{Id}; |
200
|
96
|
|
|
|
|
213
|
my $subdoc = Bio::Tools::EUtilities::Summary::Item->new( |
201
|
|
|
|
|
|
|
-datatype => $objtype, |
202
|
|
|
|
|
|
|
-verbose => $self->verbose); |
203
|
96
|
|
|
|
|
263
|
$subdoc->_add_data($sd); |
204
|
96
|
|
|
|
|
134
|
push @{ $self->{'_items'} }, $subdoc; |
|
96
|
|
|
|
|
243
|
|
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
160
|
|
|
|
|
278
|
for my $nm (qw(Type content Name)) { |
208
|
480
|
100
|
|
|
|
1375
|
$self->{'_item'.lc $nm} = $data->{$nm} if defined $data->{$nm}; |
209
|
|
|
|
|
|
|
} |
210
|
160
|
50
|
|
|
|
421
|
$self->{'_id'} = $data->{Id} if exists $data->{Id}; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# recursively called to grab subitems, then layer |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub to_string { |
217
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
218
|
0
|
|
0
|
|
|
|
my $level = shift || 0; |
219
|
|
|
|
|
|
|
# this is the field length for the initial data (spaces are padded in front) |
220
|
0
|
|
|
|
|
|
my $pad = 20 - $level; |
221
|
0
|
|
0
|
|
|
|
my $content = $self->get_content || ''; |
222
|
0
|
|
|
|
|
|
my $string .= sprintf("%-*s%-*s%s\n", |
223
|
|
|
|
|
|
|
$level, '', |
224
|
|
|
|
|
|
|
$pad, $self->get_name(), |
225
|
|
|
|
|
|
|
$self->_text_wrap(':', |
226
|
|
|
|
|
|
|
' ' x ($pad).':', |
227
|
|
|
|
|
|
|
$content)); |
228
|
0
|
|
|
|
|
|
for my $sub ($self->get_subItems) { |
229
|
0
|
|
|
|
|
|
$string .= $sub->to_string(4 + $level); |
230
|
|
|
|
|
|
|
} |
231
|
0
|
|
|
|
|
|
return $string; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
__END__ |