Tools/EUtilities/Query.pm

filter: Statementstmt 69.8% 51 / 73 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 56.2% 86 / 153 CC 28 SCAR 45.1
CC
28
Cov
58%
to_string
210.0
_add_data
15.6
BEGIN
1.0
CRAP 90.9
↑ Summary Tools/EUtilities.pm »
1 package Bio::Tools::EUtilities::Query;
2 5 our $AUTHORITY = 'cpan:BIOPERLML';
3 5 $Bio::Tools::EUtilities::Query::VERSION = '1.74';
4 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Bio::Tools::EUtilities::Query::GlobalQuery;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Bio::Tools::EUtilities::History;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use base qw(Bio::Tools::EUtilities);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Parse and collect esearch, epost, espell, egquery information.
12 # AUTHOR: Chris Fields <cjfields@bioperl.org>
13 # OWNER: 2006-2013 Chris Fields
14 # LICENSE: Perl_5
15  
16  
17  
18 # private EUtilDataI method
19  
20 {
21 5 my %TYPE = (
22 'espell' => 'spelling',
23 'esearch' => 'singledbquery',
24 'egquery' => 'multidbquery',
25 'epost' => 'history'
26 );
27  
28 sub _add_data {
29 5 ▶ my ($self, $qdata) = @_;
Subroutine _add_data: called CC=15 SCAR=27.5
30 5 my $eutil = $self->eutil;
31 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
32 0 $self->throw("Bad $eutil data");
33 }
34 5 ▶ if (exists $qdata->{WebEnv}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $qdata->{"WebEnv"}) 2 3 5
35 2 my $cookie = Bio::Tools::EUtilities::History->new(-eutil => $eutil,
36 -verbose => $self->verbose);
37 2 $cookie->_add_data($qdata);
38 2 push @{$self->{'_histories'}}, $cookie;
39 }
40 5 ▶ my $type = exists $TYPE{$eutil} ? $TYPE{$eutil} :
Branch: 1 branch
BranchTrueFalseTotal
exists $TYPE{$eutil} ? : 5 0 5
41 $self->throw("Unrecognized eutil $eutil");
42 5 $self->datatype($type); # reset type based on what's present
43 5 for my $key (sort keys %$qdata) {
44 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
45 1 for my $gquery (@{ $qdata->{eGQueryResult}->{ResultItem} }) {
46 35 $self->{'_term'} = $gquery->{Term} = $qdata->{Term};
47 35 my $qd = Bio::Tools::EUtilities::Query::GlobalQuery->new(-eutil => 'egquery',
48 -datatype => 'globalquery',
49 -verbose => $self->verbose);
50 35 $qd->_add_data($gquery);
51 35 push @{ $self->{'_globalqueries'} }, $qd;
52 }
53 }
54 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
55 exists $qdata->{IdList}->{Id}) {
56 2 $self->{'_id'} = $qdata->{IdList}->{Id};
57 2 delete $qdata->{IdList};
58 }
59 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
60 exists $qdata->{TranslationSet}->{Translation}) {
61 2 $self->{'_translation'} = $qdata->{TranslationSet}->{Translation};
62 2 delete $qdata->{TranslationSet};
63 }
64 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
65 20 $self->{'_'.lc $key} = $qdata->{$key};
66 }
67 }
68  
69 }
70  
71  
72 5 sub to_string {
73 0 ▶ my $self = shift;
Subroutine to_string: not called CC=14 SCAR=53.5
Pod documented
74 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
75 'DB' => [1, join(', ',$self->get_databases) || ''],
76 'Query' => [2, $self->get_term || ''],
77 'IDs' => [4, join(', ',$self->get_ids) || ''],
78 );
79 0 my $string = $self->SUPER::to_string;
80 0 ▶ if ($self->eutil eq 'esearch') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->eutil eq "esearch") 0 0 0
81 0 $data{'Count'} = [3, $self->get_count ];
82 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
83 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
84 0 $data{'RetStart'} = [7, $self->get_retstart];
85 0 $data{'RetMax'} = [8, $self->get_retmax];
86 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
87 }
88 0 ▶ if ($self->eutil eq 'espell') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->eutil eq "espell") 0 0 0
89 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
90 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
91 }
92 0 for my $k (sort {$data{$a}->[0] <=> $data{$b}->[0]} keys %data) {
93 0 $string .= sprintf("%-20s:%s\n",$k, $self->_text_wrap('',' 'x 20 .':', $data{$k}->[1]));
94 }
95 0 ▶ while (my $h = $self->next_History) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $h = $self->next_History) 0 0 0
96 0 $string .= $h->to_string;
97 }
98 0 ▶ while (my $gq = $self->next_GlobalQuery) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gq = $self->next_GlobalQuery) 0 0 0
99 0 $string .= $gq->to_string;
100 }
101 0 return $string;
102 }
103  
104 5 1;
105  
106 __END__
↑ Summary Tools/EUtilities.pm »