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

« back to all changes in this revision

Viewing changes to t/PopGenSims.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-*- mode for emacs
2
 
# $Id: PopGenSims.t,v 1.3 2003/10/25 14:52:22 heikki Exp $
3
 
 
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
7
 
 
8
 
my $error;
9
 
 
10
 
use vars qw($SKIPXML $LASTXMLTEST); 
11
 
use strict;
12
 
use lib '.';
13
 
 
14
 
BEGIN {     
15
 
    # to handle systems with no installed Test module
16
 
    # we include the t dir (where a copy of Test.pm is located)
17
 
    # as a fallback
18
 
    eval { require Test; };
19
 
    if( $@ ) {
20
 
        use lib 't';
21
 
    }
22
 
    use vars qw($NTESTS);
23
 
    $NTESTS = 22;
24
 
    $error = 0;
25
 
 
26
 
    use Test;
27
 
    plan tests => $NTESTS; 
28
 
 
29
 
}
30
 
 
31
 
if( $error == 1 ) {
32
 
    exit(0);
33
 
}
34
 
 
35
 
 
36
 
use Bio::PopGen::Simulation::GeneticDrift;
37
 
 
38
 
my $sim = new Bio::PopGen::Simulation::GeneticDrift(-popsize => 40,
39
 
                                                    -alleles => {A => 0.2,
40
 
                                                                 B => 0.8});
41
 
 
42
 
my (@Afreqs,@Bfreqs);
43
 
for(my $i =0 ;$i < 10; $i++ ) {
44
 
    my %f = $sim->next_generation;
45
 
    push @Afreqs, $f{'A'};
46
 
    push @Bfreqs, $f{'B'};
47
 
    ok(($f{'A'}||0) + ($f{'B'}||0), 1, 'Allele freqs should sum to 1');
48
 
}
49
 
 
50
 
ok(@Afreqs, 10);
51
 
ok(($Afreqs[9]||0) <= 1, 1, 'All frequencies should be <= 1');
52
 
 
53
 
$sim = new Bio::PopGen::Simulation::GeneticDrift(-popsize => 50,
54
 
                                                 -alleles => {A => 0.2,
55
 
                                                              B => 0.3,
56
 
                                                              C => 0.5,
57
 
                                                          });
58
 
 
59
 
for(my $i =0 ;$i < 10; $i++ ) {
60
 
    my %f = $sim->next_generation;
61
 
    ok(($f{'A'}||0) + ($f{'B'}||0) + ($f{'C'}||0), 1, 'Allele freqs should sum to 1');
62
 
}