2 ## Bioperl Test Harness Script for Modules
8 test_begin(-tests => 19);
9 use_ok('Bio::Tools::Run::Phylo::Semphy');
13 my $alignfilename = test_input_file('semphy.seq');
14 my $treefilename = test_input_file('semphy.tree');
16 # object setup and testing
17 my $factory = Bio::Tools::Run::Phylo::Semphy->new(-quiet => 1, -z => '2.0', -H => 1, -jtt => 1, -S => 1);
19 isa_ok($factory, 'Bio::Tools::Run::Phylo::Semphy');
20 ok $factory->can('alphabet'), 'has a created method not in args';
21 is $factory->ratio, '2.0', 'ratio param was set via -z';
22 ok $factory->jtt, 'jtt switch was set';
24 is ($factory->program_dir, $ENV{'SEMPHYDIR'}, 'program_dir returned correct default');
25 is ($factory->program_name(), 'semphy', 'Correct exe default name');
27 # test the program itself
29 test_skip(-requires_executable => $factory,
31 use_ok('Bio::TreeIO');
32 my $tree_out_file = test_output_file();
33 my $to = Bio::TreeIO->new(-format => 'newick',
34 -file => ">$tree_out_file");
36 # run Semphy with an alignment
37 ok my $tree1 = $factory->run($alignfilename);
38 $to->write_tree($tree1);
40 # or with alignment object
41 use_ok('Bio::AlignIO');
42 my $ai = Bio::AlignIO->new(-file => $alignfilename);
43 my $bio_simplalign = $ai->next_aln;
44 ok my $tree2 = $factory->run($bio_simplalign);
45 $to->write_tree($tree2);
47 # you can supply an initial tree as well, which can be a newick tree file,
48 # Bio::Tree::Tree object...
49 my $ti = Bio::TreeIO->new(-file => $treefilename);
50 my $tree_obj = $ti->next_tree;
51 ok my $tree3 = $factory->run($bio_simplalign, $tree_obj);
52 $to->write_tree($tree3);
54 # ... or Bio::DB::Taxonomy object
55 my $expected_count = 3;
57 test_skip(-tests => 2, -requires_networking => 1);
59 use_ok('Bio::DB::Taxonomy');
60 my $bio_db_taxonomy = Bio::DB::Taxonomy->new(-source => 'entrez');
61 ok my $tree4 = $factory->run($bio_simplalign, $bio_db_taxonomy);
62 $to->write_tree($tree4);
68 my $expected_result = '(Cow:0.280119,((Baboon:0.035422,Human:0.080635):0.000213,(Rat:0.198658,Horse:0.642019):0.120910):0.074791,Semnopithecus_entellus:0.016396);';
70 open(my $res_fh, $tree_out_file);
76 is $_, $expected_result;
80 is $count, $expected_count;
81 if ($expected_count == 3) {