Bio-Phylo
view release on metacpan or search on metacpan
t/14-nexus.t view on Meta::CPAN
2 taxon_2,
3 taxon_3,
4 taxon_4,
5 taxon_5;
TREE Default_ladder = (1,(2,(3,(4,5))));
TREE Default_bush = (1,2,3,4,5);
TREE Default_symmetrical = ((1,2),(3,(4,5)));
END;
TESTPARSE_BAD
;
# this string holds a taxa block with a bad ntax specification
my $testparse_taxa_bad = <<TESTPARSE_TAXA_BAD
#NEXUS
[written Wed Jun 08 00:30:00 CEST 2005 by Mesquite version 1.02+ (build g8)]
BEGIN TAXA;
DIMENSIONS NTAX=6;
TAXLABELS
taxon_1 taxon_2 taxon_3 taxon_4 taxon_5
;
END;
TESTPARSE_TAXA_BAD
;
my $bayes_phylogenies_tree_block = <<BAYES_PHYLOGENIES
#NEXUS
begin trees;
translate
0 Uria_aalge,
1 Uria_lomvia,
2 Alca_torda,
3 Brachyramphus_marmoratus_perdix,
4 Brachyramphus_brevirostris,
5 Brachyramphus_marmoratus_marmoratus,
6 Alle_alle,
7 Fratercula_cirrhata,
8 Cerorhinca_monocerata,
9 Fratercula_arctica,
10 Fratercula_corniculata,
11 Ptychoramphus_aleuticus,
12 Aethia_cristatella,
13 Aethia_pygmaea,
14 Aethia_pusilla,
15 Cyclorrhynchus_psittacula,
16 Cepphus_grylle,
17 Cepphus_carbo,
18 Cepphus_columba,
19 Synthliboramphus_craveri,
20 Synthliboramphus_hypoleucus,
21 Synthliboramphus_antiquus,
22 Synthliboramphus_wumizusume,
23 Podiceps_cristatus,
24 Pygoscelis_papua,
25 Pygoscelis_antarctica,
26 Pygoscelis_adeliae,
27 Aptenodytes_forsteri,
28 Aptenodytes_patagonicus,
29 Eudyptula_minor,
30 Spheniscus_humboldti,
31 Spheniscus_mendiculus,
32 Spheniscus_magellanicus,
33 Spheniscus_demersus,
34 Megadyptes_antipodes,
35 Eudyptes_pachyrhynchus,
36 Eudyptes_chrysocome,
37 Eudyptes_chrysolophus,
38 Eudyptes_sclateri;
tree tree.0.16248.085507 = (((((1:0.0252829964,((37:0.0923922678,36:0.0227291363):0.0214856938,(30:0.0985772880,0:0.0009462633):0.0085211709):0.0179755543):0.0205001767,(7:0.0424374264,((9:0.0669529421,14:0.0573991137):0.0739853752,((20:0.067712522...
end;
BAYES_PHYLOGENIES
;
my $bayes_phylogenies_newick =
'(((((Uria_lomvia:0.025283,((Eudyptes_chrysolophus:0.0923923,Eudyptes_chrysocome:0.0227291):0.0214857,(Spheniscus_humboldti:0.0985773,Uria_aalge:0.000946263):0.00852117):0.0179756):0.0205002,(Fratercula_cirrhata:0.0424374,((Fratercula_arctica:0.06695...
################################################################################
################################################################################
################################################################################
################################################################################
# Done defining nexus tokens, let's try to parse them.
print "--------------------------------------------------------------------\n";
eval { parse( '-format' => 'nexus', '-string' => $testparse ) };
if ($@) {
print $@->trace->as_string;
die $@;
}
ok( parse( '-format' => 'nexus', '-string' => $testparse ), '1 good parse' );
print "--------------------------------------------------------------------\n";
ok( parse( '-format' => 'nexus', '-string' => $testparse_trees ),
'2 tree block' );
print "--------------------------------------------------------------------\n";
eval { parse( '-format' => 'nexus', '-string' => $testparse_taxa_bad ) };
ok( UNIVERSAL::isa( $@, 'Bio::Phylo::Util::Exceptions::BadFormat' ),
'3 bad ntax' );
print "--------------------------------------------------------------------\n";
eval { parse( '-format' => 'nexus', '-string' => $testparse_bad ) };
ok( UNIVERSAL::isa( $@, 'Bio::Phylo::Util::Exceptions::BadFormat' ),
'4 bad nchar' );
print "--------------------------------------------------------------------\n";
eval { parse( '-format' => 'nexus', '-file' => 'DOES_NOT_EXIST' ) };
ok( $@->isa('Bio::Phylo::Util::Exceptions::FileError'), '5 file error' );
my $bayes_phylogenies_nexus_tree = parse(
'-format' => 'nexus',
'-string' => $bayes_phylogenies_tree_block,
'-as_project' => 1,
)->get_forests->[0]->first;
my $bayes_phylogenies_newick_tree = parse(
'-format' => 'newick',
'-string' => $bayes_phylogenies_newick,
)->first;
ok(
$bayes_phylogenies_nexus_tree->calc_symdiff($bayes_phylogenies_newick_tree)
== 0,
'6 translate table starts at 0'
);
( run in 1.994 second using v1.01-cache-2.11-cpan-a9496e3eb41 )