Skip to content

Commit 6c1a4f9

Browse files
committed
remove C++ selection_coeff_ and dominance_coeff_ ivars
1 parent 0629ef2 commit 6c1a4f9

26 files changed

Lines changed: 947 additions & 371 deletions

QtSLiM/QtSLiMChromosomeWidget_GL.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ void QtSLiMChromosomeWidget::glDrawMutations(QRect &interiorRect, Chromosome *ch
177177
static std::vector<const Mutation *> mutations;
178178
mutations.resize(0);
179179

180+
MutationBlock *mutation_block = displaySpecies->SpeciesMutationBlock();
181+
Mutation *mut_block_ptr = mutation_block->mutation_buffer_;
182+
180183
{
181184
int registry_size;
182185
const MutationIndex *registry = pop.MutationRegistry(&registry_size);
183-
Mutation *mut_block_ptr = displaySpecies->SpeciesMutationBlock()->mutation_buffer_;
184186
slim_chromosome_index_t chromosome_index = chromosome->Index();
185187

186188
for (int registry_index = 0; registry_index < registry_size; ++registry_index)
@@ -220,7 +222,10 @@ void QtSLiMChromosomeWidget::glDrawMutations(QRect &interiorRect, Chromosome *ch
220222
}
221223
else
222224
{
223-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
225+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
226+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
227+
228+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
224229
}
225230

226231
int height_adjust = mutationTickRect.height() - static_cast<int>(ceil((mutationRefCount / totalHaplosomeCount) * interiorRect.height()));
@@ -281,7 +286,10 @@ void QtSLiMChromosomeWidget::glDrawMutations(QRect &interiorRect, Chromosome *ch
281286
#pragma clang diagnostic push
282287
#pragma clang diagnostic ignored "-Wfloat-equal"
283288
// We do want to do an exact floating-point equality compare here; we want to see whether the mutation's selcoeff is unmodified from the fixed DFE
284-
if ((mutation->mutation_type_ptr_ == mut_type) && (mut_type_fixed_color || (mutation->selection_coeff_ == mut_type_selcoeff)))
289+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
290+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
291+
292+
if ((mutation->mutation_type_ptr_ == mut_type) && (mut_type_fixed_color || (mut_trait_info[0].effect_size_ == mut_type_selcoeff)))
285293
#pragma clang diagnostic pop
286294
#pragma GCC diagnostic pop
287295
{
@@ -369,7 +377,11 @@ void QtSLiMChromosomeWidget::glDrawMutations(QRect &interiorRect, Chromosome *ch
369377
int height_adjust = mutationTickRect.height() - static_cast<int>(ceil((mutationRefCount / totalHaplosomeCount) * interiorRect.height()));
370378

371379
mutationTickRect.setTop(mutationTickRect.top() + height_adjust);
372-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
380+
381+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
382+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
383+
384+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
373385

374386
SLIM_GL_DEFCOORDS(mutationTickRect);
375387
SLIM_GL_PUSHRECT();
@@ -421,8 +433,11 @@ void QtSLiMChromosomeWidget::glDrawMutations(QRect &interiorRect, Chromosome *ch
421433
mutationTickRect.setTop(mutationTickRect.top() + interiorRect.height() - barHeight);
422434

423435
const Mutation *mutation = mutationBuffer[binIndex];
424-
425-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
436+
437+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
438+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
439+
440+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
426441

427442
SLIM_GL_DEFCOORDS(mutationTickRect);
428443
SLIM_GL_PUSHRECT();
@@ -489,7 +504,8 @@ void QtSLiMChromosomeWidget::glDrawFixedSubstitutions(QRect &interiorRect, Chrom
489504
}
490505
else
491506
{
492-
RGBForSelectionCoeff(static_cast<double>(substitution->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
507+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
508+
RGBForSelectionCoeff(static_cast<double>(substitution->trait_info_[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
493509
}
494510
}
495511

@@ -568,7 +584,8 @@ void QtSLiMChromosomeWidget::glDrawFixedSubstitutions(QRect &interiorRect, Chrom
568584
}
569585
else
570586
{
571-
RGBForSelectionCoeff(static_cast<double>(substitution->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
587+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
588+
RGBForSelectionCoeff(static_cast<double>(substitution->trait_info_[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
572589
}
573590

574591
mutationTickRect.setX(interiorRect.x() + binIndex);

QtSLiM/QtSLiMChromosomeWidget_QT.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ void QtSLiMChromosomeWidget::qtDrawMutations(QRect &interiorRect, Chromosome *ch
173173
static std::vector<const Mutation *> mutations;
174174
mutations.resize(0);
175175

176+
MutationBlock *mutation_block = displaySpecies->SpeciesMutationBlock();
177+
Mutation *mut_block_ptr = mutation_block->mutation_buffer_;
178+
176179
{
177180
int registry_size;
178181
const MutationIndex *registry = pop.MutationRegistry(&registry_size);
179-
Mutation *mut_block_ptr = displaySpecies->SpeciesMutationBlock()->mutation_buffer_;
180182
slim_chromosome_index_t chromosome_index = chromosome->Index();
181183

182184
for (int registry_index = 0; registry_index < registry_size; ++registry_index)
@@ -216,7 +218,10 @@ void QtSLiMChromosomeWidget::qtDrawMutations(QRect &interiorRect, Chromosome *ch
216218
}
217219
else
218220
{
219-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
221+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
222+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
223+
224+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
220225
}
221226

222227
int height_adjust = mutationTickRect.height() - static_cast<int>(ceil((mutationRefCount / totalHaplosomeCount) * interiorRect.height()));
@@ -277,7 +282,10 @@ void QtSLiMChromosomeWidget::qtDrawMutations(QRect &interiorRect, Chromosome *ch
277282
#pragma clang diagnostic push
278283
#pragma clang diagnostic ignored "-Wfloat-equal"
279284
// We do want to do an exact floating-point equality compare here; we want to see whether the mutation's selcoeff is unmodified from the fixed DFE
280-
if ((mutation->mutation_type_ptr_ == mut_type) && (mut_type_fixed_color || (mutation->selection_coeff_ == mut_type_selcoeff)))
285+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
286+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
287+
288+
if ((mutation->mutation_type_ptr_ == mut_type) && (mut_type_fixed_color || (mut_trait_info[0].effect_size_ == mut_type_selcoeff)))
281289
#pragma clang diagnostic pop
282290
#pragma GCC diagnostic pop
283291
{
@@ -365,7 +373,11 @@ void QtSLiMChromosomeWidget::qtDrawMutations(QRect &interiorRect, Chromosome *ch
365373
int height_adjust = mutationTickRect.height() - static_cast<int>(ceil((mutationRefCount / totalHaplosomeCount) * interiorRect.height()));
366374

367375
mutationTickRect.setTop(mutationTickRect.top() + height_adjust);
368-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
376+
377+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
378+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
379+
380+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
369381

370382
SLIM_GL_DEFCOORDS(mutationTickRect);
371383
SLIM_GL_PUSHRECT();
@@ -417,8 +429,11 @@ void QtSLiMChromosomeWidget::qtDrawMutations(QRect &interiorRect, Chromosome *ch
417429
mutationTickRect.setTop(mutationTickRect.top() + interiorRect.height() - barHeight);
418430

419431
const Mutation *mutation = mutationBuffer[binIndex];
420-
421-
RGBForSelectionCoeff(static_cast<double>(mutation->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
432+
433+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
434+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mutation);
435+
436+
RGBForSelectionCoeff(static_cast<double>(mut_trait_info[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
422437

423438
SLIM_GL_DEFCOORDS(mutationTickRect);
424439
SLIM_GL_PUSHRECT();
@@ -485,7 +500,8 @@ void QtSLiMChromosomeWidget::qtDrawFixedSubstitutions(QRect &interiorRect, Chrom
485500
}
486501
else
487502
{
488-
RGBForSelectionCoeff(static_cast<double>(substitution->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
503+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
504+
RGBForSelectionCoeff(static_cast<double>(substitution->trait_info_[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
489505
}
490506
}
491507

@@ -564,7 +580,7 @@ void QtSLiMChromosomeWidget::qtDrawFixedSubstitutions(QRect &interiorRect, Chrom
564580
}
565581
else
566582
{
567-
RGBForSelectionCoeff(static_cast<double>(substitution->selection_coeff_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
583+
RGBForSelectionCoeff(static_cast<double>(substitution->trait_info_[0].effect_size_), &colorRed, &colorGreen, &colorBlue, scalingFactor);
568584
}
569585

570586
mutationTickRect.setX(interiorRect.x() + binIndex);

QtSLiM/QtSLiMHaplotypeManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ void QtSLiMHaplotypeManager::configureMutationInfoBuffer(Chromosome *chromosome)
481481
mutationPositions = static_cast<slim_position_t *>(malloc(sizeof(slim_position_t) * mutationIndexCount));
482482

483483
// Copy the information we need on each mutation in use
484-
Mutation *mut_block_ptr = graphSpecies->SpeciesMutationBlock()->mutation_buffer_;
484+
MutationBlock *mutation_block = graphSpecies->SpeciesMutationBlock();
485+
Mutation *mut_block_ptr = mutation_block->mutation_buffer_;
485486

486487
for (const MutationIndex *reg_ptr = registry; reg_ptr != reg_end_ptr; ++reg_ptr)
487488
{
@@ -493,6 +494,10 @@ void QtSLiMHaplotypeManager::configureMutationInfoBuffer(Chromosome *chromosome)
493494

494495
haplo_mut->position_ = mut_position;
495496
*(mutationPositions + mut_index) = mut_position;
497+
498+
// FIXME MULTITRAIT: should be a way to choose which trait is being used for colors in the chromosome view!
499+
MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation(mut);
500+
slim_effect_t selection_coeff = mut_trait_info[0].effect_size_;
496501

497502
if (!mut_type->color_.empty())
498503
{
@@ -502,10 +507,10 @@ void QtSLiMHaplotypeManager::configureMutationInfoBuffer(Chromosome *chromosome)
502507
}
503508
else
504509
{
505-
RGBForSelectionCoeff(static_cast<double>(mut->selection_coeff_), &haplo_mut->red_, &haplo_mut->green_, &haplo_mut->blue_, scalingFactor);
510+
RGBForSelectionCoeff(static_cast<double>(selection_coeff), &haplo_mut->red_, &haplo_mut->green_, &haplo_mut->blue_, scalingFactor);
506511
}
507512

508-
haplo_mut->neutral_ = (mut->selection_coeff_ == 0.0f);
513+
haplo_mut->neutral_ = (selection_coeff == 0.0f);
509514

510515
haplo_mut->display_ = mut_type->mutation_type_displayed_;
511516
}

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,8 @@
13271327
<p class="p6">The <span class="s1">Chromosome</span> object with which the mutation is associated.</p>
13281328
<p class="p5">dominance =&gt; (float)</p>
13291329
<p class="p6">The dominance coefficient(s) of the mutation, carried over from the original mutation object.<span class="Apple-converted-space">  </span>In a multi-trait model, this property provides the dominance coefficients for all of the traits (in the order in which the traits were defined).<span class="Apple-converted-space">  </span>For more control, see the <span class="s1">dominanceForTrait()</span> method.<span class="Apple-converted-space">  </span>Also note that dynamic properties are defined for each trait in the model; if there is a trait named <span class="s1">height</span>, for example, then <span class="s1">Substitution</span> objects will have a dynamic property named <span class="s1">heightDominance</span> to access the dominance for that trait.</p>
1330+
<p class="p5">effect =&gt; (float)</p>
1331+
<p class="p6">The selection coefficient(s) of the mutation, carried over from the original mutation object.<span class="Apple-converted-space">  </span>In a multi-trait model, this property provides the effect sizes for all of the traits (in the order in which the traits were defined).<span class="Apple-converted-space">  </span>For more control, see the <span class="s1">effectForTrait()</span> method.<span class="Apple-converted-space">  </span>Also note that dynamic properties are defined for each trait in the model; if there is a trait named <span class="s1">height</span>, for example, then <span class="s1">Substitution</span> objects will have a dynamic property named <span class="s1">heightEffect</span> to access the effect for that trait.</p>
13301332
<p class="p3">id =&gt; (integer$)</p>
13311333
<p class="p4">The identifier for this mutation.<span class="Apple-converted-space">  </span>Each mutation created during a run receives an immutable identifier that will be unique across the duration of the run, and that identifier is carried over to the <span class="s1">Substitution</span> object when the mutation fixes.</p>
13321334
<p class="p3">fixationTick =&gt; (integer$)</p>
@@ -1341,8 +1343,6 @@
13411343
<p class="p4">The tick in which this mutation arose.</p>
13421344
<p class="p3">position =&gt; (integer$)</p>
13431345
<p class="p4">The position in the chromosome of this mutation.</p>
1344-
<p class="p3">selectionCoeff =&gt; (float$)</p>
1345-
<p class="p4">The selection coefficient of the mutation, drawn from the distribution of fitness effects of its <span class="s1">MutationType</span><span class="s2">.</span></p>
13461346
<p class="p3">subpopID &lt;–&gt; (integer$)</p>
13471347
<p class="p4">The identifier of the subpopulation in which this mutation arose.<span class="Apple-converted-space">  </span>This value is carried over from the <span class="s1">Mutation</span> object directly; if a “tag” value was used in the <span class="s1">Mutation</span> object, that value will carry over to the corresponding <span class="s1">Substitution</span> object.<span class="Apple-converted-space">  </span>The <span class="s1">subpopID</span> in <span class="s1">Substitution</span> is a read-write property to allow it to be used as a “tag” in the same way, if the origin subpopulation identifier is not needed.</p>
13481348
<p class="p3">tag &lt;–&gt; (integer$)</p>

0 commit comments

Comments
 (0)