Skip to content

Commit d5fb483

Browse files
committed
fix #553, off-by-one bug in initializeRecombinationRateFromFile()
1 parent 196fdb5 commit d5fb483

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ development head (in the master branch):
3737
this is because you can't make a matrix containing NULLs, and Eidos doesn't have NA (which is what R uses in this case)
3838
add Duplicate command to the Edit command, command-D, useful for code editing; change Show Debugging Output to shift-command-D
3939
add "Show SLiMgui Color Scales" command to the Help menu in SLiMgui
40+
fix #553, an off-by-one bug in initializeRecombinationRateFromFile(); breaks backward compatibility, by fixing this bug
4041

4142

4243
version 5.0 (Eidos version 4.0):

core/slim_functions.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,18 +869,19 @@ R"V0G0N({
869869
870870
// We expect the first column to be start positions, not end positions.
871871
// The first value in that column therefore tells us whether the data
872-
// is zero-based or one-based; we require one or the other. There is
873-
// another -1 applied to the positions because we convert them from
874-
// start positions to end positions; each segment ends at the base
875-
// previous to the start of the next segment.
872+
// is zero-based or one-based; we require one or the other. Unlike in
873+
// initializeMutationRateFromFile(), there is no shift to translate from
874+
// starts to ends; a start of 8 (beginning a rate to the right of pos 8)
875+
// is the same as an end of 8 (ending the previous rate to the left of
876+
// position 8); in-between positions are confusing. See #553.
876877
base = ends[0];
877878
if ((base != 0) & (base != 1))
878879
stop(errbase + "the first position in the file must be 0 (for 0-based positions) or 1 (for 1-based positions).");
879880
880881
if (length(ends) == 1)
881882
ends = lastPosition; // only the first start position is present
882883
else
883-
ends = c(ends[1:(size(ends)-1)] - base - 1, lastPosition);
884+
ends = c(ends[1:(size(ends)-1)] - base, lastPosition);
884885
885886
initializeRecombinationRate(rates * scale, ends, sex);
886887
})V0G0N";

0 commit comments

Comments
 (0)