Package: discsim
Simulates the coalescent for populations evolving in a spatial
continuum under the extinction/recolonisation model. This
package is a specialisation of theercspackage, and provides a much more efficient method of
simulating the spatial coalescent for the disc model.
A very similar (but not identical) interface toercsis provided.The simulations
support:A sample ofnindividuals withmloci at arbitrary locations on a
torus of diameterL.A fixed recombination rate between pairs of adjacent loci.An arbitrary number of classes of event occuring at fixed
rates.Simulations in one and two dimensions.Access to the locations of ancestors at any time in the past.Simulations of the locations of all pedigree ancestors, as well
as the genetic ancestors.Thediscsimmodule supports Python 2 and 3.DocumentationHere’s a quick example for the impatient:import ercs
import discsim
sim = discsim.Simulator(10)
sim.sample = [None, (3, 2), (6, 4), (7, 0)]
sim.event_classes = [ercs.DiscEventClass(u=0.5, r=1)]
sim.run()
pi, tau = sim.get_history()Full documentation fordiscsimis available athttp://pythonhosted.org/discsim.InstallationQuick install for Debian/UbuntuIf you are running Debian or Ubuntu, this should get you up and running quickly:$ sudo apt-get install python-dev libgsl0-dev
$ sudo pip install ercs discsimFor Python 3, usepython3-devandpip3.General instructionsThediscsimmodule
depends on theGNU Scientific Library,
which must be installed before it can be built.
Fortunately, this is straightforward on most platforms. For example,
on Debian or Ubuntu use:$ sudo apt-get install libgsl0-devor on Fedora:$ sudo yum install gsl-develGSL is available on most packaging systems; if it is not available on your
platform, it can be installed from source.Thediscsimmodule also depends on theercsPython module, which
must also be installed, using the same methods as outlined below.Once GSL has been installed we can build thediscsimmodule using the
standard Pythonmethods. For
example, using pip we have$ sudo pip install discsimOr, we can manually download the package, unpack it and then run:$ python setup.py build
$ sudo python setup.py installMost of the time this will compile and install the module without difficulty.It is also possible to download the latest development version ofdiscsimfromgithub.Potential problemsOn platforms that GSL is not available as part of the native packaging
system (or GSL was installed locally because of non-root access)
there can be issues with finding the correct headers and libraries
when compilingercsanddiscsim. For example, on FreeBSD we get something
like this:$ python setup.py build
... [Messages cut for brevity] ...
_discsimmodule.c:515: error: 'sim_t' has no member named 'time'
_discsimmodule.c: In function 'Simulator_get_num_reproduction_events':
_discsimmodule.c:529: error: 'sim_t' has no member named 'num_reproduction_events'
_discsimmodule.c: In function 'Simulator_get_history':
_discsimmodule.c:743: error: 'sim_t' has no member named 'pi'
_discsimmodule.c:748: error: 'sim_t' has no member named 'tau'
_discsimmodule.c: In function 'Simulator_run':
_discsimmodule.c:789: error: 'sim_t' has no member named 'time'
error: command 'cc' failed with exit status 1This can be remedied by using thegsl-configprogram to set the
theLDFLAGSandCFLAGSenvironment variables to
their correct values:$ CFLAGS=`gsl-config --cflags` LDFLAGS=`gsl-config --libs` python setup.py buildTestsdiscsimprovides some test cases to ensure that the installation has gone smoothly.
It is a good idea to run these immediately after installation:$ python tests.pyTested platformsDiscsim has been successfully built and tested on the following platforms:Operating systemPlatformPythonCompilerDebian wheezyx86_642.7.3gcc 4.7.2Debian wheezyx86_643.2.3gcc 4.7.2Debian wheezyx862.7.3gcc 4.7.2Debian squeezeppc642.6.6gcc 4.4.5Debian squeezeppc643.1.3gcc 4.4.5Debian squeezex86_642.6.6gcc 4.4.5Debian squeezex86_643.1.3gcc 4.4.5FreeBSD 9.2x86_642.7.5gcc 4.2.1FreeBSD 9.2x86_643.3.2gcc 4.2.1Fedora 19x86_642.7.5gcc 4.8.1Fedora 19x86_643.3.2gcc 4.8.1SunOS 5.10SPARC3.3.2gcc 4.8.0