1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: TreeIO.t,v 1.7 2001/11/24 21:12:06 jason Exp $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'
my $error = 0;
use strict;
BEGIN {
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
if( $@ ) {
use lib 't';
}
use Test;
plan tests => 10;
# eval { require XML::Parser::PerlSAX; };
# if( $@ ) {
# print STDERR "XML::Parser::PerlSAX not loaded. This means TreeIO::phyloxml test cannot be executed. Skipping\n";
# foreach ( 1..43 ) {
# skip(1,1);
# }
# $error = 1;
#
# }
}
if( $error == 1 ) {
exit(0);
}
use vars qw($FILE1 $FILE2);
$FILE1= 'testnewick.phylip';
$FILE2= 'testlarge.phy';
END {
unlink $FILE1;
unlink $FILE2;
}
use Bio::TreeIO;
use Bio::Root::IO;
my $verbose = $ENV{'BIOPERLDEBUG'};
ok(1);
my $treeio = new Bio::TreeIO(-verbose => $verbose,
-format => 'newick',
-file => Bio::Root::IO->catfile('t','data',
'cysprot1b.newick'));
ok($treeio);
my $tree = $treeio->next_tree;
ok(ref($tree) && $tree->isa('Bio::Tree::TreeI'));
my @nodes = $tree->get_nodes;
ok(@nodes, 6);
if($verbose ) {
foreach my $node ( $tree->get_root_node()->each_Descendent() ) {
print "node: ", $node->to_string(), "\n";
my @ch = $node->each_Descendent();
if( @ch ) {
print "\tchildren are: \n";
foreach my $node ( $node->each_Descendent() ) {
print "\t\t ", $node->to_string(), "\n";
}
}
}
}
$treeio = new Bio::TreeIO(-verbose => $verbose,
-format => 'newick',
-file => ">$FILE1");
$treeio->write_tree($tree);
undef $treeio;
ok( -s $FILE1 );
$treeio = new Bio::TreeIO(-verbose => $verbose,
-format => 'newick',
-file => Bio::Root::IO->catfile('t','data',
'LOAD_Ccd1.dnd'));
ok($treeio);
$tree = $treeio->next_tree;
ok(ref($tree) && $tree->isa('Bio::Tree::TreeI'));
@nodes = $tree->get_nodes;
ok(@nodes, 52);
if($verbose ) {
foreach my $node ( @nodes ) {
print "node: ", $node->to_string(), "\n";
my @ch = $node->each_Descendent();
if( @ch ) {
print "\tchildren are: \n";
foreach my $node ( $node->each_Descendent() ) {
print "\t\t ", $node->to_string(), "\n";
}
}
}
}
ok($tree->total_branch_length, 7.12148);
$treeio = new Bio::TreeIO(-verbose => $verbose,
-format => 'newick',
-file => ">$FILE2");
$treeio->write_tree($tree);
undef $treeio;
ok(-s $FILE2);
|