Skip to content

Commit 0629ef2

Browse files
committed
remove setSelectionCoeff(), rename selectionCoeff to effect
1 parent 0875937 commit 0629ef2

16 files changed

Lines changed: 213 additions & 294 deletions

QtSLiM/QtSLiMWindow.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,19 @@ bool QtSLiMWindow::checkTerminationForAutofix(QString terminationMessage)
21542154
(selectionString == "drawSelectionCoefficient"))
21552155
return offerAndExecuteAutofix(selection, "drawEffectForTrait", "The `drawSelectionCoefficient()` method of MutationType has become the method `drawEffectForTrait()`.", terminationMessage);
21562156

2157+
if ((afterSelection1String == "(") &&
2158+
terminationMessage.contains("method setSelectionCoeff() is not defined on object element type Mutation") &&
2159+
(selectionPlus1AfterString == "setSelectionCoeff("))
2160+
return offerAndExecuteAutofix(selectionPlus1After, "setEffectForTrait(NULL, ", "The `setSelectionCoeff()` method of Mutation has become the method `setEffectForTrait()`.", terminationMessage);
2161+
2162+
if (terminationMessage.contains("property selectionCoeff is not defined for object element type Mutation") &&
2163+
(selectionString == "selectionCoeff"))
2164+
return offerAndExecuteAutofix(selection, "effect", "The `selectionCoeff` property of Mutation has become the property `effect`.", terminationMessage);
2165+
2166+
if (terminationMessage.contains("property selectionCoeff is not defined for object element type Substitution") &&
2167+
(selectionString == "selectionCoeff"))
2168+
return offerAndExecuteAutofix(selection, "effect", "The `selectionCoeff` property of Substitution has become the property `effect`.", terminationMessage);
2169+
21572170
return false;
21582171
}
21592172

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 18 additions & 25 deletions
Large diffs are not rendered by default.

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 55 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,39 +5948,58 @@ You can get the
59485948
\f4\fs20 object with which the mutation is associated.\
59495949
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
59505950

5951-
\f3\fs18 \cf2 dominanceCoeff => (float$)\
5951+
\f3\fs18 \cf2 dominance => (float)\
59525952
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
59535953

5954-
\f4\fs20 \cf2 The dominance coefficient of the mutation, taken from the default dominance coefficient of its
5954+
\f4\fs20 \cf2 The dominance coefficient(s) of the mutation, taken from the default dominance coefficient(s) of its
59555955
\f3\fs18 MutationType
5956-
\f4\fs20 . If a mutation has a
5957-
\f3\fs18 selectionCoeff
5958-
\f4\fs20 of
5959-
\f1\i s
5960-
\f4\i0 and a
5961-
\f3\fs18 dominanceCoeff
5962-
\f4\fs20 of
5963-
\f1\i h
5964-
\f4\i0 , the multiplicative fitness effect of the mutation in a homozygote is 1+
5965-
\f1\i s
5966-
\f4\i0 , and in a heterozygote is 1+
5967-
\f1\i hs
5968-
\f4\i0 . The dominance coefficient of a mutation can be changed with the
5969-
\f3\fs18 setDominanceCoeff()
5956+
\f4\fs20 . 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). For more control, see the
5957+
\f3\fs18 dominanceForTrait()
5958+
\f4\fs20 method. Also note that dynamic properties are defined for each trait in the model; if there is a trait named
5959+
\f3\fs18 height
5960+
\f4\fs20 , for example, then
5961+
\f3\fs18 Mutation
5962+
\f4\fs20 objects will have a dynamic property named
5963+
\f3\fs18 heightDominance
5964+
\f4\fs20 to access the dominance for that trait. The dominance coefficient(s) of a mutation can be changed with the
5965+
\f3\fs18 setDominanceForTrait()
59705966
\f4\fs20 method.\
5971-
Note that this property has a quirk: it is stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
5967+
Note that dominance coefficients in SLiM have a quirk: they are stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
59725968
\f3\fs18 mut
59735969
\f4\fs20 \'92s dominance coefficient to some number
59745970
\f3\fs18 x
59755971
\f4\fs20 ,
59765972
\f3\fs18 mut.dominanceCoeff==x
59775973
\f4\fs20 may be
59785974
\f3\fs18 F
5979-
\f4\fs20 due to floating-point rounding error. Comparisons of floating-point numbers for exact equality is often a bad idea, but this is one case where it may fail unexpectedly. Instead, it is recommended to use the
5980-
\f3\fs18 id
5981-
\f4\fs20 or
5982-
\f3\fs18 tag
5983-
\f4\fs20 properties to identify particular mutations.\
5975+
\f4\fs20 due to floating-point rounding error. Comparisons of floating-point numbers for exact equality is often a bad idea, but this is one case where it may fail unexpectedly.\
5976+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
5977+
5978+
\f3\fs18 \cf2 effect => (float)\
5979+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
5980+
5981+
\f4\fs20 \cf2 The effect size(s) of the mutation, drawn from the distribution of effect sizes of its
5982+
\f3\fs18 MutationType
5983+
\f4\fs20 . 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). For more control, see the
5984+
\f3\fs18 effectForTrait()
5985+
\f4\fs20 method. Also note that dynamic properties are defined for each trait in the model; if there is a trait named
5986+
\f3\fs18 height
5987+
\f4\fs20 , for example, then
5988+
\f3\fs18 Mutation
5989+
\f4\fs20 objects will have a dynamic property named
5990+
\f3\fs18 heightEffect
5991+
\f4\fs20 to access the effect for that trait. The effect size of a mutation can be changed with the
5992+
\f3\fs18 setEffectForTrait()
5993+
\f4\fs20 method.\
5994+
Note that effect sizes in SLiM have a quirk: they are stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
5995+
\f3\fs18 mut
5996+
\f4\fs20 \'92s effect size to some number
5997+
\f3\fs18 x
5998+
\f4\fs20 ,
5999+
\f3\fs18 mut.effect==x
6000+
\f4\fs20 may be
6001+
\f3\fs18 F
6002+
\f4\fs20 due to floating-point rounding error. Comparisons of floating-point numbers for exact equality is often a bad idea, but this is one case where it may fail unexpectedly.\
59846003
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
59856004

59866005
\f3\fs18 \cf0 id => (integer$)\
@@ -6076,42 +6095,6 @@ nucleotide <\'96> (string$)\
60766095
\f5 \
60776096
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
60786097

6079-
\f3\fs18 \cf0 selectionCoeff => (float$)\
6080-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6081-
6082-
\f4\fs20 \cf0 The selection coefficient of the mutation, drawn from the distribution of fitness effects of its
6083-
\f3\fs18 MutationType
6084-
\f5\fs20 .
6085-
\f4 \cf2 \expnd0\expndtw0\kerning0
6086-
If a mutation has a
6087-
\f3\fs18 selectionCoeff
6088-
\f4\fs20 of
6089-
\f1\i s
6090-
\f4\i0 , the multiplicative fitness effect of the mutation in a homozygote is 1+
6091-
\f1\i s
6092-
\f4\i0 ; in a heterozygote it is 1+
6093-
\f1\i hs
6094-
\f4\i0 , where
6095-
\f1\i h
6096-
\f4\i0 is the dominance coefficient kept by the mutation type.
6097-
\f5 \cf0 \kerning1\expnd0\expndtw0 \
6098-
6099-
\f4 Note that this property has a quirk: it is stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
6100-
\f3\fs18 mut
6101-
\f4\fs20 \'92s selection coefficient to some number
6102-
\f3\fs18 x
6103-
\f4\fs20 ,
6104-
\f3\fs18 mut.selectionCoeff==x
6105-
\f4\fs20 may be
6106-
\f3\fs18 F
6107-
\f4\fs20 due to floating-point rounding error. Comparisons of floating-point numbers for exact equality is often a bad idea, but this is one case where it may fail unexpectedly. Instead, it is recommended to use the
6108-
\f3\fs18 id
6109-
\f4\fs20 or
6110-
\f3\fs18 tag
6111-
\f4\fs20 properties to identify particular mutations.
6112-
\f5 \
6113-
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6114-
61156098
\f3\fs18 \cf0 subpopID <\'96> (integer$)\
61166099
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
61176100

@@ -6185,21 +6168,6 @@ If you don\'92t care which subpopulation a mutation originated in, the
61856168
\f4\fs20 .\
61866169
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
61876170

6188-
\f3\fs18 \cf2 \'96\'a0(void)setDominanceCoeff(float$\'a0dominanceCoeff)\
6189-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6190-
6191-
\f4\fs20 \cf2 Set the dominance coefficient of the mutation to
6192-
\f3\fs18 dominanceCoeff
6193-
\f4\fs20 . The dominance coefficient will be changed for all individuals that possess the mutation, since they all share a single
6194-
\f3\fs18 Mutation
6195-
\f4\fs20 object (note that the selection coefficient will remain unchanged).\
6196-
Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6197-
\f3\fs18 Species
6198-
\f4\fs20 method
6199-
\f3\fs18 recalculateFitness()
6200-
\f4\fs20 \'96 but see the documentation of that method for caveats.\
6201-
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6202-
62036171
\f3\fs18 \cf2 +\'a0(void)setDominanceForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL], [Nif\'a0dominance\'a0=\'a0NULL])\
62046172
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
62056173

@@ -6271,31 +6239,14 @@ The parameter
62716239
\f3\fs18 integer
62726240
\f4\fs20 identifier or a
62736241
\f3\fs18 MutationType
6274-
\f4\fs20 object). The selection coefficients and dominance coefficients of existing mutations are not changed, since they are properties of the mutation objects themselves; they can be changed explicitly using the
6275-
\f3\fs18 setSelectionCoeff()
6242+
\f4\fs20 object). The effects and dominance coefficients of existing mutations are not changed, since those are properties of the mutation objects themselves; they can be changed explicitly using the
6243+
\f3\fs18 setEffectForTrait()
62766244
\f4\fs20 and
6277-
\f3\fs18 setDominanceCoeff()
6245+
\f3\fs18 setDominanceForTrait()
62786246
\f4\fs20 methods of
62796247
\f3\fs18 Mutation
62806248
\f4\fs20 if so desired.\
62816249
In nucleotide-based models, a restriction applies: nucleotide-based mutations may not be changed to a non-nucleotide-based mutation type, and non-nucleotide-based mutations may not be changed to a nucleotide-based mutation type.\
6282-
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6283-
6284-
\f3\fs18 \cf2 \'96\'a0(void)setSelectionCoeff(float$\'a0selectionCoeff)\
6285-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6286-
6287-
\f4\fs20 \cf2 Set the selection coefficient of the mutation to
6288-
\f3\fs18 selectionCoeff
6289-
\f4\fs20 . The selection coefficient will be changed for all individuals that possess the mutation, since they all share a single
6290-
\f3\fs18 Mutation
6291-
\f4\fs20 object (note that the dominance coefficient will remain unchanged).\
6292-
Often setting up a
6293-
\f3\fs18 mutationEffect()
6294-
\f4\fs20 callback is preferable, in order to modify the selection coefficient in a more limited and controlled fashion. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6295-
\f3\fs18 Species
6296-
\f4\fs20 method
6297-
\f3\fs18 recalculateFitness()
6298-
\f4\fs20 \'96 but see the documentation of that method for caveats.\
62996250
\pard\pardeftab720\ri720\sb360\sa60\partightenfactor0
63006251

63016252
\f0\b\fs22 \cf0 5.11 Class MutationType\
@@ -6536,7 +6487,7 @@ The species to which the target object belongs.\
65366487
\f4\fs20 property, but that can be changed later with the
65376488
\f3\fs18 Mutation
65386489
\f4\fs20 method
6539-
\f3\fs18 setDominanceCoeff()
6490+
\f3\fs18 setDominanceForTrait()
65406491
\f4\fs20 .\
65416492
Note that dominance coefficients are not bounded. A dominance coefficient greater than
65426493
\f3\fs18 1.0
@@ -13894,10 +13845,18 @@ Note that this method is only for use in nonWF models, in which migration is man
1389413845
\f4\fs20 object with which the mutation is associated.\
1389513846
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1389613847

13897-
\f3\fs18 \cf2 dominanceCoeff => (float$)\
13848+
\f3\fs18 \cf2 dominance => (float)\
1389813849
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
1389913850

13900-
\f4\fs20 \cf2 The dominance coefficient of the mutation, carried over from the original mutation object.\
13851+
\f4\fs20 \cf2 The dominance coefficient(s) of the mutation, carried over from the original mutation object. 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). For more control, see the
13852+
\f3\fs18 dominanceForTrait()
13853+
\f4\fs20 method. Also note that dynamic properties are defined for each trait in the model; if there is a trait named
13854+
\f3\fs18 height
13855+
\f4\fs20 , for example, then
13856+
\f3\fs18 Substitution
13857+
\f4\fs20 objects will have a dynamic property named
13858+
\f3\fs18 heightDominance
13859+
\f4\fs20 to access the dominance for that trait.\
1390113860
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1390213861

1390313862
\f3\fs18 \cf0 id => (integer$)\

VERSIONS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ multitrait branch:
3838
add Community property allTraits => (object<Trait>)
3939
make a single implicit trait with MakeImplicitTrait() (defaulting to kMultiplicative with a direct fitness effect) if initializeTrait() is not called before initializeMutationType() is called
4040
add a C++ dominance_coeff_ property to Mutation, with a value inherited from MutationType's property (which is now just the default value)
41-
add dominanceCoeff properties to Mutation and Substitution
42-
add a setDominanceCoeff() method to Mutation, yay!
41+
add dominance properties to Mutation and Substitution
4342
fix calcInbreedingLoad() to use muts.dominanceCoeff instead of muts.mutationType.dominanceCoeff
4443
revamp MutationType for multiple traits
4544
remove MutationType properties dominanceCoeff, distributionType, and distributionParams properties
@@ -64,6 +63,8 @@ multitrait branch:
6463
add +setEffectForTrait([Nio<Trait> traits = NULL], [Nif effect = NULL]) and +setDominanceForTrait([Nio<Trait> traits = NULL], [Nif dominance = NULL]) methods to Mutation
6564
add <trait>Effect and <trait>Dominance properties to Mutation, both read-write float$
6665
add <trait>Effect and <trait>Dominance properties to Substitution, both read-only float$
66+
remove Mutation method setSelectionCoeff(), autofixing to setEffectForTrait(NULL, )
67+
rename the selectionCoeff property to effect, for both Mutation and Substitution; it changes from float$ to float, and now returns all trait effects; and SLiMgui autofixes this change
6768

6869

6970
version 5.1 (Eidos version 4.1):

core/haplosome.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ const std::vector<EidosMethodSignature_CSP> *Haplosome_Class::Methods(void) cons
22172217

22182218
methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_addMutations, kEidosValueMaskVOID))->AddObject("mutations", gSLiM_Mutation_Class));
22192219
methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_addNewDrawnMutation, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject("mutationType", gSLiM_MutationType_Class)->AddInt("position")->AddIntObject_ON("originSubpop", gSLiM_Subpopulation_Class, gStaticEidosValueNULL)->AddIntString_ON("nucleotide", gStaticEidosValueNULL));
2220-
methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_addNewMutation, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject("mutationType", gSLiM_MutationType_Class)->AddNumeric("selectionCoeff")->AddInt("position")->AddIntObject_ON("originSubpop", gSLiM_Subpopulation_Class, gStaticEidosValueNULL)->AddIntString_ON("nucleotide", gStaticEidosValueNULL));
2220+
methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_addNewMutation, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject("mutationType", gSLiM_MutationType_Class)->AddNumeric("selectionCoeff")->AddInt("position")->AddIntObject_ON("originSubpop", gSLiM_Subpopulation_Class, gStaticEidosValueNULL)->AddIntString_ON("nucleotide", gStaticEidosValueNULL)); // FIXME MULTITRAIT
22212221
methods->emplace_back(((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_containsMarkerMutation, kEidosValueMaskLogical | kEidosValueMaskSingleton | kEidosValueMaskNULL | kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject_S("mutType", gSLiM_MutationType_Class)->AddInt_S("position")->AddLogical_OS("returnMutation", gStaticEidosValue_LogicalF))->DeclareAcceleratedImp(Haplosome::ExecuteMethod_Accelerated_containsMarkerMutation));
22222222
methods->emplace_back(((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_containsMutations, kEidosValueMaskLogical))->AddObject("mutations", gSLiM_Mutation_Class))->DeclareAcceleratedImp(Haplosome::ExecuteMethod_Accelerated_containsMutations));
22232223
methods->emplace_back(((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_countOfMutationsOfType, kEidosValueMaskInt | kEidosValueMaskSingleton))->AddIntObject_S("mutType", gSLiM_MutationType_Class))->DeclareAcceleratedImp(Haplosome::ExecuteMethod_Accelerated_countOfMutationsOfType));

0 commit comments

Comments
 (0)