1
# -*-Perl-*- Test Harness script for Bioperl
2
# $Id: esearch.t 15112 2008-12-08 18:12:38Z sendu $
12
test_begin(-tests => 33,
13
-requires_module => 'XML::Simple');
15
use_ok('Bio::Tools::EUtilities');
16
use_ok('Bio::Tools::EUtilities::EUtilParameters');
19
my @ids = qw(6679096 31543332 134288853 483581 20805941 187951953 169158074
20
123228044 148676374 114326469 148707003 187952787 123233807 148694865 148694864
21
148694863 148694861 148694862 8705244 8568086);
23
# test any Query-related methods (term related)
26
my $eutil = Bio::Tools::EUtilities->new(
28
-file => test_input_file('eutils','esearch1.xml'));
30
# w/o a ParameterBase, only IDs, count, retstart/retmax, optionally History
31
is ($eutil->get_count, 534, 'get_count');
32
my $history = $eutil->next_History;
34
my @ids2 = $eutil->get_ids;
35
is_deeply(\@ids2, \@ids, 'get_ids');
36
is($eutil->get_retstart, 0,'get_retstart');
37
is($eutil->get_retmax, 20,'get_retmax');
38
is($eutil->get_translation_from, 'Mus musculus','get_translation_from');
39
is($eutil->get_translation_to, '("Mus musculus"[Organism:__txid10090] OR Mus musculus)','get_translation_to');
41
# the database isn't carried into the parsers unless a EUtilParameters is present
42
is($eutil->get_db, undef, 'get_db');
43
is($eutil->get_database, undef, 'get_database');
44
is($eutil->get_term, undef,'get_term');
47
my $pb = Bio::Tools::EUtilities::EUtilParameters->new(-eutil => 'esearch',
49
-term => 'Notch AND Mus musculus');
51
$eutil->parameter_base($pb);
54
is($eutil->get_db, 'protein', 'get_db');
55
is($eutil->get_database, 'protein', 'get_database');
56
is($eutil->get_term, 'Notch AND Mus musculus','get_term');
58
# espell only (should be undef)
59
is($eutil->get_corrected_query, undef ,'get_corrected_query');
60
is($eutil->get_replaced_terms, undef ,'get_replaced_terms');
62
# test esearch data with History
63
$eutil = Bio::Tools::EUtilities->new(
65
-file => test_input_file('eutils','esearch2.xml'));
67
is ($eutil->get_count, 534, 'get_count');
68
$history = $eutil->next_History;
69
isa_ok($history, 'Bio::Tools::EUtilities::HistoryI');
70
is($history->get_webenv,
71
'00m7eJh8lyG3wiC2SE2hd7Im_w5o3z3q4_JK9-Rn266ix_eRXkjNOYQxHp@03F17619941CFD71_0005SID',
73
is($history->get_query_key, 1, 'get_query_key');
74
is(join(',',$history->history),
75
'00m7eJh8lyG3wiC2SE2hd7Im_w5o3z3q4_JK9-Rn266ix_eRXkjNOYQxHp@03F17619941CFD71_0005SID,1', 'history');
77
@ids2 = $eutil->get_ids;
78
is_deeply(\@ids2, \@ids, 'get_ids');
79
is($eutil->get_retstart, 0,'get_retstart');
80
is($eutil->get_retmax, 20,'get_retmax');
81
is($eutil->get_translation_from, 'Mus musculus','get_translation_from');
82
is($eutil->get_translation_to, '("Mus musculus"[Organism:__txid10090] OR Mus musculus)','get_translation_to');
84
# the database isn't carried into the parsers
85
is($eutil->get_db, undef, 'get_db');
86
is($eutil->get_database, undef, 'get_database');
88
# the term isn't carried into the parsers
89
is($eutil->get_term, undef,'get_term');
91
# espell only (should be undef)
92
is($eutil->get_corrected_query, undef ,'get_corrected_query');
93
is($eutil->get_replaced_terms, undef ,'get_replaced_terms');
95
my @qs = $eutil->get_GlobalQueries;
96
is(scalar(@qs), 0, 'get_GlobalQueries')