version increase for final release, improved warning
[bioperl-network.git] / t / Node.t
blob3e832a54943a2f3737791cafb7fb24cc0ec28da8
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 = 30;
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::ProteinNet;
37 require Bio::Network::Node;
38 require Bio::Seq;
40 my $verbose = 0;
41 $verbose = 1 if $DEBUG;
43 ok 1;
45 my $seq1 = Bio::Seq->new(-seq => "aaaaaaa",-display_id => 1);
46 my $seq2 = Bio::Seq->new(-seq => "ttttttt",-display_id => 2);
47 my $seq3 = Bio::Seq->new(-seq => "ggggggg",-display_id => 3);
50 # 1 protein
52 my $node = Bio::Network::Node->new(-protein => $seq1);
53 ok $node->is_complex, 0;
54 my $count = $node->proteins;
55 ok $count, 1;
57 my @proteins = $node->proteins;
58 ok $proteins[0]->seq, "aaaaaaa";
59 ok $proteins[0]->display_id, 1;
60 ok $node->subunit_number($proteins[0]), undef;
61 $node->subunit_number($proteins[0],52);
62 ok $node->subunit_number($proteins[0]), 52;
65 # 1 or more proteins, but no subunit composition
67 $node = Bio::Network::Node->new(-protein => [($seq1,$seq2,$seq3)]);
68 ok $node->is_complex, 1;
69 @proteins = $node->proteins;
70 my $x = 0;
71 my @seqs = qw(aaaaaaa ggggggg ttttttt);
72 for my $protein (@proteins) {
73         ok $protein->seq, $seqs[$x++];
74         ok $node->subunit_number($protein), undef;
76 $count = $node->proteins;
77 ok $count, 3;
79 $node = Bio::Network::Node->new(-protein => [($seq1)]);
80 ok $node->is_complex, 0;
83 # 1 or more proteins, specifying subunit composition
85 $node = Bio::Network::Node->new(-protein => [ [($seq1, 2) ],
86                                                                                                                   [ ($seq2, 3) ],
87                                                                                                                   [ ($seq3, 1)] ]);
88 ok $node->is_complex, 1;
89 @proteins = $node->proteins;
90 $x = 0;
91 @seqs = qw(aaaaaaa ggggggg ttttttt);
92 my @nums = (2,1,3);
93 for my $protein (@proteins) {
94         ok $protein->seq, $seqs[$x];
95         ok $node->subunit_number($protein), $nums[$x++];
97 $count = $node->proteins;
98 ok $count, 3;
100 $node = Bio::Network::Node->new(-protein => [ [($seq3, 1)] ]);
101 ok $node->is_complex, 0;
102 ok $node->proteins, 1;
104 $node = Bio::Network::Node->new(-protein => [ [($seq3, 1)],
105                                                                                                                   [($seq2, 1)] ] );
106 ok $node->is_complex, 1;
107 ok $node->proteins, 2;
108 $node->is_complex(0);
109 ok $node->is_complex, 0;
111 $node->subunit_number($seq2,2);
112 ok $node->subunit_number($seq2), 2;
114 __END__