Bio::Tools::CodonTable and Bio::Tools::IUPAC: prepare with dzil.
[bioperl-live.git] / t / Align / TreeBuild.t
blobfdcdb297123ab3141fb8f1466044d32fb61b876a
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7     use Bio::Root::Test;
8     
9     test_begin(-tests => 13);
10         
11         for my $mod ( qw(Bio::Align::DNAStatistics
12                                          Bio::Align::ProteinStatistics
13                                          Bio::Align::Utilities
14                                          Bio::AlignIO
15                                          Bio::Tree::DistanceFactory
16                                          Bio::TreeIO) ) {
17                 use_ok($mod);
18     }
21 my $debug = test_debug();
23 use Bio::Align::Utilities qw(:all);
25 my $in = Bio::AlignIO->new(-format => 'clustalw',
26                           -file   => test_input_file('pep-266.aln'));
27 my $aln = $in->next_aln();
28 isa_ok($aln, 'Bio::SimpleAlign','SimpleAlign object parsed out');
29 my $pstats = Bio::Align::ProteinStatistics->new(-verbose => $debug);
30 my $matrix = $pstats->distance(-method => 'Kimura',
31                                -align  => $aln);
32 isa_ok($matrix,'Bio::Matrix::MatrixI','Protein distance matrix retrieved');
34 my $treebuilder = Bio::Tree::DistanceFactory->new(-method => 'NJ');
35 my $tree = $treebuilder->make_tree($matrix);
36 isa_ok($tree,'Bio::Tree::TreeI', 'Tree object gotten back');
38 my ($cn) = $tree->find_node('183.m01790');
40 # brlens checked against tree generated by PHYLIP NJ
41 is($tree->find_node('AN2438.1')->branch_length, '0.28221','NJ calculated Branch length');
42 is($tree->find_node('FG05298.1')->branch_length, '0.20593','NJ calculated Branch length');
44 # simple topology test - make sure these 2 are sister
45 is($tree->find_node('YOR262W')->ancestor->id, 
46    $tree->find_node('Smik_Contig1103.1')->ancestor->id, 'Make sure two nodes are sister');
48 # TODO?
49 # UPGMA tests
52 # test the bootstrap
53 my $replicates = &bootstrap_replicates($aln,10);
54 is(scalar @$replicates, 10,'10 replicates formulated');