tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / t / Tree / TreeIO / nexus.t
blob957e0ca7b9c1956572d900602e92f630159fe1c3
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: TreeIO.t 14580 2008-03-01 17:01:30Z cjfields $
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 24);
11     use_ok('Bio::TreeIO');
14 my $verbose = test_debug();
17 SKIP: {
18     test_skip(-tests => 8, -requires_module => 'IO::String');
19         
20     # test nexus tree parsing
21     my $treeio = Bio::TreeIO->new(-format => 'nexus',
22                                   -verbose => $verbose,
23                                   -file   => test_input_file('urease.tre.nexus'));
24     
25     my $tree = $treeio->next_tree;
26     ok($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);
31     
32     # test nexus MrBayes tree parsing
33     $treeio = Bio::TreeIO->new(-format => 'nexus',
34                                -file   => test_input_file('adh.mb_tree.nexus'));
35     
36     $tree = $treeio->next_tree;
37         my $ct = 1; 
38     ok($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) {
44                 $ct++;
45         }
46         is($ct,13,'bug 2356');
50 # bug #1854
51 # process no-newlined tree
52 my $treeio = Bio::TreeIO->new(-format => 'nexus',
53                               -verbose => $verbose,
54                               -file   => test_input_file('tree_nonewline.nexus'));
56 my $tree = $treeio->next_tree;
57 ok($tree);
58 ok($tree->find_node('TRXHomo'));
60 # bug #2205
61 # process trees with node IDs containing spaces
62 $treeio = Bio::TreeIO->new(-format => 'nexus',
63                            -verbose => $verbose,
64                            -file   => test_input_file('spaces.nex'));
66 $tree = $treeio->next_tree;
68 my @nodeids = ("'Allium drummondii'", "'Allium cernuum'",'A.cyaneum');
70 ok($tree);
71 for my $node ($tree->get_leaf_nodes) {
72         is($node->id, shift @nodeids);          
75 # bug #2221
76 # process tree with names containing quoted commas
78 $tree = $treeio->next_tree;
80 @nodeids = ("'Allium drummondii, USA'", "'Allium drummondii, Russia'",'A.cyaneum');
82 ok($tree);
83 for my $node ($tree->get_leaf_nodes) {
84         is($node->id, shift @nodeids);          
87 # bug #2221
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');
94 ok($tree);
95 for my $node ($tree->get_leaf_nodes) {
96         is($node->id, shift @nodeids);