version increase for final release, improved warning
[bioperl-network.git] / t / IO_psi.t
blob76ec97767cc0753cdfe3acec6688902ab48ee94d
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 = 19;
20         plan tests => $NUMTESTS;
21         eval { require Graph; };
22         if ( $@ ) {
23                 warn("Graph required for graph creation and analysis, skipping tests");
24                 $ERROR = 1;
25         }
26         eval { require XML::Twig; };
27         if ($@) {
28                 warn "XML::Twig needed for XML format parsing, skipping tests";
29                 $ERROR = 1;
30         }
33 END {
34         foreach ( $Test::ntest..$NUMTESTS) {
35                 skip("Missing dependencies. Skipping tests",1);
36         }
39 exit 0 if $ERROR == 1;
41 require Bio::Network::IO;
43 my $verbose = 0;
44 $verbose = 1 if $DEBUG;
46 ok 1;
49 # PSI XML from DIP
51 ok my $io = Bio::Network::IO->new
52   (-format => 'psi',
53         -file   => Bio::Root::IO->catfile("t", "data", "psi_xml.dat"));
54 ok my $g1 = $io->next_network();
55 ok $g1->edge_count, 3;
56 ok $g1->node_count, 4;
57 ok $g1->is_connected,1;
58 my $n = $g1->get_nodes_by_id('O24853');
59 my @proteins = $n->proteins;
60 ok $proteins[0]->species->binomial('FULL'),"Helicobacter pylori 26695";
61 ok $proteins[0]->primary_seq->desc,"hypothetical HP0001";
62 my @rts = $g1->articulation_points;
63 ok scalar @rts,1; # correct, by inspection in Cytoscape
64 @proteins = $rts[0]->proteins;
65 my $seq = $proteins[0];
66 ok $seq->desc,"hypothetical HP0001"; # correct, by inspection in Cytoscape
69 # PSI XML from IntAct
71 ok $io = Bio::Network::IO->new
72   (-format => 'psi',
73         -file   => Bio::Root::IO->catfile("t", "data", "sv40_small.xml"));
74 ok $g1 = $io->next_network();
75 ok $g1->edge_count, 3;
76 ok $g1->node_count, 5;
77 ok $g1->is_connected, "";
79 $n = $g1->get_nodes_by_id("P03070");
80 @proteins = $n->proteins;
81 ok $proteins[0]->species->binomial('FULL'),"Simian virus 40";
82 ok $proteins[0]->primary_seq->desc,"Large T antigen";
84 my @components = $g1->connected_components;
85 ok scalar @components, 2;
87 # seems there's an intermittent bug in articulation_points() here
88 # but not in the invocation above
89 # @rts = $g1->articulation_points;
90 # ok scalar @rts, 1; # OK, inspected in Cytoscape
91 # @proteins = $rts[0]->proteins;
92 # $seq = $proteins[0];
93 # ok $seq->desc,"Erythropoietin receptor precursor"; # OK, inspected in Cytoscape
96 # GO terms
98 $n = $g1->get_nodes_by_id("EBI-474016");
99 @proteins = $n->proteins;
102 # PSI XML from HPRD
104 ok $io = Bio::Network::IO->new
105   (-format => 'psi',
106         -file   => Bio::Root::IO->catfile("t", "data", "00001.xml"));
107 # ok $g1 = $io->next_network(); 
108 # The individual files from HPRD are not standard PSI, problems parsing them
110 __END__