~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/Tree/Node.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: Node.t 15112 2008-12-08 18:12:38Z sendu $
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN { 
 
7
    use lib '.';
 
8
    use Bio::Root::Test;
 
9
    
 
10
    test_begin(-tests => 34);
 
11
        
 
12
        use_ok('Bio::Tree::Node');
 
13
        use_ok('Bio::Tree::AlleleNode');
 
14
}
 
15
 
 
16
my $node1 = Bio::Tree::Node->new();
 
17
my $node2 = Bio::Tree::Node->new();
 
18
ok($node1->is_Leaf() );
 
19
is($node1->ancestor, undef);
 
20
 
 
21
# tests for tags
 
22
ok ! $node1->has_tag('test');
 
23
is $node1->add_tag_value('test','a'), 1;
 
24
ok $node1->has_tag('test');
 
25
is $node1->add_tag_value('test','b'), 2;
 
26
my @tags = $node1->get_tag_values('test');
 
27
is scalar @tags, 2;
 
28
is scalar $node1->get_tag_values('test'), 'a', 'retrieve the first value';
 
29
 
 
30
is $node1->remove_tag('test2'), 0;
 
31
is $node1->remove_tag('test'), 1;
 
32
ok ! $node1->has_tag('test');
 
33
is $node1->set_tag_value('test',('a','b','c')), 3;
 
34
is $node1->remove_all_tags(), undef;
 
35
ok ! $node1->has_tag('test');
 
36
 
 
37
 
 
38
my $pnode = Bio::Tree::Node->new();
 
39
$pnode->add_Descendent($node1);
 
40
is($node1->ancestor, $pnode);
 
41
$pnode->add_Descendent($node2);
 
42
is($node2->ancestor, $pnode);
 
43
 
 
44
ok(! $pnode->is_Leaf);
 
45
 
 
46
my $phylo_node = Bio::Tree::Node->new(-bootstrap => 0.25,
 
47
                                     -id => 'ADH_BOV',
 
48
                                     -desc => 'Taxon 1');
 
49
$node1->add_Descendent($phylo_node);
 
50
ok(! $node1->is_Leaf);
 
51
is($phylo_node->ancestor, $node1);
 
52
is($phylo_node->id, 'ADH_BOV');
 
53
is($phylo_node->bootstrap, 0.25);
 
54
is($phylo_node->description, 'Taxon 1');
 
55
 
 
56
is $phylo_node->ancestor($node2), $node2;
 
57
ok $node1->is_Leaf;
 
58
is my @descs = $node2->each_Descendent, 1;
 
59
is $descs[0], $phylo_node;
 
60
 
 
61
my $allele_node = Bio::Tree::AlleleNode->new();
 
62
$allele_node->add_Genotype(Bio::PopGen::Genotype->new(-marker_name => 'm1',
 
63
                                                     -alleles=>  [ 0 ]));
 
64
$allele_node->add_Genotype(Bio::PopGen::Genotype->new(-marker_name => 'm3',
 
65
                                                     -alleles=>  [ 1,1 ]));
 
66
$allele_node->add_Genotype(Bio::PopGen::Genotype->new(-marker_name => 'm4',
 
67
                                                     -alleles=>  [ 0,4 ]));
 
68
ok($allele_node);
 
69
my @mkrs = $allele_node->get_marker_names;
 
70
 
 
71
is(@mkrs, 3);
 
72
my ($m3) = $allele_node->get_Genotypes(-marker => 'm3');
 
73
is($m3->get_Alleles, 2);
 
74
my ($a1) = $allele_node->get_Genotypes(-marker => 'm1')->get_Alleles;
 
75
is($a1, 0);
 
76
 
 
77
my ($a2,$a3) = $allele_node->get_Genotypes(-marker => 'm4')->get_Alleles;
 
78
is($a2, 0);
 
79
is($a3, 4);