Tools/EUtilities/Query.pm

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