In [1]:
import os
from Bio.PopGen import SimCoal as simcoal
from Bio.PopGen.SimCoal.Template import generate_simcoal_from_template
from Bio.PopGen.SimCoal.Controller import FastSimCoalController as fsc

In [2]:
print(simcoal.builtin_tpl_dir)
print(os.listdir(simcoal.builtin_tpl_dir))


/home/tra/anaconda3/envs/book2/lib/python2.7/site-packages/Bio/PopGen/SimCoal/data
['decline_split.par', 'split_ssm_2d.par', 'island.par', 'ssm_1d.par', 'ssm_2d.par', 'split_island.par', 'simple.par', 'decline_lambda.par', 'bottle.par', 'split_ssm_1d.par']

In [3]:
f = open(simcoal.builtin_tpl_dir + os.sep + 'simple.par')
print(f.readlines())


['//Parameters for the coalescence simulation program : simcoal.exe\r\n', '1 samples\r\n', '//Population effective sizes (number of genes 2*diploids)\r\n', '?pop_size\r\n', '//Samples sizes (number of genes 2*diploids)\r\n', '?sample_size\r\n', '//Growth rates\t: negative growth implies population expansion\r\n', '0\r\n', '//Number of migration matrices : 0 implies no migration between demes\r\n', '0\r\n', '//historical event: time, source, sink, migrants, new deme size, new growth rate, migration matrix index\r\n', '0 historical events\r\n']

Genome


In [4]:
n_indep_MSATs = [(200, [('MICROSAT', [1, 0, 0.005, 0, 0])])]  # refer fastsimcoal documentation
linked_snps = [(1, [('SNP', [200, 0.0005, 0.01])])]
linked_DNA = [(1, [('DNA', [1000, 0.0005,  0.0000002, 0.33])])]
complex_genome = [(2, [
    ('DNA', [10, 0.00001, 0.00005, 0.33]),
    ('SNP', [1, 0.001, 0.0001]),
    ('MICROSAT', [1, 0.0, 0.001, 0.0, 0.0])])]

Demography


In [5]:
simple = [('sample_size', [30]),
          ('pop_size', [100, 200])]
island = [('sample_size', [30]),
          ('pop_size', [100]),
          ('mig', [0.01]),
          ('total_demes', [10])]
split_ssm_1d = [('sample_size', [30]),
                ('pop_size', [100]),
                ('mig', [0.01]),
                ('ne', [500]),
                ('t', [100]),
                ('total_demes', [10])]

In [6]:
generate_simcoal_from_template('island', complex_genome, island)
generate_simcoal_from_template('simple', n_indep_MSATs, simple)
generate_simcoal_from_template('split_ssm_1d', linked_snps, split_ssm_1d)
#careful with overidding parameter files

Running fastsimcoal


In [8]:
ctrl = fsc(bin_name='fsc252')

In [10]:
ctrl.run_fastsimcoal('simple_100_30.par', 10)
ctrl.run_fastsimcoal('simple_200_30.par', 10)
ctrl.run_fastsimcoal('island_10_0.01_100_30.par', 10)
ctrl.run_fastsimcoal('split_ssm_1d_10_100_500_0.01_100_30.par', 10)

In [ ]: