~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to t/PopGen/Coalescent.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: Coalescent.t 15112 2008-12-08 18:12:38Z sendu $
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN { 
 
7
    use lib '.';
 
8
        use Bio::Root::Test;
 
9
        
 
10
        test_begin(-tests => 13);
 
11
        
 
12
        use_ok('Bio::PopGen::Simulation::Coalescent');
 
13
        use_ok('Bio::PopGen::Statistics');
 
14
        use_ok('Bio::TreeIO');
 
15
}
 
16
 
 
17
my $ssize = 5;
 
18
my $sim = Bio::PopGen::Simulation::Coalescent->new(-sample_size => $ssize);
 
19
my $stats = Bio::PopGen::Statistics->new();
 
20
my $tree = $sim->next_tree;
 
21
 
 
22
is($tree->get_nodes, ($ssize * 2 - 1));
 
23
 
 
24
my $FILE1 = test_output_file();
 
25
my $treeio = Bio::TreeIO->new(-format => 'newick', -file => ">$FILE1");
 
26
 
 
27
$treeio->write_tree($tree);
 
28
undef $treeio;
 
29
 
 
30
ok(-s $FILE1);
 
31
my $mutcount = 100;
 
32
$sim->add_Mutations($tree, $mutcount);
 
33
 
 
34
my $leaves = [$tree->get_leaf_nodes];
 
35
# $stats->verbose(1);
 
36
my $pi = $stats->pi($leaves);
 
37
is( $pi > 0 , 1, 'pi');
 
38
 
 
39
 
 
40
# theta is num seg sites / sum(1/(numsams-1))
 
41
my $theta = $stats->theta(scalar @$leaves, $mutcount);
 
42
is($theta,48, 'theta');
 
43
 
 
44
my $tD = Bio::PopGen::Statistics->tajima_D($leaves);
 
45
is(defined $tD,1, 'tajimaD');
 
46
 
 
47
my $seg_sites = Bio::PopGen::Statistics->segregating_sites_count($leaves);
 
48
is($seg_sites,$mutcount,
 
49
   'all the mutations should be polymorphic (by definition)');
 
50
my $single = Bio::PopGen::Statistics->singleton_count($leaves);
 
51
my $flD = Bio::PopGen::Statistics->fu_and_li_D($leaves,$single);
 
52
is(defined $flD,1,'fu and li D');
 
53
 
 
54
my $flD_star = $stats->fu_and_li_D_star($leaves);
 
55
is(defined $flD_star,1,'fu and li D*');
 
56
 
 
57
my $flF = $stats->fu_and_li_F($leaves,$single);
 
58
is(defined $flF, 1,'fu and li F');
 
59
 
 
60
my $flFstar = $stats->fu_and_li_F_star($leaves);
 
61
is(defined $flF, 1,'fu and li F');