{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import os\n", "from Bio.PopGen import SimCoal as simcoal\n", "from Bio.PopGen.SimCoal.Template import generate_simcoal_from_template\n", "from Bio.PopGen.SimCoal.Controller import FastSimCoalController as fsc" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/tra/anaconda3/envs/book2/lib/python2.7/site-packages/Bio/PopGen/SimCoal/data\n", "['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']\n" ] } ], "source": [ "print(simcoal.builtin_tpl_dir)\n", "print(os.listdir(simcoal.builtin_tpl_dir))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['//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']\n" ] } ], "source": [ "f = open(simcoal.builtin_tpl_dir + os.sep + 'simple.par')\n", "print(f.readlines())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Genome" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "n_indep_MSATs = [(200, [('MICROSAT', [1, 0, 0.005, 0, 0])])] # refer fastsimcoal documentation\n", "linked_snps = [(1, [('SNP', [200, 0.0005, 0.01])])]\n", "linked_DNA = [(1, [('DNA', [1000, 0.0005, 0.0000002, 0.33])])]\n", "complex_genome = [(2, [\n", " ('DNA', [10, 0.00001, 0.00005, 0.33]),\n", " ('SNP', [1, 0.001, 0.0001]),\n", " ('MICROSAT', [1, 0.0, 0.001, 0.0, 0.0])])]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Demography" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simple = [('sample_size', [30]),\n", " ('pop_size', [100, 200])]\n", "island = [('sample_size', [30]),\n", " ('pop_size', [100]),\n", " ('mig', [0.01]),\n", " ('total_demes', [10])]\n", "split_ssm_1d = [('sample_size', [30]),\n", " ('pop_size', [100]),\n", " ('mig', [0.01]),\n", " ('ne', [500]),\n", " ('t', [100]),\n", " ('total_demes', [10])]\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "generate_simcoal_from_template('island', complex_genome, island)\n", "generate_simcoal_from_template('simple', n_indep_MSATs, simple)\n", "generate_simcoal_from_template('split_ssm_1d', linked_snps, split_ssm_1d)\n", "#careful with overidding parameter files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running fastsimcoal" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ctrl = fsc(bin_name='fsc252')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ctrl.run_fastsimcoal('simple_100_30.par', 10)\n", "ctrl.run_fastsimcoal('simple_200_30.par', 10)\n", "ctrl.run_fastsimcoal('island_10_0.01_100_30.par', 10)\n", "ctrl.run_fastsimcoal('split_ssm_1d_10_100_500_0.01_100_30.par', 10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }