Have minimal version for branch be 1.5.9 RC1, designate this as RC1
[bioperl-network.git] / t / Node.t
blob57bff952b762994d05d8cd8f08e6fb5a7ff9e095
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules
3 # $Id$
5 use strict;
7 BEGIN {
8         use Bio::Root::Test;
9         test_begin(-tests => 32,
10                            -requires_module => 'Graph');
12         use_ok('Bio::Network::ProteinNet');
13         use_ok('Bio::Network::Node');
14         use_ok('Bio::Seq');
17 my $verbose = test_debug();
19 my $seq1 = Bio::Seq->new(-seq => "aaaaaaa",-display_id => 1);
20 my $seq2 = Bio::Seq->new(-seq => "ttttttt",-display_id => 2);
21 my $seq3 = Bio::Seq->new(-seq => "ggggggg",-display_id => 3);
24 # 1 protein
26 my $node = Bio::Network::Node->new(-protein => $seq1);
27 ok $node->is_complex == 0;
28 my $count = $node->proteins;
29 ok $count == 1;
31 my @proteins = $node->proteins;
32 ok $proteins[0]->seq eq "aaaaaaa";
33 ok $proteins[0]->display_id == 1;
34 is $node->subunit_number($proteins[0]), undef;
35 $node->subunit_number($proteins[0],52);
36 ok $node->subunit_number($proteins[0]) == 52;
39 # 1 or more proteins, but no subunit composition
41 $node = Bio::Network::Node->new(-protein => [($seq1,$seq2,$seq3)]);
42 ok $node->is_complex == 1;
43 @proteins = $node->proteins;
44 my $x = 0;
45 my @seqs = qw(aaaaaaa ggggggg ttttttt);
46 for my $protein (@proteins) {
47         ok $protein->seq eq $seqs[$x++];
48         is $node->subunit_number($protein), undef;
50 $count = $node->proteins;
51 ok $count == 3;
53 $node = Bio::Network::Node->new(-protein => [($seq1)]);
54 ok $node->is_complex == 0;
57 # 1 or more proteins, specifying subunit composition
59 $node = Bio::Network::Node->new(-protein => [ [($seq1, 2) ],
60                                                                                                                   [ ($seq2, 3) ],
61                                                                                                                   [ ($seq3, 1)] ]);
62 ok $node->is_complex == 1;
63 @proteins = $node->proteins;
64 $x = 0;
65 @seqs = qw(aaaaaaa ggggggg ttttttt);
66 my @nums = (2,1,3);
67 for my $protein (@proteins) {
68         ok $protein->seq eq $seqs[$x];
69         ok $node->subunit_number($protein) == $nums[$x++];
71 $count = $node->proteins;
72 ok $count == 3;
74 $node = Bio::Network::Node->new(-protein => [ [($seq3, 1)] ]);
75 ok $node->is_complex == 0;
76 ok $node->proteins == 1;
78 $node = Bio::Network::Node->new(-protein => [ [($seq3, 1)],
79                                                                                                                   [($seq2, 1)] ] );
80 ok $node->is_complex == 1;
81 ok $node->proteins == 2;
82 $node->is_complex(0);
83 ok $node->is_complex == 0;
85 $node->subunit_number($seq2,2);
86 ok $node->subunit_number($seq2) == 2;
88 __END__