File: PopGenSims.t

package info (click to toggle)
bioperl 1.6.924-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 50,776 kB
  • ctags: 11,412
  • sloc: perl: 175,865; xml: 27,565; lisp: 2,034; sh: 1,958; makefile: 19
file content (43 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (4)
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
# -*-Perl-*- Test Harness script for Bioperl
# $Id$

# This will outline tests for the population genetics simulation
# in the Bio::PopGen::Simulation namespace
# Coalescent has its own tests though in t/Coalescent.t

use strict;

BEGIN {     
    use lib '.';
    use Bio::Root::Test;
    
    test_begin(-tests => 23);
	
    use_ok 'Bio::PopGen::Simulation::GeneticDrift';
}

my $sim = Bio::PopGen::Simulation::GeneticDrift->new(-popsize => 40,
						    -alleles => {A => 0.2,
								 B => 0.8});

my (@Afreqs,@Bfreqs);
for my $i (0..9) {
    my %f = $sim->next_generation;
    push @Afreqs, $f{'A'};
    push @Bfreqs, $f{'B'};
    is(($f{'A'}||0) + ($f{'B'}||0), 1, 'Allele freqs should sum to 1');
}

is(@Afreqs, 10);
cmp_ok (($Afreqs[9]||0), '<=', 1, 'All frequencies should be <= 1');

$sim = Bio::PopGen::Simulation::GeneticDrift->new(-popsize => 50,
						 -alleles => {A => 0.2,
							      B => 0.3,
							      C => 0.5,
							  });

for my $i (0..9) {
    my %f = $sim->next_generation;
    is(($f{'A'}||0) + ($f{'B'}||0) + ($f{'C'}||0), 1, 'Allele freqs should sum to 1');
}