Skip to content

Commit

Permalink
fix bug looking for breakpoint at end iterator, fix test recombination;
Browse files Browse the repository at this point in the history
fix #27
  • Loading branch information
TheoPannetier committed Jun 14, 2024
1 parent 03c4799 commit 1f0283e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion DispersalTrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void DispersalTrait::inheritGenes(const bool& fromMother, QuantitativeTrait* par
// ----------------------------------------------------------------------------------------
void DispersalTrait::inheritDiploid(const bool& fromMother, map<int, vector<shared_ptr<Allele>>> const& parentGenes, set<unsigned int> const& recomPositions, int parentChromosome) {

const int lastPosition = parentGenes.rbegin()->first;
auto it = recomPositions.lower_bound(parentGenes.begin()->first);
int nextBreakpoint = *it;
// Is the first parent gene position already recombinant?
Expand All @@ -223,7 +224,13 @@ void DispersalTrait::inheritDiploid(const bool& fromMother, map<int, vector<shar
while (locus > nextBreakpoint) {
parentChromosome = 1 - parentChromosome;
std::advance(it, 1); // go to next recombination site
nextBreakpoint = *it;
if (it == recomPositions.end()) {
// no more recombinations
nextBreakpoint = lastPosition;
}
else {
nextBreakpoint = *it;
}
}

if (locus <= nextBreakpoint) {
Expand Down

0 comments on commit 1f0283e

Please sign in to comment.