Code optimization. Can force a skip ISA checking for small speed boost
[bioperl-live.git] / t / PopGenSims.t
blob9d3645c22f4b14c32adcfb031ee786aa375e8251
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 # This will outline tests for the population genetics simulation
5 # in the Bio::PopGen::Simulation namespace
6 # Coalescent has its own tests though in t/Coalescent.t
8 use strict;
10 BEGIN {     
11     use lib 't/lib';
12     use BioperlTest;
13     
14     test_begin(-tests => 23);
15         
16     use_ok 'Bio::PopGen::Simulation::GeneticDrift';
19 my $sim = Bio::PopGen::Simulation::GeneticDrift->new(-popsize => 40,
20                                                     -alleles => {A => 0.2,
21                                                                  B => 0.8});
23 my (@Afreqs,@Bfreqs);
24 for my $i (0..9) {
25     my %f = $sim->next_generation;
26     push @Afreqs, $f{'A'};
27     push @Bfreqs, $f{'B'};
28     is(($f{'A'}||0) + ($f{'B'}||0), 1, 'Allele freqs should sum to 1');
31 is(@Afreqs, 10);
32 cmp_ok (($Afreqs[9]||0), '<=', 1, 'All frequencies should be <= 1');
34 $sim = Bio::PopGen::Simulation::GeneticDrift->new(-popsize => 50,
35                                                  -alleles => {A => 0.2,
36                                                               B => 0.3,
37                                                               C => 0.5,
38                                                           });
40 for my $i (0..9) {
41     my %f = $sim->next_generation;
42     is(($f{'A'}||0) + ($f{'B'}||0) + ($f{'C'}||0), 1, 'Allele freqs should sum to 1');