~ubuntu-branches/ubuntu/wily/bioperl-run/wily-proposed

« back to all changes in this revision

Viewing changes to t/PhastCons.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-09-03 11:00:03 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903110003-11of27rxner5vnl9
Tags: 1.6.1-1
* New upstream release.
* debian/patches/10-wrong-path-for-interpreter.patch: removed
  (fixed upstream).
* debian/watch updated (bioperl -> BioPerl).
* debian/rules refreshed with dh-make-perl 0.53.
  - Disabled installation of examples (removed upstream).
  - Removed the correction of file permission of Pise documentation
    (removed upstream).
  - Removed patching facilities (no patches anymore).
  - Disabled tests as I experience failures with t/Eponine.t despite
    this program is not installed.
* debian/copyright:
  - Removed vanity lines about debianization and debian copyright.
  - Incremented years to 2009.
  - Updated to latest experimentation of the machine-readable license summary.
* debian/control:
  - Incremented Standards-Version to reflect conformance on new Policy
    (dropped versionned build-dependancy on Perl).
  - Removed build-dependancy on quilt (no patches anymore).
  - Depend and Build-Depend on bioperl versions superior or equal to 1.6.0.
  - Build-depends on, and Recommdnes libalgorithm-diff-perl, libipc-run-perl,
    libio-string-perl and libxml-twig-perl, that are listed in DEPENDANCIES.
  - Build-depends on libarray-compare-perl and libtree-dagnode-perl
    (otherwise tests fail). 
  - Depend on amap-align instead of amap (Closes: #541274).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*-
 
2
## Bioperl Test Harness Script for Modules
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN {
 
7
    use Bio::Root::Test;
 
8
    test_begin(-tests => 181,
 
9
               -requires_modules => [qw(Clone)]);
 
10
    use_ok('Bio::Tools::Run::Phylo::Phast::PhastCons');
 
11
    use_ok('Bio::AlignIO');
 
12
    use_ok('Bio::TreeIO');
 
13
    use_ok('Bio::DB::Taxonomy');
 
14
 
 
15
}
 
16
 
 
17
# setup input files etc
 
18
my $alignfilename = test_input_file("apes.multi_fasta");
 
19
my $treefilename = test_input_file("apes.newick");
 
20
ok (-e $alignfilename, 'Found input alignment file');
 
21
ok (-e $treefilename, 'Found input tree file');
 
22
 
 
23
my $factory = Bio::Tools::Run::Phylo::Phast::PhastCons->new(-verbose => -1,
 
24
                                                            -quiet => 1,
 
25
                                                            '-expected-length' => 3,
 
26
                                                            Target_coverage => 0.286,
 
27
                                                            '--rho' => 0.01);
 
28
isa_ok($factory, 'Bio::Tools::Run::Phylo::Phast::PhastCons');
 
29
ok $factory->can('ignore_missing'), 'has a created method not in args';
 
30
is $factory->expected_length, 3, 'dashed parameter with internal dash was set';
 
31
ok ! $factory->can('Target_coverage'), "wrong-case method wasn't created";
 
32
is $factory->target_coverage, 0.286, 'dashless wrong-case parameter was set';
 
33
is $factory->C, 0.286, 'synonym installed and accessed primary value';
 
34
is $factory->rho, 0.01, 'double-dashed parameter was set';
 
35
 
 
36
# test default factory values
 
37
is ($factory->program_dir, $ENV{'PHASTDIR'}, 'program_dir returned correct default');
 
38
is ($factory->program_name(), 'phastCons', 'Correct exe default name');
 
39
 
 
40
# test the program itself
 
41
SKIP: {
 
42
    test_skip(-requires_executable => $factory,
 
43
              -tests => 166);
 
44
    
 
45
    # using filename input
 
46
    ok my @result1 = $factory->run($alignfilename, $treefilename), 'got results using filename input';
 
47
    
 
48
    # using SimpleAlign and Bio::Tree::Tree input
 
49
    my $alignio = Bio::AlignIO->new(-file => $alignfilename);
 
50
    my $aln = $alignio->next_aln;
 
51
    $aln->id('apes');
 
52
    my $treeio = Bio::TreeIO->new(-verbose => -1, -file => $treefilename);
 
53
    my $tree = $treeio->next_tree;
 
54
    ok my @result2 = $factory->run($aln, $tree), 'got results using object input';
 
55
    
 
56
    # using database to generate species tree
 
57
    my $tdb = Bio::DB::Taxonomy->new(-source => 'flatfile',
 
58
        -directory => test_output_dir(),
 
59
        -nodesfile => test_input_file('taxdump','nodes.dmp'),
 
60
        -namesfile => test_input_file('taxdump','names.dmp'));
 
61
    
 
62
    ok my @result3 = $factory->run($aln, $tdb), 'got results using db input';
 
63
    
 
64
    is_deeply \@result1, \@result2, 'results same for file and object input';
 
65
    is_deeply \@result1, \@result3, 'results same for file and db input';
 
66
    
 
67
    # test the results
 
68
    my @apes = qw(human chimpanzee Cross_river_gorilla orangutan common_gibbon crested_gibbon siamang mountain_gorilla Hoolock_gibbon silvery_gibbon);
 
69
    is @result1, 20, 'correct number of results';
 
70
    foreach my $expected (['apes.1', 10, 14], ['apes.2', 26, 30]) {
 
71
        foreach my $i (0..9) {
 
72
            my $feat = shift(@result1);
 
73
            isa_ok $feat, 'Bio::SeqFeature::Annotated';
 
74
            is $feat->seq_id, $apes[$i], 'correct seq_id';
 
75
            is $feat->source->value, 'phastCons', 'correct source';
 
76
            is ${[$feat->annotation->get_Annotations('Name')]}[0]->value, ${$expected}[0], 'correct feature name';
 
77
            is $feat->start, ${$expected}[1], 'correct feature start';
 
78
            is $feat->end, ${$expected}[2], 'correct feature end';
 
79
            is $feat->score, 6, 'correct feature score';
 
80
            is $feat->strand, 1, 'correct feature strand';
 
81
        }
 
82
    }
 
83
}