clean up XMFA parsing, allow spaces in parsing (ende++, from IRC)
[bioperl-live.git] / t / TreeStatistics.t
blob8f5540c22a850f89be024b59b035d03a0637dfbc
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: RandomTreeFactory.t 11525 2007-06-27 10:16:38Z sendu $
4 use strict;
6 BEGIN { 
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 13);
12     use_ok('Bio::TreeIO');
13     use_ok('Bio::Tree::Statistics');
17 use Data::Dumper;
18 my $in = Bio::TreeIO->new(-format => 'nexus',
19                           -file   => test_input_file('traittree.nexus'));
20 my $tree = $in->next_tree;
21 my $node = $tree->find_node(-id => 'N14');
24 my $stats = Bio::Tree::Statistics->new();
25 is $stats->cherries($tree), 8, 'cherries';
26 is $stats->cherries($tree, $node), 4, 'cherries';
28 # traits
29 my $key = $tree->add_trait(test_input_file('traits.tab'), 3);
30 is ($key, 'intermediate', 'read traits');
32 is $stats->ps($tree, $key), 5, 'parsimony score';
33 is $stats->ps($tree, $key, $node), 1, 'subtree parsimony score';
35 is $stats->ai($tree, $key), 0.628906, 'association index';
36 is $stats->ai($tree, $key, $node), 0.062500, 'subtree association index';
38 my $mc = $stats->mc($tree, $key);
39 is ($mc->{blue}, 2, 'monophyletic clade size');
40 is ($mc->{red}, 4, 'monophyletic clade size');
41 $node = $tree->find_node(-id => 'N10');
42 $mc = $stats->mc($tree, $key, $node);
43 is ($mc->{blue}, 2, 'monophyletic clade size');
44 is ($mc->{red}, 2, 'monophyletic clade size');