@@ -562,6 +562,11 @@ void testGenetics() {
562562 }
563563}
564564
565+ bool haveSameEmigD0Allele (const Individual& indA, const Individual& indB, const int & position, short whichHaplo = 0 ) {
566+ return indA.getTrait (E_D0)->getAlleleValueAtLocus (whichHaplo, position)
567+ == indB.getTrait (E_D0)->getAlleleValueAtLocus (whichHaplo, position);
568+ }
569+
565570void testIndividual () {
566571
567572 // Kernel-based transfer
@@ -580,7 +585,6 @@ void testIndividual() {
580585 // Count times c1 = A & B; c2 = B & C have same alleles
581586 // Assert c1 > c2
582587 {
583-
584588 Patch* pPatch = new Patch (0 , 0 );
585589 Cell* pCell = new Cell (0 , 0 , (intptr)pPatch, 0 );
586590
@@ -605,7 +609,23 @@ void testIndividual() {
605609 indFather.setUpGenes (pSpecies, 1.0 );
606610 Individual indChild = Individual (pCell, pPatch, 0 , 0 , 0 , 0.0 , false , 0 );
607611
608- indChild.inheritTraits (pSpecies, &indMother, &indFather, 1.0 ); cout << endl;
612+ indChild.inheritTraits (pSpecies, &indMother, &indFather, 1.0 );
613+
614+ int countRecombineTogetherAB = 0 ;
615+ int countRecombineTogetherAC = 0 ;
616+
617+ // for i in ...
618+ {
619+ bool hasInheritedA0 = haveSameEmigD0Allele (indChild, indMother, 0 );
620+ bool hasInheritedB0 = haveSameEmigD0Allele (indChild, indMother, 1 );
621+ bool hasInheritedC0 = haveSameEmigD0Allele (indChild, indMother, 2 );
622+
623+ countRecombineTogetherAB += (hasInheritedA0 && hasInheritedB0)
624+ || (!hasInheritedA0 && !hasInheritedB0);
625+ countRecombineTogetherAC += (hasInheritedA0 && hasInheritedC0)
626+ || (!hasInheritedA0 && !hasInheritedC0);
627+ }
628+ assert (countRecombineTogetherAB > countRecombineTogetherAC);
609629 }
610630}
611631
0 commit comments