tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / t / Tools / EUtilities / elink_scores.t
blob20bfe5ca8e645f0a59ee1b50075bce7f1f5a4f03
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: epost.t 15112 2008-12-08 18:12:38Z sendu $
4 use strict;
5 use warnings;
7 BEGIN {
8     use lib '.';
9         use Bio::Root::Test;
10         
11         test_begin(-tests => 58,
12                            -requires_module => 'XML::Simple');
13         
14     use_ok('Bio::Tools::EUtilities');
15     use_ok('Bio::Tools::EUtilities::EUtilParameters');
18 # check -correspondence => 0 (default) - this is set up to return the
19 # exact same thing as correspondece = 1, tested below)
20 my $eutil = Bio::Tools::EUtilities->new(
21     -eutil      => 'elink',
22     -file       => test_input_file('eutils','elink_scores.xml'));
24 isa_ok($eutil, 'Bio::Tools::EUtilities::Link');
25 is(join(',',$eutil->get_databases), 'protein');
27 # for elinks, IDs are globbed together when called from the parser unless a database is specified
28 is(join(',',$eutil->get_ids), '15622530,15921743,70607303,68567951,145702933,'.
29    '146304683,6015889,13813749,15897502,15622530,74573864,15921743', 'get_ids');
30 my @ls = $eutil->get_LinkSets;
31 is(scalar(@ls), 2, 'uncorrelated LinkSets lump everything together');
32 is(join(',',$ls[1]->get_databases), 'protein');
33 isa_ok($ls[0], 'Bio::Tools::EUtilities::EUtilDataI');
34 isa_ok($ls[0], 'Bio::Tools::EUtilities::Link::LinkSet');
36 # check data in LinkSets
37 is(join(',',$ls[0]->get_ids), '15622530,15921743,70607303,68567951,145702933,'.
38    '146304683,6015889,13813749,15897502');
39 is(join(',',$ls[0]->get_databases), 'protein');
40 is(join(',',$ls[0]->get_submitted_ids), '15622530');
41 is($ls[0]->get_dbfrom, 'protein');
42 is(join(',',$ls[0]->get_link_names), 'protein_protein');
43 is($ls[0]->has_linkout, 0);
44 is($ls[0]->has_neighbor, 0);
46 # has relatedness scores!
47 is($ls[0]->has_scores, 1);
49 my %sd = (
50     15622530 => 2147483647,
51     15921743 => 381,
52     70607303 => 178,
53     68567951 => 178,
54     145702933 => 161,
55     146304683 => 161,
56     6015889 => 142,
57     13813749 => 142,
58     15897502 => 142);
60 my %sc = $ls[0]->get_scores;
61 for my $id ($ls[0]->get_ids) {
62     ok(exists($sc{$id}));
63     is($sc{$id}, $sd{$id});
64     delete $sd{$id};
66 is(keys %sd, 0);
68 # no LinkInfo
69 my @info = $ls[0]->get_LinkInfo;
70 is(scalar(@info), 0);
72 # no UrlLinks
73 my @urls = $ls[0]->get_UrlLinks;
74 is(scalar(@urls), 0);
76 is(join(',',$ls[1]->get_ids), '15622530,74573864,15921743');
77 is(join(',',$ls[1]->get_databases), 'protein');
78 is(join(',',$ls[1]->get_submitted_ids), '15622530');
79 is(join(',',$ls[1]->get_link_names), 'protein_protein_identical');
80 is($ls[1]->get_webenv, undef);
81 is($ls[1]->get_dbfrom, 'protein');
82 is($ls[1]->has_linkout, 0);
83 is($ls[1]->has_neighbor, 0);
85 # has relatedness scores!
86 is($ls[1]->has_scores, 1);
88 %sd = (
89     15622530 => 2147483647,
90     74573864 => 0,
91     15921743 => 0,
94 %sc = $ls[1]->get_scores;
95 for my $id ($ls[1]->get_ids) {
96     ok(exists($sc{$id}));
97     is($sc{$id}, $sd{$id});
98     delete $sd{$id};
101 is(keys %sd, 0);
103 # HistoryI
104 is($ls[1]->get_webenv, undef);
105 is($ls[1]->get_query_key, undef);
107 # no LinkInfo
108 @info = $ls[1]->get_LinkInfo;
109 is(scalar(@info), 0);
111 # no UrlLinks
112 @urls = $ls[1]->get_UrlLinks;
113 is(scalar(@urls), 0);