molpopgen / fwdpp

fwdpp is a C++ template library for implementing efficient forward-time population genetic simulations
http://fwdpp.readthedocs.io
GNU General Public License v3.0
27 stars 11 forks source link

Make multi-locus/region API for recombination more flexible #48

Closed molpopgen closed 7 years ago

molpopgen commented 7 years ago

The current scheme for multi-locus evolution requires the following:

  1. A const double * representing between-locus recombination rates
  2. A single "between-locus recombination function".

The between locus recombination function would typically have one of the two following forms:

//No. x-overs b/w loci i and i+1 are Poisson-distributed
[](const gsl_rng * r, const double d)
{
return gsl_ran_poisson(r,d);
}

or

//Loci i and i+1 are d cM apart
[](const gsl_rng * r, const double d)
{
return gsl_ran_binomial(r,d,1);
}

Ideally, one should be able to mix these types of processes.

The proposal is that the API get reduced to take a single argument of the following type:

std::vector<std::function<unsigned(void)>>;

This change would allow much more flexibility. For example, we can have a 3-locus system with two tightly-linked and one unlinked locus:

std::vector<std::function<unsigned(void)>> interlocus_rec{
std::bind(gsl_ran_poisson,r,1e-5), 
std::bind(gsl_ran_binomial,r,0.5,1)
};
molpopgen commented 7 years ago

Addressed in 0.5.6