~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to t/Tools/EUtilities/esearch.t

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*-Perl-*- Test Harness script for Bioperl
2
 
# $Id: esearch.t 15112 2008-12-08 18:12:38Z sendu $
3
 
#
4
 
 
5
 
use strict;
6
 
use warnings;
7
 
 
8
 
BEGIN {
9
 
    use lib '.';
10
 
        use Bio::Root::Test;
11
 
        
12
 
        test_begin(-tests => 33,
13
 
                           -requires_module => 'XML::Simple');
14
 
        
15
 
    use_ok('Bio::Tools::EUtilities');
16
 
    use_ok('Bio::Tools::EUtilities::EUtilParameters');
17
 
}
18
 
 
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);
22
 
 
23
 
# test any Query-related methods (term related)
24
 
 
25
 
# Normal esearch
26
 
my $eutil = Bio::Tools::EUtilities->new(
27
 
    -eutil      => 'esearch',
28
 
    -file       => test_input_file('eutils','esearch1.xml'));
29
 
 
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;
33
 
is($history, undef);
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');
40
 
 
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');
45
 
 
46
 
# add Parameters
47
 
my $pb = Bio::Tools::EUtilities::EUtilParameters->new(-eutil => 'esearch',
48
 
                                                                           -db => 'protein',
49
 
                                                                           -term => 'Notch AND Mus musculus');
50
 
 
51
 
$eutil->parameter_base($pb);
52
 
 
53
 
# now will work...
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');
57
 
 
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');
61
 
 
62
 
# test esearch data with History
63
 
$eutil = Bio::Tools::EUtilities->new(
64
 
    -eutil      => 'esearch',
65
 
    -file       => test_input_file('eutils','esearch2.xml'));
66
 
 
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',
72
 
   'get_webenv');
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');
76
 
 
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');
83
 
 
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');
87
 
 
88
 
# the term isn't carried into the parsers
89
 
is($eutil->get_term, undef,'get_term');
90
 
 
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');
94
 
 
95
 
my @qs = $eutil->get_GlobalQueries;
96
 
is(scalar(@qs), 0, 'get_GlobalQueries')