Code optimization. Can force a skip ISA checking for small speed boost
[bioperl-live.git] / t / TreeBuild.t
blob85d15633efd0b0c7c403717f15ee1aff86006c21
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 13);
11         
12         for my $mod ( qw(Bio::Align::DNAStatistics
13                                          Bio::Align::ProteinStatistics
14                                          Bio::Align::Utilities
15                                          Bio::AlignIO
16                                          Bio::Tree::DistanceFactory
17                                          Bio::TreeIO) ) {
18                 use_ok($mod);
19     }
22 my $debug = test_debug();
24 use Bio::Align::Utilities qw(:all);
26 my $in = Bio::AlignIO->new(-format => 'clustalw',
27                           -file   => test_input_file('pep-266.aln'));
28 my $aln = $in->next_aln();
29 isa_ok($aln, 'Bio::SimpleAlign','SimpleAlign object parsed out');
30 my $pstats = Bio::Align::ProteinStatistics->new(-verbose => $debug);
31 my $matrix = $pstats->distance(-method => 'Kimura',
32                                -align  => $aln);
33 isa_ok($matrix,'Bio::Matrix::MatrixI','Protein distance matrix retrieved');
35 my $treebuilder = Bio::Tree::DistanceFactory->new(-method => 'NJ');
36 my $tree = $treebuilder->make_tree($matrix);
37 isa_ok($tree,'Bio::Tree::TreeI', 'Tree object gotten back');
39 my ($cn) = $tree->find_node('183.m01790');
41 # brlens checked against tree generated by PHYLIP NJ
42 is($tree->find_node('AN2438.1')->branch_length, '0.28221','NJ calculated Branch length');
43 is($tree->find_node('FG05298.1')->branch_length, '0.20593','NJ calculated Branch length');
45 # simple topology test - make sure these 2 are sister
46 is($tree->find_node('YOR262W')->ancestor->id, 
47    $tree->find_node('Smik_Contig1103.1')->ancestor->id, 'Make sure two nodes are sister');
49 # TODO?
50 # UPGMA tests
53 # test the bootstrap
54 my $replicates = &bootstrap_replicates($aln,10);
55 is(scalar @$replicates, 10,'10 replicates formulated');