1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: TreeIO.t 14580 2008-03-01 17:01:30Z cjfields $
9 test_begin(-tests => 24);
10 use_ok('Bio::TreeIO');
13 my $verbose = test_debug();
17 test_skip(-tests => 8, -requires_module => 'IO::String');
19 # test nexus tree parsing
20 my $treeio = Bio::TreeIO->new(-format => 'nexus',
22 -file => test_input_file('urease.tre.nexus'));
24 my $tree = $treeio->next_tree;
26 is($tree->id, 'PAUP_1');
27 is($tree->get_leaf_nodes, 6);
28 my ($node) = $tree->find_node(-id => 'Spombe');
29 is($node->branch_length,0.221404);
31 # test nexus MrBayes tree parsing
32 $treeio = Bio::TreeIO->new(-format => 'nexus',
33 -file => test_input_file('adh.mb_tree.nexus'));
35 $tree = $treeio->next_tree;
38 is($tree->id, 'rep.1');
39 is($tree->get_leaf_nodes, 54);
40 ($node) = $tree->find_node(-id => 'd.madeirensis');
41 is($node->branch_length,0.039223);
42 while ($tree = $treeio->next_tree) {
45 is($ct,13,'bug 2356');
50 # process no-newlined tree
51 my $treeio = Bio::TreeIO->new(-format => 'nexus',
53 -file => test_input_file('tree_nonewline.nexus'));
55 my $tree = $treeio->next_tree;
57 ok($tree->find_node('TRXHomo'));
60 # process trees with node IDs containing spaces
61 $treeio = Bio::TreeIO->new(-format => 'nexus',
63 -file => test_input_file('spaces.nex'));
65 $tree = $treeio->next_tree;
67 my @nodeids = ("'Allium drummondii'", "'Allium cernuum'",'A.cyaneum');
70 for my $node ($tree->get_leaf_nodes) {
71 is($node->id, shift @nodeids);
75 # process tree with names containing quoted commas
77 $tree = $treeio->next_tree;
79 @nodeids = ("'Allium drummondii, USA'", "'Allium drummondii, Russia'",'A.cyaneum');
82 for my $node ($tree->get_leaf_nodes) {
83 is($node->id, shift @nodeids);
87 # process tree with names containing quoted commas on one line
89 $tree = $treeio->next_tree;
91 @nodeids = ("'Allium drummondii, Russia'", "'Allium drummondii, USA'",'A.cyaneum');
94 for my $node ($tree->get_leaf_nodes) {
95 is($node->id, shift @nodeids);