@@ -2583,9 +2583,8 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_
25832583
25842584 // No need to add the mutation to the registry; how would the user ever get a Mutation that was not already in it?
25852585
2586- // BCH 1/4/2025: the mutation is already in the system, so for now we don't need to note it
2587- // if (!mut_to_add->is_neutral_)
2588- // species->NoteNonNeutralMutation(mut_to_add);
2586+ // BCH 1/4/2025: the mutation is already in the system, so its effects have been
2587+ // noted; no call to NoteChangedMutation(mut_to_add) is needed
25892588 }
25902589 }
25912590 }
@@ -2964,10 +2963,6 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID
29642963 if (p_method_id == gID_addNewDrawnMutation )
29652964 {
29662965 new_mut = new (mut_block_ptr + new_mut_index) Mutation (mutation_type_ptr, chromosome->Index (), position, origin_subpop_id, origin_tick, (int8_t )nucleotide);
2967-
2968- // this mutation will be added to the simulation somewhere, so tell the species about it
2969- if (!new_mut->is_neutral_ )
2970- species->NoteNonNeutralMutation (new_mut);
29712966 }
29722967 else // (p_method_id == gID_addNewMutation)
29732968 {
@@ -2984,10 +2979,6 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID
29842979 // FIXME MULTITRAIT: This needs to pass in a whole vector of effects and dominance coefficients now... and hemizygous dominance...
29852980 // FIXME MULTITRAIT this code will also now need to handle the independent dominance case
29862981 new_mut = new (mut_block_ptr + new_mut_index) Mutation (mutation_type_ptr, chromosome->Index (), position, static_cast <slim_effect_t >(selection_coeff), mutation_type_ptr->DefaultDominanceForTrait (0 ), origin_subpop_id, origin_tick, (int8_t )nucleotide);
2987-
2988- // this mutation will be added to the simulation somewhere, so tell the species about it
2989- if (!new_mut->is_neutral_ )
2990- species->NoteNonNeutralMutation (new_mut);
29912982 }
29922983
29932984 // add to the registry, return value, haplosome, etc.
@@ -3484,10 +3475,6 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_readHaplosomesFromMS(EidosGlobalStr
34843475 // FIXME MULTITRAIT this code will also now need to handle the independent dominance case
34853476 Mutation *new_mut = new (mut_block_ptr + new_mut_index) Mutation (mutation_type_ptr, chromosome->Index (), position, static_cast <slim_effect_t >(selection_coeff), mutation_type_ptr->DefaultDominanceForTrait (0 ), subpop_index, origin_tick, nucleotide);
34863477
3487- // this mutation will be added to the simulation somewhere, so tell the species about it
3488- if (!new_mut->is_neutral_ )
3489- species.NoteNonNeutralMutation (new_mut);
3490-
34913478 // add it to our local map, so we can find it when making haplosomes, and to the population's mutation registry
34923479 pop.MutationRegistryAdd (new_mut);
34933480 mutation_indices.emplace_back (new_mut_index);
@@ -4136,10 +4123,6 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_readHaplosomesFromVCF(EidosGlobalSt
41364123 new_mut = new (mut_block_ptr + new_mut_index) Mutation (mutation_type_ptr, chromosome->Index (), mut_position, selection_coeff, dominance_coeff, subpop_index, origin_tick, nucleotide);
41374124 }
41384125
4139- // this mutation will be added to the simulation somewhere, so tell the species about it
4140- if (!new_mut->is_neutral_ )
4141- species->NoteNonNeutralMutation (new_mut);
4142-
41434126 // add it to our local map, so we can find it when making haplosomes, and to the population's mutation registry
41444127 pop.MutationRegistryAdd (new_mut);
41454128 alt_allele_mut_indices.emplace_back (new_mut_index);
@@ -4391,7 +4374,6 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID
43914374 // Construct a vector of mutations to remove that is sorted by position
43924375 std::vector<Mutation *> mutations_to_remove;
43934376 Mutation * const *mutations_data = (Mutation * const *)mutations_value->ObjectData ();
4394- slim_trait_index_t trait_count = species->TraitCount ();
43954377
43964378 for (int value_index = 0 ; value_index < mutations_count; ++value_index)
43974379 {
@@ -4405,20 +4387,12 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID
44054387
44064388 mutations_to_remove.emplace_back (mut);
44074389
4390+ // Note the removal; it might affect our caching, even if the mutation is neutral
4391+ species->NoteChangedMutation (mut);
4392+
44084393 // If we're not already aware of having removed a non-neutral mutation, check on that now
4409- if (!any_nonneutral_removed)
4410- {
4411- MutationTraitInfo *mut_trait_info = mutation_block->TraitInfoForMutation (mut);
4412-
4413- for (slim_trait_index_t trait_index = 0 ; trait_index < trait_count; ++trait_index)
4414- {
4415- if (mut_trait_info[trait_index].effect_size_ != (slim_effect_t )0.0 )
4416- {
4417- any_nonneutral_removed = true ;
4418- break ;
4419- }
4420- }
4421- }
4394+ if (!mut->is_neutral_for_all_traits_ )
4395+ any_nonneutral_removed = true ;
44224396 }
44234397
44244398 std::sort (mutations_to_remove.begin (), mutations_to_remove.end (), [ ](Mutation *i1, Mutation *i2) {return i1->position_ < i2->position_ ;});
0 commit comments