Skip to content

Commit bd8c0bf

Browse files
committed
add Species.chromosome back in, as a singleton alias for chromosomes
1 parent 543a2e0 commit bd8c0bf

File tree

7 files changed

+26
-5
lines changed

7 files changed

+26
-5
lines changed

QtSLiM/QtSLiMWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,11 +2001,11 @@ bool QtSLiMWindow::checkTerminationForAutofix(QString terminationMessage)
20012001

20022002
if (terminationMessage.contains("property chromosome is not defined for object element type Species") &&
20032003
(selectionString == "chromosome"))
2004-
return offerAndExecuteAutofix(selection, "chromosomes", "The `chromosome` property of Species has been renamed to `chromosomes`.", terminationMessage);
2004+
return offerAndExecuteAutofix(selection, "chromosomes", "The `chromosome` property of Species has been renamed to `chromosomes`.", terminationMessage); // actually, this property was left in, for now
20052005

20062006
if (terminationMessage.contains("property chromosomeType is not defined for object element type Species") &&
20072007
(selectionString == "chromosomeType"))
2008-
return offerAndExecuteAutofix(selection, "chromosomes.type", "The `chromosomeType` property of Species has been removed; it is now accessed as `chromosomes.type`.", terminationMessage);
2008+
return offerAndExecuteAutofix(selection, "chromosome.type", "The `chromosomeType` property of Species has been removed; it is now accessed as `chromosome.type`.", terminationMessage);
20092009

20102010
if (terminationMessage.contains("undefined identifier genome") &&
20112011
(selectionString == "genome"))

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@
880880
<p class="p2"><i>5.16.1<span class="Apple-converted-space">  </span></i><span class="s1"><i>Species</i></span><i> properties</i></p>
881881
<p class="p5">avatar =&gt; (string$)</p>
882882
<p class="p6">The avatar string used to represent this species in SLiMgui.<span class="Apple-converted-space">  </span>Outside of SLiMgui, this property still exists, but is not used by SLiM.<span class="Apple-converted-space">  </span>Avatars are typically one-character strings, often using an emoji that symbolizes the species.<span class="Apple-converted-space">  </span>This property is read-only; its value should be set with the <span class="s1">avatar</span> parameter of <span class="s1">initializeSpecies()</span>.</p>
883+
<p class="p5">chromosome =&gt; (object&lt;Chromosome&gt;$)</p>
884+
<p class="p6">The <span class="s1">Chromosome</span> object used by the species.<span class="Apple-converted-space">  </span>This property may only be accessed in a single-chromosome model; if there are multiple chromosomes (or none), the <span class="s1">chromosomes</span> property must be used instead.</p>
883885
<p class="p5">chromosomes =&gt; (object&lt;Chromosome&gt;)</p>
884886
<p class="p6">The <span class="s1">Chromosome</span> objects used by the species, in the order in which they were defined.<span class="Apple-converted-space">  </span>See also the <span class="s1">sexChromosomes</span> property.</p>
885887
<p class="p5">color =&gt; (string$)</p>

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7858,6 +7858,16 @@ The density scale of the kernel has no effect and will be normalized; this is th
78587858
\f4\fs20 .\
78597859
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
78607860

7861+
\f3\fs18 \cf2 chromosome => (object<Chromosome>$)\
7862+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
7863+
7864+
\f4\fs20 \cf2 The
7865+
\f3\fs18 Chromosome
7866+
\f4\fs20 object used by the species. This property may only be accessed in a single-chromosome model; if there are multiple chromosomes (or none), the
7867+
\f3\fs18 chromosomes
7868+
\f4\fs20 property must be used instead.\
7869+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
7870+
78617871
\f3\fs18 \cf2 chromosomes => (object<Chromosome>)\
78627872
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
78637873

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ development head (in the master branch):
141141
split chapter 15 (nonWF models) into two chapters, involving a great deal of renumbering, reorganizing, and rewriting
142142
add a [Niso<Chromosome]$ chromosome] parameter to relatedness(), to allow relatedness to be assessed for any model chromosome; extended to all chromosome types
143143
disable defer=T for all nonWF reproduction methods; it now does the same thing as defer=F (and is documented as having that possibility)
144+
add a chromosome property back onto Species, accessible only in single-chromosome models; this makes porting models forward a little easier
144145

145146

146147
version 4.3 (Eidos version 3.3):

