line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Tools::EUtilities::Query; |
2
|
|
|
|
|
|
|
$Bio::Tools::EUtilities::Query::VERSION = '1.77'; |
3
|
4
|
|
|
4
|
|
2476
|
use utf8; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
24
|
|
4
|
4
|
|
|
4
|
|
133
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
76
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
99
|
|
6
|
4
|
|
|
4
|
|
1935
|
use Bio::Tools::EUtilities::Query::GlobalQuery; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
112
|
|
7
|
4
|
|
|
4
|
|
1817
|
use Bio::Tools::EUtilities::History; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
150
|
|
8
|
4
|
|
|
4
|
|
27
|
use base qw(Bio::Tools::EUtilities); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
3504
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Parse and collect esearch, epost, espell, egquery information. |
11
|
|
|
|
|
|
|
# AUTHOR: Chris Fields |
12
|
|
|
|
|
|
|
# OWNER: 2006-2013 Chris Fields |
13
|
|
|
|
|
|
|
# LICENSE: Perl_5 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# private EUtilDataI method |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
my %TYPE = ( |
21
|
|
|
|
|
|
|
'espell' => 'spelling', |
22
|
|
|
|
|
|
|
'esearch' => 'singledbquery', |
23
|
|
|
|
|
|
|
'egquery' => 'multidbquery', |
24
|
|
|
|
|
|
|
'epost' => 'history' |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _add_data { |
28
|
5
|
|
|
5
|
|
18
|
my ($self, $qdata) = @_; |
29
|
5
|
|
|
|
|
34
|
my $eutil = $self->eutil; |
30
|
5
|
50
|
33
|
|
|
58
|
if (!$qdata || ref($qdata) !~ /HASH/i) { |
31
|
0
|
|
|
|
|
0
|
$self->throw("Bad $eutil data"); |
32
|
|
|
|
|
|
|
} |
33
|
5
|
100
|
|
|
|
38
|
if (exists $qdata->{WebEnv}) { |
34
|
2
|
|
|
|
|
16
|
my $cookie = Bio::Tools::EUtilities::History->new(-eutil => $eutil, |
35
|
|
|
|
|
|
|
-verbose => $self->verbose); |
36
|
2
|
|
|
|
|
10
|
$cookie->_add_data($qdata); |
37
|
2
|
|
|
|
|
5
|
push @{$self->{'_histories'}}, $cookie; |
|
2
|
|
|
|
|
8
|
|
38
|
|
|
|
|
|
|
} |
39
|
5
|
50
|
|
|
|
50
|
my $type = exists $TYPE{$eutil} ? $TYPE{$eutil} : |
40
|
|
|
|
|
|
|
$self->throw("Unrecognized eutil $eutil"); |
41
|
5
|
|
|
|
|
29
|
$self->datatype($type); # reset type based on what's present |
42
|
5
|
|
|
|
|
56
|
for my $key (sort keys %$qdata) { |
43
|
21
|
50
|
66
|
|
|
50
|
if ($key eq 'eGQueryResult' && exists $qdata->{$key}->{ResultItem}) { |
44
|
1
|
|
|
|
|
3
|
for my $gquery (@{ $qdata->{eGQueryResult}->{ResultItem} }) { |
|
1
|
|
|
|
|
4
|
|
45
|
35
|
|
|
|
|
93
|
$self->{'_term'} = $gquery->{Term} = $qdata->{Term}; |
46
|
35
|
|
|
|
|
77
|
my $qd = Bio::Tools::EUtilities::Query::GlobalQuery->new(-eutil => 'egquery', |
47
|
|
|
|
|
|
|
-datatype => 'globalquery', |
48
|
|
|
|
|
|
|
-verbose => $self->verbose); |
49
|
35
|
|
|
|
|
93
|
$qd->_add_data($gquery); |
50
|
35
|
|
|
|
|
58
|
push @{ $self->{'_globalqueries'} }, $qd; |
|
35
|
|
|
|
|
79
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
21
|
50
|
66
|
|
|
50
|
if ($key eq 'IdList' && |
54
|
|
|
|
|
|
|
exists $qdata->{IdList}->{Id}) { |
55
|
2
|
|
|
|
|
6
|
$self->{'_id'} = $qdata->{IdList}->{Id}; |
56
|
2
|
|
|
|
|
7
|
delete $qdata->{IdList}; |
57
|
|
|
|
|
|
|
} |
58
|
21
|
50
|
66
|
|
|
48
|
if ($key eq 'TranslationSet' && |
59
|
|
|
|
|
|
|
exists $qdata->{TranslationSet}->{Translation}) { |
60
|
2
|
|
|
|
|
7
|
$self->{'_translation'} = $qdata->{TranslationSet}->{Translation}; |
61
|
2
|
|
|
|
|
5
|
delete $qdata->{TranslationSet}; |
62
|
|
|
|
|
|
|
} |
63
|
21
|
100
|
100
|
|
|
55
|
next if (ref $qdata->{$key} eq 'HASH' && !keys %{$qdata->{$key}}); |
|
5
|
|
|
|
|
24
|
|
64
|
20
|
|
|
|
|
107
|
$self->{'_'.lc $key} = $qdata->{$key}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub to_string { |
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
73
|
0
|
|
0
|
|
|
|
my %data = ( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
74
|
|
|
|
|
|
|
'DB' => [1, join(', ',$self->get_databases) || ''], |
75
|
|
|
|
|
|
|
'Query' => [2, $self->get_term || ''], |
76
|
|
|
|
|
|
|
'IDs' => [4, join(', ',$self->get_ids) || ''], |
77
|
|
|
|
|
|
|
); |
78
|
0
|
|
|
|
|
|
my $string = $self->SUPER::to_string; |
79
|
0
|
0
|
|
|
|
|
if ($self->eutil eq 'esearch') { |
80
|
0
|
|
|
|
|
|
$data{'Count'} = [3, $self->get_count ]; |
81
|
0
|
|
0
|
|
|
|
$data{'Translation From'} = [5, $self->get_translation_from || '']; |
82
|
0
|
|
0
|
|
|
|
$data{'Translation To'} = [6, $self->get_translation_to || '']; |
83
|
0
|
|
|
|
|
|
$data{'RetStart'} = [7, $self->get_retstart]; |
84
|
0
|
|
|
|
|
|
$data{'RetMax'} = [8, $self->get_retmax]; |
85
|
0
|
|
0
|
|
|
|
$data{'Translation'} = [9, $self->get_query_translation || '']; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
if ($self->eutil eq 'espell') { |
88
|
0
|
|
0
|
|
|
|
$data{'Corrected'} = [3, $self->get_corrected_query || '']; |
89
|
0
|
|
0
|
|
|
|
$data{'Replaced'} = [4, join(',',$self->get_replaced_terms) || '']; |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
for my $k (sort {$data{$a}->[0] <=> $data{$b}->[0]} keys %data) { |
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$string .= sprintf("%-20s:%s\n",$k, $self->_text_wrap('',' 'x 20 .':', $data{$k}->[1])); |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
|
while (my $h = $self->next_History) { |
95
|
0
|
|
|
|
|
|
$string .= $h->to_string; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
while (my $gq = $self->next_GlobalQuery) { |
98
|
0
|
|
|
|
|
|
$string .= $gq->to_string; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
return $string; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |