Skip to content

Commit c025265

Browse files
committed
add chromosomeSubposition property to Haplosome
1 parent 311fd28 commit c025265

File tree

8 files changed

+52
-1
lines changed

8 files changed

+52
-1
lines changed

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@
249249
<p class="p2"><i>5.4.1<span class="Apple-converted-space">  </span></i><span class="s1"><i>Haplosome</i></span><i> properties</i></p>
250250
<p class="p5">chromosome =&gt; (object&lt;Chromosome&gt;$)</p>
251251
<p class="p6">The <span class="s1">Chromosome</span> object which this haplosome represents; for example, if this haplosome represents the X sex chromosome in a particular individual, then this property provides the <span class="s1">Chromosome</span> object that defines the genetic structure of the X sex chromosome in that individual’s species.</p>
252+
<p class="p5">chromosomeSubposition =&gt; (integer$)</p>
253+
<p class="p6">The position index of the haplosome, within the set of haplosomes associated with the <span class="s1">Chromosome</span> object which this haplosome represents.<span class="Apple-converted-space">  </span>For example, if an individual in a multi-chromosome model has two haplosomes that represent a given chromosome within its <span class="s1">haplosomes</span> vector, the first of those haplosomes will have a <span class="s1">chromosomeSubposition</span> value of <span class="s1">0</span>, the second will have a <span class="s1">chromosomeSubposition</span> value of <span class="s1">1</span>.<span class="Apple-converted-space">  </span>For an intrinsically diploid chromosome in individuals generated by a standard biparental cross, the first haplosome (at subposition <span class="s1">0</span>) came from its first parent (the female parent, in sexual models), and the second haplosome (at subposition <span class="s1">1</span>) came from its second parent (the male parent, in sexual models).</p>
252254
<p class="p5"><span class="s3">haplosomePedigreeID =&gt; (integer$)</span></p>
253255
<p class="p6">If pedigree tracking is turned on with <span class="s1">initializeSLiMOptions(keepPedigrees=T)</span>, <span class="s1">haplosomePedigreeID</span> is a “semi-unique” non-negative identifier for each haplosome in a simulation, never re-used throughout the duration of the simulation run.<span class="Apple-converted-space">  </span>The <span class="s1">haplosomePedigreeID</span> of a given haplosome will be equal to either <span class="s1">(2*pedigreeID)</span> or <span class="s1">(2*pedigreeID + 1)</span> of the individual that the haplosome belongs to (the former for a first haplosome of the individual, the latter for a second haplosome of the individual if one exists); this invariant relationship is guaranteed.</p>
254256
<p class="p6">This value is “semi-unique” in the sense that it is shared by <i>all</i> of the first haplosomes of an individual, or by <i>all</i> of the second haplosomes of an individual.<span class="Apple-converted-space">  </span>In a single-chromosome model, a given individual will have just one first haplosome, and perhaps (depending on the chromosome type) one second haplosome, and so the value of <span class="s1">haplosomePedigreeID</span> for each of those haplosomes will be truly unique.<span class="Apple-converted-space">  </span>In a multi-chromosome model, however, an individual has a first haplosome for each chromosome, and perhaps (depending on the chromosome types) a second haplosome for each chromosome.<span class="Apple-converted-space">  </span>In that case, the value of <span class="s1">haplosomePedigreeID</span> is unique in the sense that it is different for each individual, but it is <i>not</i> unique in the sense that it will be shared by other haplosomes within the same individual – shared by all the first haplosomes, or shared by all the second haplosomes.<span class="Apple-converted-space">  </span>This “semi-uniqueness” is intentional; it allows <span class="s1">haplosomePedigreeID</span> to be used as a “key” that associates the haplosomes of an individual across disparate datasets, such as across the different tree sequences for each chromosome that are produced by tree-sequence recording in a multi-chromosome model.<span class="Apple-converted-space">  </span>See sections 1.5.1 and 8.3 for further discussion of multi-chromosome models.</p>

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,28 @@ Note that new script blocks can also be created and scheduled using the
15651565
\f4\fs20 object that defines the genetic structure of the X sex chromosome in that individual\'92s species.\
15661566
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
15671567

1568+
\f3\fs18 \cf2 chromosomeSubposition => (integer$)\
1569+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
1570+
1571+
\f4\fs20 \cf2 The position index of the haplosome, within the set of haplosomes associated with the
1572+
\f3\fs18 Chromosome
1573+
\f4\fs20 object which this haplosome represents. For example, if an individual in a multi-chromosome model has two haplosomes that represent a given chromosome within its
1574+
\f3\fs18 haplosomes
1575+
\f4\fs20 vector, the first of those haplosomes will have a
1576+
\f3\fs18 chromosomeSubposition
1577+
\f4\fs20 value of
1578+
\f3\fs18 0
1579+
\f4\fs20 , the second will have a
1580+
\f3\fs18 chromosomeSubposition
1581+
\f4\fs20 value of
1582+
\f3\fs18 1
1583+
\f4\fs20 . For an intrinsically diploid chromosome in individuals generated by a standard biparental cross, the first haplosome (at subposition
1584+
\f3\fs18 0
1585+
\f4\fs20 ) came from its first parent (the female parent, in sexual models), and the second haplosome (at subposition
1586+
\f3\fs18 1
1587+
\f4\fs20 ) came from its second parent (the male parent, in sexual models).\
1588+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1589+
15681590
\f3\fs18 \cf2 \expnd0\expndtw0\kerning0
15691591
haplosomePedigreeID => (integer$)\
15701592
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

VERSIONS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ development head (in the master branch):
1212
write "chromosomes" and "this_chromosome" keys out to provenance as well as metadata (#520)
1313
fix an annoying autoindent cursor position bug that I suspect is a Qt 6 regression in QPlainTextEdit
1414
add a define of TSK_TRACE_ERRORS in Xcode for slim and SLiMguiLegacy, in DEBUG only, for easier tskit debugging; break on _tsk_trace_error()
15-
fix a regression that caused the sourceSubpop pseudo-parameter to be NULL in modifyChild() clabbacks in all cases; add tests, improve documentation (#522)
15+
fix a regression that caused the sourceSubpop pseudo-parameter to be NULL in modifyChild() callbacks in all cases; add tests, improve documentation (#522)
16+
add chromosomeSubposition property to Haplosome, providing whether the haplosome is index 0 or 1 within its individual, within the set of haplosomes for its associated chromosome
1617

1718

1819
version 5.0 (Eidos version 4.0):

core/haplosome.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ EidosValue_SP Haplosome::GetProperty(EidosGlobalStringID p_property_id)
423423

424424
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(chromosome, gSLiM_Chromosome_Class));
425425
}
426+
case gID_chromosomeSubposition: // ACCELERATED
427+
{
428+
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(chromosome_subposition_));
429+
}
426430
case gID_haplosomePedigreeID: // ACCELERATED
427431
{
428432
if (!individual_->subpopulation_->species_.PedigreesEnabledByUser())
@@ -504,6 +508,21 @@ EidosValue *Haplosome::GetProperty_Accelerated_haplosomePedigreeID(EidosObject *
504508
return int_result;
505509
}
506510

511+
EidosValue *Haplosome::GetProperty_Accelerated_chromosomeSubposition(EidosObject **p_values, size_t p_values_size)
512+
{
513+
EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size);
514+
515+
for (size_t value_index = 0; value_index < p_values_size; ++value_index)
516+
{
517+
Haplosome *value = (Haplosome *)(p_values[value_index]);
518+
int64_t subposition_value = (uint64_t)(value->chromosome_subposition_);
519+
520+
int_result->set_int_no_check(subposition_value, value_index);
521+
}
522+
523+
return int_result;
524+
}
525+
507526
EidosValue *Haplosome::GetProperty_Accelerated_isNullHaplosome(EidosObject **p_values, size_t p_values_size)
508527
{
509528
EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(p_values_size);
@@ -2167,6 +2186,7 @@ const std::vector<EidosPropertySignature_CSP> *Haplosome_Class::Properties(void)
21672186
properties = new std::vector<EidosPropertySignature_CSP>(*super::Properties());
21682187

21692188
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_chromosome, true, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_Chromosome_Class)));
2189+
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_chromosomeSubposition, true, kEidosValueMaskInt | kEidosValueMaskSingleton))->DeclareAcceleratedGet(Haplosome::GetProperty_Accelerated_chromosomeSubposition));
21702190
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_haplosomePedigreeID,true, kEidosValueMaskInt | kEidosValueMaskSingleton))->DeclareAcceleratedGet(Haplosome::GetProperty_Accelerated_haplosomePedigreeID));
21712191
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_individual, true, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_Individual_Class)));
21722192
properties->emplace_back((EidosPropertySignature *)(new EidosPropertySignature(gStr_isNullHaplosome, true, kEidosValueMaskLogical | kEidosValueMaskSingleton))->DeclareAcceleratedGet(Haplosome::GetProperty_Accelerated_isNullHaplosome));

core/haplosome.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ class Haplosome : public EidosObject
438438

439439
// Accelerated property access; see class EidosObject for comments on this mechanism
440440
static EidosValue *GetProperty_Accelerated_haplosomePedigreeID(EidosObject **p_values, size_t p_values_size);
441+
static EidosValue *GetProperty_Accelerated_chromosomeSubposition(EidosObject **p_values, size_t p_values_size);
441442
static EidosValue *GetProperty_Accelerated_isNullHaplosome(EidosObject **p_values, size_t p_values_size);
442443
static EidosValue *GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size);
443444

core/slim_globals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ const std::string &gStr_geneConversionGCBias = EidosRegisteredString("geneConver
12251225
const std::string &gStr_geneConversionNonCrossoverFraction = EidosRegisteredString("geneConversionNonCrossoverFraction", gID_geneConversionNonCrossoverFraction);
12261226
const std::string &gStr_geneConversionMeanLength = EidosRegisteredString("geneConversionMeanLength", gID_geneConversionMeanLength);
12271227
const std::string &gStr_geneConversionSimpleConversionFraction = EidosRegisteredString("geneConversionSimpleConversionFraction", gID_geneConversionSimpleConversionFraction);
1228+
const std::string &gStr_chromosomeSubposition = EidosRegisteredString("chromosomeSubposition", gID_chromosomeSubposition);
12281229
const std::string &gStr_isNullHaplosome = EidosRegisteredString("isNullHaplosome", gID_isNullHaplosome);
12291230
const std::string &gStr_mutations = EidosRegisteredString("mutations", gID_mutations);
12301231
const std::string &gStr_uniqueMutations = EidosRegisteredString("uniqueMutations", gID_uniqueMutations);

core/slim_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ extern const std::string &gStr_geneConversionGCBias;
799799
extern const std::string &gStr_geneConversionNonCrossoverFraction;
800800
extern const std::string &gStr_geneConversionMeanLength;
801801
extern const std::string &gStr_geneConversionSimpleConversionFraction;
802+
extern const std::string &gStr_chromosomeSubposition;
802803
extern const std::string &gStr_isNullHaplosome;
803804
extern const std::string &gStr_mutations;
804805
extern const std::string &gStr_uniqueMutations;
@@ -1252,6 +1253,7 @@ enum _SLiMGlobalStringID : int {
12521253
gID_geneConversionNonCrossoverFraction,
12531254
gID_geneConversionMeanLength,
12541255
gID_geneConversionSimpleConversionFraction,
1256+
gID_chromosomeSubposition,
12551257
gID_isNullHaplosome,
12561258
gID_mutations,
12571259
gID_uniqueMutations,

core/slim_test_genetics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,14 @@ void _RunHaplosomeTests(const std::string &temp_path)
709709

710710
// Test Haplosome properties
711711
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; if (gen.chromosome.type == 'A') stop(); }", __LINE__);
712+
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[c(0,1)]; if (identical(gen.chromosomeSubposition, c(0,1))) stop(); }", __LINE__);
712713
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; if (gen.isNullHaplosome == F) stop(); }", __LINE__);
713714
SLiMAssertScriptStop(gen1_setup_highmut_p1 + "10 early() { gen = p1.haplosomes[0]; if (gen.mutations[0].mutationType == m1) stop(); }", __LINE__);
714715
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; gen.tag; }", "before being set", __LINE__);
715716
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; c(gen,gen).tag; }", "before being set", __LINE__);
716717
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; gen.tag = 278; if (gen.tag == 278) stop(); }", __LINE__);
717718
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; gen.chromosome.type = 'A'; stop(); }", "read-only property", __LINE__);
719+
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; gen.chromosomeSubposition = 0; stop(); }", "read-only property", __LINE__);
718720
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { gen = p1.haplosomes[0]; gen.isNullHaplosome = F; stop(); }", "read-only property", __LINE__);
719721
SLiMAssertScriptRaise(gen1_setup_highmut_p1 + "10 early() { gen = p1.haplosomes[0]; gen.mutations[0].mutationType = m1; stop(); }", "read-only property", __LINE__);
720722

0 commit comments

Comments
 (0)