ModuleBuildBioperl -> Bio::Root::Build
[bioperl-network.git] / t / IO_psi10.t
blob51aa92faa83922f6336bcde3e589bbd24f7b9602
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules#
3 # $Id$
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 = 21;
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 => 'psi10',
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 => 'psi10',
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 # there was an intermittent bug in articulation_points() here
88 # but not in the invocation above, this appears to be fixed
89 # in Graph v. .86
90 @rts = $g1->articulation_points;
91 ok scalar @rts, 1;
92 @proteins = $rts[0]->proteins;
93 $seq = $proteins[0];
94 ok $seq->desc,"Erythropoietin receptor precursor";
97 # GO terms
99 $n = $g1->get_nodes_by_id("EBI-474016");
100 @proteins = $n->proteins;
103 # PSI XML from HPRD
105 ok $io = Bio::Network::IO->new
106   (-format => 'psi10',
107         -file   => Bio::Root::IO->catfile("t", "data", "00001.xml"));
108 # ok $g1 = $io->next_network(); 
109 # The individual files from HPRD are not standard PSI, problems parsing them
111 __END__