File: Coalescent.t

package info (click to toggle)
bioperl 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 20,336 kB
  • ctags: 8,476
  • sloc: perl: 119,890; xml: 6,001; lisp: 121; makefile: 57
file content (73 lines) | stat: -rw-r--r-- 1,875 bytes parent folder | download | duplicates (2)
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
# -*-Perl-*-
# $Id: Coalescent.t,v 1.5 2003/12/16 01:12:34 jason Exp $
## Bioperl Test Harness Script for Modules
##

my $error;
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
    $error = 0; 
    eval { require Test; };
    if( $@ ) {
	use lib 't';
    }
    use Test;
    plan tests => 11;
}

use Bio::PopGen::Simulation::Coalescent;
use Bio::PopGen::Statistics;
use Bio::TreeIO;
ok(1);

use vars qw($FILE1);
$FILE1 = 'out.tre';
END { unlink $FILE1; }
 
my $ssize = 5;
my $sim = new Bio::PopGen::Simulation::Coalescent(-sample_size => $ssize);
my $stats = Bio::PopGen::Statistics->new();
my $tree = $sim->next_tree;

ok($tree->get_nodes, ($ssize * 2 - 1));

my $treeio = new Bio::TreeIO(-format => 'newick', -file => ">$FILE1");

$treeio->write_tree($tree);
undef $treeio;

ok(-s $FILE1);
my $mutcount = 100;
$sim->add_Mutations($tree, $mutcount);

my $leaves = [$tree->get_leaf_nodes];
# $stats->verbose(1);
my $pi = $stats->pi($leaves);
ok( $pi > 0 , 1, 'pi');


# theta is num seg sites / sum(1/(numsams-1))
my $theta = $stats->theta(scalar @$leaves, $mutcount);
ok($theta,48, 'theta');

my $tD = Bio::PopGen::Statistics->tajima_D($leaves);
ok(defined $tD,1, 'tajimaD');

my $seg_sites = Bio::PopGen::Statistics->segregating_sites_count($leaves);
ok($seg_sites,$mutcount,
   'all the mutations should be polymorphic (by definition)');
my $single = Bio::PopGen::Statistics->singleton_count($leaves);
my $flD = Bio::PopGen::Statistics->fu_and_li_D($leaves,$single);
ok(defined $flD,1,'fu and li D');

my $flD_star = $stats->fu_and_li_D_star($leaves);
ok(defined $flD_star,1,'fu and li D*');

my $flF = $stats->fu_and_li_F($leaves,$single);
ok(defined $flF, 1,'fu and li F');

my $flFstar = $stats->fu_and_li_F_star($leaves);
ok(defined $flF, 1,'fu and li F');