New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / TreeBuild.t
blob683d2c8bcc4f2530964fb197a43254f564c42f5d
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
3 ## $Id$
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
8 my $error = 0;
10 use strict;
11 BEGIN {
12     # to handle systems with no installed Test module
13     # we include the t dir (where a copy of Test.pm is located)
14     # as a fallback
15     eval { require Test; };
16     if( $@ ) {
17         use lib 't';
18     }
20     use Test;
21     plan tests => 7;
24 if( $error == 1 ) {
25     exit(0);
28 my $debug = -1;
30 use Bio::Align::DNAStatistics;
31 use Bio::Align::ProteinStatistics;
32 use Bio::Align::Utilities qw(:all);
33 use Bio::AlignIO;
34 use Bio::Root::IO;
35 use Bio::Tree::DistanceFactory;
36 use Bio::TreeIO;
38 my $in = new Bio::AlignIO(-format => 'clustalw',
39                           -file   => Bio::Root::IO->catfile('t', 'data',
40                                                             'pep-266.aln'));
41 my $aln = $in->next_aln();
42 ok($aln);
43 my $pstats = new Bio::Align::ProteinStatistics(-verbose => $debug);
44 my $matrix = $pstats->distance(-method => 'Kimura',
45                                -align  => $aln);
46 ok($matrix);
48 my $treebuilder = Bio::Tree::DistanceFactory->new(-method => 'NJ');
49 my $tree = $treebuilder->make_tree($matrix);
50 ok($tree);
52 my ($cn) = $tree->find_node('183.m01790');
54 # brlens checked against tree generated by PHYLIP NJ
55 ok($tree->find_node('AN2438.1')->branch_length, '0.28221');
56 ok($tree->find_node('FG05298.1')->branch_length, '0.20593');
58 # simple topology test - make sure these 2 are sister
59 ok($tree->find_node('YOR262W')->ancestor->id, 
60    $tree->find_node('Smik_Contig1103.1')->ancestor->id);
62 # TODO 
63 # UPGMA tests
66 # test the bootstrap
67 my $replicates = &bootstrap_replicates($aln,10);
68 ok(scalar @$replicates, 10);