1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: TreeIO.t 14580 2008-03-01 17:01:30Z cjfields $
10 test_begin(-tests => 24);
11 use_ok('Bio::TreeIO');
14 my $verbose = test_debug();
18 test_skip(-tests => 8, -requires_module => 'IO::String');
20 # test nexus tree parsing
21 my $treeio = Bio::TreeIO->new(-format => 'nexus',
23 -file => test_input_file('urease.tre.nexus'));
25 my $tree = $treeio->next_tree;
27 is($tree->id, 'PAUP_1');
28 is($tree->get_leaf_nodes, 6);
29 my ($node) = $tree->find_node(-id => 'Spombe');
30 is($node->branch_length,0.221404);
32 # test nexus MrBayes tree parsing
33 $treeio = Bio::TreeIO->new(-format => 'nexus',
34 -file => test_input_file('adh.mb_tree.nexus'));
36 $tree = $treeio->next_tree;
39 is($tree->id, 'rep.1');
40 is($tree->get_leaf_nodes, 54);
41 ($node) = $tree->find_node(-id => 'd.madeirensis');
42 is($node->branch_length,0.039223);
43 while ($tree = $treeio->next_tree) {
46 is($ct,13,'bug 2356');
51 # process no-newlined tree
52 my $treeio = Bio::TreeIO->new(-format => 'nexus',
54 -file => test_input_file('tree_nonewline.nexus'));
56 my $tree = $treeio->next_tree;
58 ok($tree->find_node('TRXHomo'));
61 # process trees with node IDs containing spaces
62 $treeio = Bio::TreeIO->new(-format => 'nexus',
64 -file => test_input_file('spaces.nex'));
66 $tree = $treeio->next_tree;
68 my @nodeids = ("'Allium drummondii'", "'Allium cernuum'",'A.cyaneum');
71 for my $node ($tree->get_leaf_nodes) {
72 is($node->id, shift @nodeids);
76 # process tree with names containing quoted commas
78 $tree = $treeio->next_tree;
80 @nodeids = ("'Allium drummondii, USA'", "'Allium drummondii, Russia'",'A.cyaneum');
83 for my $node ($tree->get_leaf_nodes) {
84 is($node->id, shift @nodeids);
88 # process tree with names containing quoted commas on one line
90 $tree = $treeio->next_tree;
92 @nodeids = ("'Allium drummondii, Russia'", "'Allium drummondii, USA'",'A.cyaneum');
95 for my $node ($tree->get_leaf_nodes) {
96 is($node->id, shift @nodeids);