| 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
Condition33%1/3
$qdata and ref($qdata) =~ /HASH/i
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
| |||||||||||||||||||||||||||||||||
| 31 | 0 | $self->throw("Bad $eutil data"); | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | if (exists $qdata->{WebEnv}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$key eq "eGQueryResult" and exists $qdata->{$key}{"ResultItem"}
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"}
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$key eq "IdList" and exists $qdata->{"IdList"}{"Id"}
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"}
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$key eq "TranslationSet" and exists $qdata->{"TranslationSet"}{"Translation"}
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"}
| |||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
ref $qdata->{$key} eq "HASH" and not keys %{$$qdata{$key};}
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};}
| |||||||||||||||||||||||||||||||||
| 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) || ''
$self->get_term || ''
join(', ', $self->get_ids) || ''
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)
Truth table0%0/2
A
A= $self->get_term
Truth table0%0/2
A
A= join(', ', $self->get_ids)
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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 || ''
MC/DC0%0/1
$self->get_translation_from || ''
$self->get_translation_from
Truth table0%0/2
A
A= $self->get_translation_from
| |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $data{'Translation To'} = [6, $self->get_translation_to || '']; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_translation_to || ''
MC/DC0%0/1
$self->get_translation_to || ''
$self->get_translation_to
Truth table0%0/2
A
A= $self->get_translation_to
| |||||||||||||||||||||||||||||||||
| 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 || ''
MC/DC0%0/1
$self->get_query_translation || ''
$self->get_query_translation
Truth table0%0/2
A
A= $self->get_query_translation
| |||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($self->eutil eq 'espell') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $data{'Corrected'} = [3, $self->get_corrected_query || '']; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_corrected_query || ''
MC/DC0%0/1
$self->get_corrected_query || ''
$self->get_corrected_query
Truth table0%0/2
A
A= $self->get_corrected_query
| |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $data{'Replaced'} = [4, join(',',$self->get_replaced_terms) || '']; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
join(',', $self->get_replaced_terms) || ''
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)
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 95 | 0 | $string .= $h->to_string; | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | while (my $gq = $self->next_GlobalQuery) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | 0 | $string .= $gq->to_string; | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | 0 | return $string; | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 5 | 1; | |||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||||||||||||||