core/slim_globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,6 @@ const std::string &gStr_geneConversionGCBias = EidosRegisteredString("geneConver
12241224
const std::string &gStr_geneConversionNonCrossoverFraction = EidosRegisteredString("geneConversionNonCrossoverFraction", gID_geneConversionNonCrossoverFraction);
12251225
const std::string &gStr_geneConversionMeanLength = EidosRegisteredString("geneConversionMeanLength", gID_geneConversionMeanLength);
12261226
const std::string &gStr_geneConversionSimpleConversionFraction = EidosRegisteredString("geneConversionSimpleConversionFraction", gID_geneConversionSimpleConversionFraction);
1227-
const std::string &gStr_chromosome = EidosRegisteredString("chromosome", gID_chromosome);
12281227
const std::string &gStr_isNullHaplosome = EidosRegisteredString("isNullHaplosome", gID_isNullHaplosome);
12291228
const std::string &gStr_mutations = EidosRegisteredString("mutations", gID_mutations);
12301229
const std::string &gStr_uniqueMutations = EidosRegisteredString("uniqueMutations", gID_uniqueMutations);
@@ -1262,6 +1261,7 @@ const std::string &gStr_allMutationTypes = EidosRegisteredString("allMutationTyp
12621261
const std::string &gStr_allScriptBlocks = EidosRegisteredString("allScriptBlocks", gID_allScriptBlocks);
12631262
const std::string &gStr_allSpecies = EidosRegisteredString("allSpecies", gID_allSpecies);
12641263
const std::string &gStr_allSubpopulations = EidosRegisteredString("allSubpopulations", gID_allSubpopulations);
1264+
const std::string &gStr_chromosome = EidosRegisteredString("chromosome", gID_chromosome);
12651265
const std::string &gStr_chromosomes = EidosRegisteredString("chromosomes", gID_chromosomes);
12661266
const std::string &gStr_genomicElementTypes = EidosRegisteredString("genomicElementTypes", gID_genomicElementTypes);
12671267
const std::string &gStr_lifetimeReproductiveOutput = EidosRegisteredString("lifetimeReproductiveOutput", gID_lifetimeReproductiveOutput);

core/slim_globals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ extern const std::string &gStr_geneConversionGCBias;
797797
extern const std::string &gStr_geneConversionNonCrossoverFraction;
798798
extern const std::string &gStr_geneConversionMeanLength;
799799
extern const std::string &gStr_geneConversionSimpleConversionFraction;
800-
extern const std::string &gStr_chromosome;
801800
extern const std::string &gStr_isNullHaplosome;
802801
extern const std::string &gStr_mutations;
803802
extern const std::string &gStr_uniqueMutations;
@@ -835,6 +834,7 @@ extern const std::string &gStr_allMutationTypes;
835834
extern const std::string &gStr_allScriptBlocks;
836835
extern const std::string &gStr_allSpecies;
837836
extern const std::string &gStr_allSubpopulations;
837+
extern const std::string &gStr_chromosome;
838838
extern const std::string &gStr_chromosomes;
839839
extern const std::string &gStr_genomicElementTypes;
840840
extern const std::string &gStr_lifetimeReproductiveOutput;
@@ -1246,7 +1246,6 @@ enum _SLiMGlobalStringID : int {
12461246
gID_geneConversionNonCrossoverFraction,
12471247
gID_geneConversionMeanLength,
12481248
gID_geneConversionSimpleConversionFraction,
1249-
gID_chromosome,
12501249
gID_isNullHaplosome,
12511250
gID_mutations,
12521251
gID_uniqueMutations,
@@ -1284,6 +1283,7 @@ enum _SLiMGlobalStringID : int {
12841283
gID_allScriptBlocks,
12851284
gID_allSpecies,
12861285
gID_allSubpopulations,
1286+
gID_chromosome,
12871287
gID_chromosomes,
12881288
gID_genomicElementTypes,
12891289
gID_lifetimeReproductiveOutput,

core/species_eidos.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,13 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id)
16981698
{
16991699
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(avatar_));
17001700
}
1701+
case gID_chromosome:
1702+
{
1703+
if (chromosomes_.size() != 1)
1704+
EIDOS_TERMINATION << "ERROR (Species::GetProperty): property chromosome may only be accessed on a species that has exactly one chromosome; in all other cases the chromosomes property must be used, since it can return multiple chromosomes (or none)." << EidosTerminate();
1705+
1706+
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(chromosomes_[0], gSLiM_Chromosome_Class));
1707+
}
17011708
case gID_chromosomes:
17021709
{
17031710
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Chromosome_Class);
@@ -4135,6 +4142,7 @@ const std::vector<EidosPropertySignature_CSP> *Species_Class::Properties(void) c
41354142
properties = new std::vector<EidosPropertySignature_CSP>(*super::Properties());
41364143

41374144
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_avatar, true, kEidosValueMaskString | kEidosValueMaskSingleton)));
4145+
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_chromosome, true, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_Chromosome_Class)));
41384146
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_chromosomes, true, kEidosValueMaskObject, gSLiM_Chromosome_Class)));
41394147
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gEidosStr_color, true, kEidosValueMaskString | kEidosValueMaskSingleton)));
41404148
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_description, false, kEidosValueMaskString | kEidosValueMaskSingleton)));

0 commit comments

Comments
 (0)