Tools/EUtilities/Query.pm

filter: Statementstmt 69.4% 50 / 72 Branchbran 54.5% 12 / 22 Conditioncond 32.2% 10 / 31 MC/DCmcdc 27.7% 5 / 18 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 55.9% 85 / 152 CC 28 SCAR 44.5
CC
28
Cov
58%
to_string
197.5
_add_data
15.6
BEGIN
1.0
CRAP 85.9
↑ Summary Tools/EUtilities.pm »
1 package Bio::Tools::EUtilities::Query;
2 5 $Bio::Tools::EUtilities::Query::VERSION = '1.77';
3 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Bio::Tools::EUtilities::Query::GlobalQuery;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Bio::Tools::EUtilities::History;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use base qw(Bio::Tools::EUtilities);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Parse and collect esearch, epost, espell, egquery information.
11 # AUTHOR: Chris Fields <cjfields@bioperl.org>
12 # OWNER: 2006-2013 Chris Fields
13 # LICENSE: Perl_5
14  
15  
16  
17 # private EUtilDataI method
18  
19 {
20 5 my %TYPE = (
21 'espell' => 'spelling',
22 'esearch' => 'singledbquery',
23 'egquery' => 'multidbquery',
24 'epost' => 'history'
25 );
26  
27 5 ▶sub _add_data {
Subroutine _add_data: called CC=15 SCAR=27.5
28 5 my ($self, $qdata) = @_;
29 5 my $eutil = $self->eutil;
30 5 ▶ if (!$qdata || ref($qdata) !~ /HASH/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($qdata and ref($qdata) =~ /HASH/i) 0 5 5
Condition33%1/3
$qdata and ref($qdata) =~ /HASH/i
!ll&&!rl&&r
005
MC/DC0%0/2
$qdata and ref($qdata) =~ /HASH/i
$qdata ref($qdata) =~ /HASH/i
Truth table33%1/3
A and B
A= $qdataB= ref($qdata) =~ /HASH/i
ABresult
0X0
100
111
31 0 $self->throw("Bad $eutil data");
32 }
33 5 ▶ if (exists $qdata->{WebEnv}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $qdata->{"WebEnv"}) 2 3 5
34 2 my $cookie = Bio::Tools::EUtilities::History->new(-eutil => $eutil,
35 -verbose => $self->verbose);
36 2 $cookie->_add_data($qdata);
37 2 push @{$self->{'_histories'}}, $cookie;
38 }
39 5 ▶ my $type = exists $TYPE{$eutil} ? $TYPE{$eutil} :
Branch: 1 branch
BranchTrueFalseTotal
exists $TYPE{$eutil} ? : 5 0 5
40 $self->throw("Unrecognized eutil $eutil");
41 5 $self->datatype($type); # reset type based on what's present
42 5 for my $key (sort keys %$qdata) {
43 21 ▶ if ($key eq 'eGQueryResult' && exists $qdata->{$key}->{ResultItem}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "eGQueryResult" and exists $qdata->{$key}{"ResultItem"}) 1 20 21
Condition66%2/3
$key eq "eGQueryResult" and exists $qdata->{$key}{"ResultItem"}
!ll&&!rl&&r
2001
MC/DC50%1/2
$key eq "eGQueryResult" and exists $qdata->{$key}{"ResultItem"}
$key eq "eGQueryResult" exists $qdata->{$key}{"ResultItem"}
Truth table66%2/3
A and B
A= $key eq "eGQueryResult"B= exists $qdata->{$key}{"ResultItem"}
ABresult
0X0
100
111
44 1 for my $gquery (@{ $qdata->{eGQueryResult}->{ResultItem} }) {
45 35 $self->{'_term'} = $gquery->{Term} = $qdata->{Term};
46 35 my $qd = Bio::Tools::EUtilities::Query::GlobalQuery->new(-eutil => 'egquery',
47 -datatype => 'globalquery',
48 -verbose => $self->verbose);
49 35 $qd->_add_data($gquery);
50 35 push @{ $self->{'_globalqueries'} }, $qd;
51 }
52 }
53 21 ▶ if ($key eq 'IdList' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "IdList" and exists $qdata->{"IdList"}{"Id"}) 2 19 21
Condition66%2/3
$key eq "IdList" and exists $qdata->{"IdList"}{"Id"}
!ll&&!rl&&r
1902
MC/DC50%1/2
$key eq "IdList" and exists $qdata->{"IdList"}{"Id"}
$key eq "IdList" exists $qdata->{"IdList"}{"Id"}
Truth table66%2/3
A and B
A= $key eq "IdList"B= exists $qdata->{"IdList"}{"Id"}
ABresult
0X0
100
111
54 exists $qdata->{IdList}->{Id}) {
55 2 $self->{'_id'} = $qdata->{IdList}->{Id};
56 2 delete $qdata->{IdList};
57 }
58 21 ▶ if ($key eq 'TranslationSet' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "TranslationSet" and exists $qdata->{"TranslationSet"}{"Translation"}) 2 19 21
Condition66%2/3
$key eq "TranslationSet" and exists $qdata->{"TranslationSet"}{"Translation"}
!ll&&!rl&&r
1902
MC/DC50%1/2
$key eq "TranslationSet" and exists $qdata->{"TranslationSet"}{"Translation"}
$key eq "TranslationSet" exists $qdata->{"TranslationSet"}{"Translation"}
Truth table66%2/3
A and B
A= $key eq "TranslationSet"B= exists $qdata->{"TranslationSet"}{"Translation"}
ABresult
0X0
100
111
59 exists $qdata->{TranslationSet}->{Translation}) {
60 2 $self->{'_translation'} = $qdata->{TranslationSet}->{Translation};
61 2 delete $qdata->{TranslationSet};
62 }
63 21 ▶ next if (ref $qdata->{$key} eq 'HASH' && !keys %{$qdata->{$key}});
Branch: 1 branch
BranchTrueFalseTotal
if ref $qdata->{$key} eq "HASH" and not keys %{$$qdata{$key};} 1 20 21
Condition100%3/3
ref $qdata->{$key} eq "HASH" and not keys %{$$qdata{$key};}
!ll&&!rl&&r
1641
MC/DC100%2/2
ref $qdata->{$key} eq "HASH" and not keys %{$$qdata{$key};}
ref $qdata->{$key} eq "HASH" not keys %{$$qdata{$key};}
Truth table100%3/3
A and not(B)
A= ref $qdata->{$key} eq "HASH"B= not keys %{$$qdata{$key};}
ABresult
0X0
100
111
64 20 $self->{'_'.lc $key} = $qdata->{$key};
65 }
66 }
67  
68 }
69  
70  
71 5 ▶sub to_string {
Subroutine to_string: not called CC=14 SCAR=52.9
Pod documented
72 0 my $self = shift;
73 0 ▶ my %data = (
Condition0%0/6
join(', ', $self->get_databases) || ''
l!l
00
$self->get_term || ''
l!l
00
join(', ', $self->get_ids) || ''
l!l
00
MC/DC0%0/1
join(', ', $self->get_databases) || ''
join(', ', $self->get_databases)
MC/DC0%0/1
$self->get_term || ''
$self->get_term
MC/DC0%0/1
join(', ', $self->get_ids) || ''
join(', ', $self->get_ids)
Truth table0%0/2
A
A= join(', ', $self->get_databases)
Aresult
11
00
Truth table0%0/2
A
A= $self->get_term
Aresult
11
00
Truth table0%0/2
A
A= join(', ', $self->get_ids)
Aresult
11
00
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 ▶ if ($self->eutil eq 'esearch') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->eutil eq "esearch") 0 0 0
80 0 $data{'Count'} = [3, $self->get_count ];
81 0 ▶ $data{'Translation From'} = [5, $self->get_translation_from || ''];
Condition0%0/2
$self->get_translation_from || ''
l!l
00
MC/DC0%0/1
$self->get_translation_from || ''
$self->get_translation_from
Truth table0%0/2
A
A= $self->get_translation_from
Aresult
11
00
82 0 ▶ $data{'Translation To'} = [6, $self->get_translation_to || ''];
Condition0%0/2
$self->get_translation_to || ''
l!l
00
MC/DC0%0/1
$self->get_translation_to || ''
$self->get_translation_to
Truth table0%0/2
A
A= $self->get_translation_to
Aresult
11
00
83 0 $data{'RetStart'} = [7, $self->get_retstart];
84 0 $data{'RetMax'} = [8, $self->get_retmax];
85 0 ▶ $data{'Translation'} = [9, $self->get_query_translation || ''];
Condition0%0/2
$self->get_query_translation || ''
l!l
00
MC/DC0%0/1
$self->get_query_translation || ''
$self->get_query_translation
Truth table0%0/2
A
A= $self->get_query_translation
Aresult
11
00
86 }
87 0 ▶ if ($self->eutil eq 'espell') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->eutil eq "espell") 0 0 0
88 0 ▶ $data{'Corrected'} = [3, $self->get_corrected_query || ''];
Condition0%0/2
$self->get_corrected_query || ''
l!l
00
MC/DC0%0/1
$self->get_corrected_query || ''
$self->get_corrected_query
Truth table0%0/2
A
A= $self->get_corrected_query
Aresult
11
00
89 0 ▶ $data{'Replaced'} = [4, join(',',$self->get_replaced_terms) || ''];
Condition0%0/2
join(',', $self->get_replaced_terms) || ''
l!l
00
MC/DC0%0/1
join(',', $self->get_replaced_terms) || ''
join(',', $self->get_replaced_terms)
Truth table0%0/2
A
A= join(',', $self->get_replaced_terms)
Aresult
11
00
90 }
91 0 for my $k (sort {$data{$a}->[0] <=> $data{$b}->[0]} keys %data) {
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) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $h = $self->next_History) 0 0 0
95 0 $string .= $h->to_string;
96 }
97 0 ▶ while (my $gq = $self->next_GlobalQuery) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gq = $self->next_GlobalQuery) 0 0 0
98 0 $string .= $gq->to_string;
99 }
100 0 return $string;
101 }
102  
103 5 1;
104  
105 __END__
↑ Summary Tools/EUtilities.pm »