ModuleBuildBioperl -> Bio::Root::Build
[bioperl-network.git] / t / Graph-Articulation.x
blob9247c8f406af8ccf94a68fe60e2dffe4fa6a4300
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules
3 # $Id: Node.t 14466 2008-02-04 05:15:58Z bosborne $
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 = 51;
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::IO;
38 my $verbose = 0;
39 $verbose = 1 if $DEBUG;
41 # tests for Graph's problematic articulation_points()
42 # As of 2/2008 this test suite is still not reliably passing -
43 # I run it 5 times and I'll get an error 1 out of 5:
44 # Can't locate object method "proteins" via package "Bio::Network::Node...
46 ok 1;
49 # read old DIP format
51 my $io = Bio::Network::IO->new(
52   -format => 'dip_tab',
53   -file   => Bio::Root::IO->catfile("t","data","tab1part.tab"),
54   -threshold => 0.6);
55 ok(defined $io);
56 ok my $g1 = $io->next_network();
58 my @nodes = $g1->articulation_points();
59 ok $#nodes, 12;
60 my $nodes = $g1->articulation_points();
61 ok $nodes, 13;
63 # test articulation_points, but first check that each Node
64 # in network exists as an object
66 $io = Bio::Network::IO->new
67 (-format => 'psi10',
68  -file   => Bio::Root::IO->catfile("t","data","bovin_small_intact.xml"));
69 my $g = $io->next_network();
71 @nodes = $g->nodes;
72 ok scalar @nodes, 23;
74 foreach my $node (@nodes) {
75         my @seqs = $node->proteins;
76         ok $seqs[0]->display_id;
79 # ($ap, $bc, $br) = $g->biconnectivity;
81 @nodes = $g->articulation_points;
82 ok scalar @nodes, 4; # OK, inspected in Cytoscape
84 my @eids = qw(Q29462 P16106 Q27954 P53619);
85 foreach my $node (@nodes) {
86         my @seqs = $node->proteins;
87         ok my $id = $seqs[0]->display_id;
88         ok grep /$id/, @eids;
91 # additional articulation_points tests
92 # arath_small-02.xml is PSI MI version 1.0
94 ok $io = Bio::Network::IO->new
95   (-format => 'psi10',
96         -file   => Bio::Root::IO->catfile("t", "data", "arath_small-02.xml"));
97 ok $g1 = $io->next_network();
98 ok $g1->nodes, 73;
99 ok $g1->interactions, 516;
100 @nodes = $g1->articulation_points;
101 ok scalar @nodes, 8;
103 for my $node (@nodes) {
104         for my $prot ($node->proteins) {
105                 ok $prot->display_id;
106         }
109 __END__