[Avida-SVN] r3469 - development/source/main
dk at myxo.css.msu.edu
dk at myxo.css.msu.edu
Tue Oct 13 13:07:30 PDT 2009
Author: dk
Date: 2009-10-13 16:07:30 -0400 (Tue, 13 Oct 2009)
New Revision: 3469
Modified:
development/source/main/cPopulationInterface.cc
Log:
Added HGT replace option.
Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc 2009-10-13 19:24:33 UTC (rev 3468)
+++ development/source/main/cPopulationInterface.cc 2009-10-13 20:07:30 UTC (rev 3469)
@@ -659,9 +659,14 @@
// insertion: insert the fragment at the final location of the match:
offspring.Insert(ssm.position, *f);
} else {
- // replacement is more complicated... for now, disallow it.
- assert(false);
- // offspring.Replace(std::max(ssm.position-f->GetSize(), 0), f->GetSize(), *f); // pos, number of sites to replace, genom
+ // replacement: replace up to fragment size instructions in the genome.
+
+ // replacement counts forward, so let's get the starting index of where the
+ // fragment needs to go. *inclusive* of the final match position (so +1), and
+ // a floor at 0.
+ int start = std::max(ssm.position-f->GetSize()+1, 0);
+
+ offspring.Replace(start, ssm.position-start+1, *f);
}
// resource utilization, cleanup, and stats tracking:
More information about the Avida-cvs
mailing list