-
Notifications
You must be signed in to change notification settings - Fork 0
/
SAIsimTest.py
70 lines (51 loc) · 2.4 KB
/
SAIsimTest.py
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
# Simulator script for testing SAI forward simulations with particular parameters
import SAIsim as sim
# Ensures a minimum of 1 female, 1 male
size = 100
# given 10^-8 SAmut/base/gen and
mutRate = .1
# Approximated by
mutRateInv = .1
# Deviation of normally distributed offset of mutation effects from [x,1-x], with x = uniform[0,1)
mutEffectDiffSD = .2
# Reasonable minimum length given that 1 distance unit on the chromosome = 1 Morgan
minInvLen = .1
# The expected # of crossovers per chromosome arm
# parameter = 1 gives 1 Morgan chromosome arm
recombRate = 1
# Must be <= pop size
encounterNum = 20
# SD for the normally distributed additive noise to male quality in the female choice
choiceNoiseSD = .5
# The probability per instance of heterozygosity that a gene undergoes conversion in a heterozygous gamete,
# which one is converted is selected at random, treated independently from number of crossover events
conversionRate = 10.0**-2.0
# Inversion record buffer represents how far from inversion edges to examine mutation effects
# CONSIDER making this a parameter of the record function (Doesn't really work as recording is simultaneous)
invRecBuffer = .1
# For genGenomesSexes
initMutList = [[0.5,0.95,0.1,0,40]]
initInvList = [[0.01,0.06,0,60]]
genomes = [[[[[],[]],[[],[]]]]]
sexes = ['F']
# For genGenoSexFromWholeGenHap
mutList = [[0.5,0.95,0.1,0],[0.04,0.45,0.45,0]]
invList = [[0.01,0.06,0]]
mut0 = [0.5,0.95,0.1,0]
mut1 = [0.04,0.45,0.45,1]
inv0 = [0.01,0.06,0]
hapList = [[[[[mut0,mut1],[inv0]]],6],[[[[mut0],[inv0]]],4]]
numGens = 500
# Now run the simulator session in length and recording intervals as desired using above parameters
# (genomes,sexes,record) = sim.genGenomesSexes(size,initMutList,initInvList,genomes=genomes,sexes=sexes)
(genomes,sexes,record) = sim.genGenoSexFromWholeGenHap(size,mutList,invList,hapList,genomes=genomes,sexes=sexes)
pop = sim.SAIpop(size, mutRate, mutRateInv, mutEffectDiffSD, minInvLen, conversionRate, recombRate,\
encounterNum, choiceNoiseSD, invRecBuffer, willMutate = False, willMutInv = False,\
noMaleCost = True, genomes=genomes,sexes=sexes,record=record)
# pop = sim.SAIpop(size, mutRate, mutRateInv, mutEffectDiffSD, minInvLen, conversionRate, recombRate,encounterNum, choiceNoiseSD, invRecBuffer)
# pop.stepNGens(numGens)
# pop.recordEveryNGens(10,200)
pop.recordNGens(numGens)
# pop.printGenomes()
# pop.printRecord()
pop.writeRecordTables('testOutput/Test1')