version increase for final release, improved warning
[bioperl-network.git] / t / Graph-Articulation.x
blobb2233be7c772012053db5ea2fec99449139b456e
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules
3 # $Id: protgraph.t,v 1.1 2004/03/13 23:45:32 radams Exp
5 use vars qw($NUMTESTS $DEBUG $ERROR);
6 use strict;
7 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
9 BEGIN {
10         # to handle systems with no installed Test module
11         # we include the t dir (where a copy of Test.pm is located)
12         # as a fallback
13         eval { require Test; };
14         $ERROR = 0;
15         if ( $@ ) {
16                 use lib 't';
17         }
18         use Test;
19         $NUMTESTS = 47;
20         plan tests => $NUMTESTS;
21         eval { require Graph; };
22         if ($@) {
23                 warn "Perl's Graph needed for the bioperl-network package, skipping tests";
24                 $ERROR = 1;
25         }
28 END {
29         foreach ( $Test::ntest..$NUMTESTS) {
30                 skip("Missing dependencies. Skipping tests",1);
31         }
34 exit 0 if $ERROR ==  1;
36 require Bio::Network::ProteinNet;
37 require Bio::Network::IO;
38 require Bio::Network::Interaction;
40 my $verbose = 0;
41 $verbose = 1 if $DEBUG;
43 # tests for Graph's problematic articulation_points()
45 ok 1;
48 # read old DIP format
50 my $io = Bio::Network::IO->new(
51   -format => 'dip_tab',
52   -file   => Bio::Root::IO->catfile("t","data","tab1part.tab"),
53   -threshold => 0.6);
54 ok(defined $io);
55 ok my $g1 = $io->next_network();
57 my @nodes = $g1->articulation_points();
58 ok $#nodes, 12;
59 my $nodes = $g1->articulation_points();
60 ok $nodes, 13;
62 # test articulation_points, but first check that each Node
63 # in network can load...
65 $io = Bio::Network::IO->new
66 (-format => 'psi',
67  -file   => Bio::Root::IO->catfile("t","data","bovin_small_intact.xml"));
68 my $g = $io->next_network();
70 @nodes = $g->nodes;
71 ok scalar @nodes, 23;
72 foreach my $node (@nodes) {
73         my @seqs = $nodes[0]->proteins;
74         ok $seqs[0]->display_id;
77 # ($ap, $bc, $br) = $g->biconnectivity;
79 @nodes = $g->articulation_points;
80 ok scalar @nodes, 4; # OK, inspected in Cytoscape
82 my @eids = qw(EBI-307814 EBI-79764 EBI-620432 EBI-620400);
83 my @seqs = $nodes[0]->proteins; # Node not always loaded
84 my $id = $seqs[0]->display_id;
85 ok grep /$id/, @eids;
86 @seqs = $nodes[1]->proteins; # Node not always loaded
87 $id = $seqs[0]->display_id;
88 ok grep /$id/, @eids;
89 @seqs = $nodes[2]->proteins; # Node not always loaded
90 $id = $seqs[0]->display_id;
91 ok grep /$id/, @eids;
92 @seqs = $nodes[3]->proteins; # Node not always loaded
93 $id = $seqs[0]->display_id;
94 ok grep /$id/, @eids;
96 # additional articulation_points tests
97 # arath_small-02.xml is PSI MI version 1.0
99 ok $io = Bio::Network::IO->new
100   (-format => 'psi',
101         -file   => Bio::Root::IO->catfile("t", "data", "arath_small-02.xml"));
102 ok $g1 = $io->next_network();
103 ok $g1->nodes, 73;
104 ok $g1->interactions, 516;
105 @nodes = $g1->articulation_points;
106 ok scalar @nodes, 8;
107 my @ids = qw(EBI-621930 EBI-622235 EBI-622281 EBI-622140 
108                           EBI-622382 EBI-622306 EBI-622264 EBI-622203 );
109 for my $node (@nodes) {
110         for my $prot ($node->proteins) {
111                 my $id = $prot->display_id;
112                 ok grep /$id/,@ids;
113         }
116 __END__