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);
7 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
10 # to handle systems with no installed Test module
11 # we include the t dir (where a copy of Test.pm is located)
13 eval { require Test; };
20 plan tests => $NUMTESTS;
21 eval { require Graph; };
23 warn "Perl's Graph needed for the bioperl-network package, skipping tests";
29 foreach ( $Test::ntest..$NUMTESTS) {
30 skip("Missing dependencies. Skipping tests",1);
32 unlink "t/data/out.tab" if -e "t/data/out.tab";
35 exit 0 if $ERROR == 1;
37 require Bio::Network::IO;
40 $verbose = 1 if $DEBUG;
47 my $io = Bio::Network::IO->new(
49 -file => Bio::Root::IO->catfile("t","data","tab4part.tab"));
50 my $g1 = $io->next_network();
56 $io = Bio::Network::IO->new(
58 -file => Bio::Root::IO->catfile("t","data","tab1part.tab"),
61 ok $g1 = $io->next_network();
62 ok my $node = $g1->get_nodes_by_id('PIR:A64696');
63 my @proteins = $node->proteins;
64 ok $proteins[0]->accession_number, 'PIR:A64696';
65 my %ids = $g1->get_ids_by_node($node);
67 my @ids = qw(A64696 2314583 3053N);
68 for my $k (keys %ids) {
69 ok $ids{$k},$ids[$x++];
72 # test write to filehandle...
74 my $out = Bio::Network::IO->new(
76 -file => ">". Bio::Root::IO->catfile("t","data","out.tab"));
78 ok $out->write_network($g1);
80 # can we round trip, is the output the same as original format?
82 my $io2 = Bio::Network::IO->new(
84 -file => Bio::Root::IO->catfile("t","data","out.tab"));
86 ok my $g2 = $io2->next_network();
87 ok $node = $g2->get_nodes_by_id('PIR:A64696');
88 @proteins = $node->proteins;
89 ok $proteins[0]->accession_number, 'PIR:A64696';