More tidying, remove , and so on
[bioperl-network.git] / t / IO_dip_tab.t
blob3a8589088854bab0458ee33cdcec9def57431442
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules
4 use strict;
6 BEGIN {
7         use Bio::Root::Test;
8         test_begin(-tests => 17,
9                            -requires_module => 'Graph');
11         use_ok('Bio::Network::IO');
12         use_ok('Bio::Seq');
15 my $verbose = test_debug();
18 # read new DIP format
20 my $io = Bio::Network::IO->new(
21     -format => 'dip_tab',
22     -file   => test_input_file("tab4part.tab"));
23 my $g1 = $io->next_network();
24 ok $g1->edges == 5;
25 ok $g1->vertices == 7;
27 # read old DIP format
29 $io = Bio::Network::IO->new(
30   -format => 'dip_tab',
31   -file   => test_input_file("tab1part.tab"),
32   -threshold => 0.6);
33 ok(defined $io);
34 ok $g1 = $io->next_network();
35 ok my $node = $g1->get_nodes_by_id('PIR:A64696');
36 my @proteins = $node->proteins;
37 ok $proteins[0]->accession_number, 'PIR:A64696';
38 my %ids = $g1->get_ids_by_node($node);
39 my $x = 0;
40 my @ids = qw(A64696 2314583 3053N);
41 for my $k (keys %ids) {
42         ok $ids{$k} eq $ids[$x++];
45 # test write to filehandle...
47 my $out_file = test_output_file();
48 my $out =  Bio::Network::IO->new(
49   -format => 'dip_tab',
50   -file   => ">".$out_file);
51 ok(defined $out);
52 ok $out->write_network($g1);
54 # can we round trip, is the output the same as original format?
56 my $io2 = Bio::Network::IO->new(
57   -format   => 'dip_tab',
58   -file     => $out_file);
59 ok defined $io2;
60 ok      my $g2 = $io2->next_network();
61 ok $node = $g2->get_nodes_by_id('PIR:A64696');
62 @proteins = $node->proteins;
63 ok $proteins[0]->accession_number eq 'PIR:A64696';
65 __END__