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

Bug in fwdpp::update_mutations #130

Closed molpopgen closed 6 years ago

molpopgen commented 6 years ago

A rare bug can be triggered in the following way:

  1. An extinct mutation exists at position i.
  2. An extant mutation also exists at position i.

The current implementation of update_mutations will see the first mutation's mcount as zero and remove the position from the lookup table. If the mutation rate is high enough, this position may be used again, violating an infinite-sites assumption.

The fact that this bug has been undetected until now implies that any effect it has on simulations' final states is extremely subtle. You'd need a lot of combinations of rare things happening, and for the combo to happen many times, to have a big effect.

Have to decide whether to fix this in update_mutations or in process_gametes. The latter is likely preferable, as the former is optional from a modeling perspective.