Skip to content

Commit 8f818e0

Browse files
committed
multichrom work for outputFull() and readFromPopulationFile()
1 parent f3b7e75 commit 8f818e0

File tree

11 files changed

+1226
-1052
lines changed

11 files changed

+1226
-1052
lines changed

QtSLiM/QtSLiMWindow.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5882,8 +5882,7 @@ void QtSLiMWindow::dumpPopulationClicked(void)
58825882
slim_tick_t species_cycle = displaySpecies->Cycle();
58835883

58845884
// dump the population
5885-
SLIM_OUTSTREAM << "#OUT: " << community->tick_ << " " << species_cycle << " A" << std::endl;
5886-
displaySpecies->population_.PrintAll(SLIM_OUTSTREAM, true, true, false, false); // output spatial positions and ages if available, but not ancestral sequence
5885+
displaySpecies->population_.PrintAll(SLIM_OUTSTREAM, true, true, false, false, false ); // output spatial positions and ages if available, but not ancestral sequence or tags
58875886

58885887
// dump fixed substitutions also; so the dump in SLiMgui is like outputFull() + outputFixedMutations()
58895888
SLIM_OUTSTREAM << std::endl;

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,7 @@
958958
<p class="p6"><span class="s3">In SLiM 3.3 and later, the output format includes the nucleotides associated with any nucleotide-based mutations.</span></p>
959959
<p class="p4">Output is generally done in a <span class="s1">late()</span> event, so that the output reflects the state of the simulation at the end of a tick.</p>
960960
<p class="p3">– (integer$)readFromPopulationFile(string$ filePath<span class="s5">, [No&lt;Dictionary&gt;$ subpopMap = NULL]</span>)</p>
961-
<p class="p6">Read from a population initialization file, whether in text or binary format as previously specified to <span class="s1">outputFull()</span>, and return the tick counter value represented by the file’s contents (i.e., the tick at which the file was generated).<span class="Apple-converted-space">  </span>Although this is most commonly used to set up initial populations (often in an Eidos event set to run in tick 1, immediately after simulation initialization), it may be called in any <span class="s1">early()</span> or <span class="s1">late()</span> Eidos event; the current state of all populations in the target species will be wiped and replaced by the state in the file at <span class="s1">filePath</span>.<span class="Apple-converted-space">  </span>All Eidos variables that are of type <span class="s1">object</span> and have element type <span class="s1">Subpopulation</span>, <span class="s6">Haplosome</span>, <span class="s1">Mutation</span>, <span class="s1">Individual</span>, or <span class="s1">Substitution</span> will be removed as a side effect of this method if they contain any element that belongs to the target species, because those objects will no longer exist in the SLiM simulation; if you want to preserve any of that state, you should output it or save it to a file prior to this call.<span class="Apple-converted-space">  </span>New symbols will be defined to refer to the new <span class="s1">Subpopulation</span> objects loaded from the file.</p>
962-
<p class="p6">If the file being read was written by a version of SLiM prior to 2.3, then for backward compatibility fitness values will be calculated immediately for any new subpopulations created by this call, which will trigger the calling of any activated and applicable <span class="s1">mutationEffect()</span> and <span class="s1">fitnessEffect()</span> callbacks.<span class="Apple-converted-space">  </span>When reading files written by SLiM 2.3 or later, fitness values are not calculated as a side effect of this call (because the simulation will often need to evaluate interactions or modify other state prior to doing so).</p>
961+
<p class="p6">Read from a population initialization file, whether in text or binary format as previously specified to <span class="s1">outputFull()</span>, and return the tick counter value represented by the file’s contents (i.e., the tick at which the file was generated).<span class="Apple-converted-space">  </span>Although this is most commonly used to set up initial populations (often in an Eidos event set to run in tick 1, immediately after simulation initialization), it may be called in any <span class="s1">early()</span> or <span class="s1">late()</span> Eidos event; the current state of all populations in the target species will be wiped and replaced by the state in the file at <span class="s1">filePath</span>.<span class="Apple-converted-space">  </span>All Eidos variables that are of type <span class="s1">object</span> and have element type <span class="s1">Subpopulation</span>, <span class="s1">Haplosome</span>, <span class="s1">Mutation</span>, <span class="s1">Individual</span>, or <span class="s1">Substitution</span> will be removed as a side effect of this method if they contain any element that belongs to the target species, because those objects will no longer exist in the SLiM simulation; if you want to preserve any of that state, you should output it or save it to a file prior to this call.<span class="Apple-converted-space">  </span>New symbols will be defined to refer to the new <span class="s1">Subpopulation</span> objects loaded from the file.<span class="Apple-converted-space">  </span>Note that fitness values are not calculated as a side effect of this call (because the simulation will often need to evaluate interactions or modify other state prior to doing so).</p>
963962
<p class="p6"><span class="s3">In SLiM 2.3 and later when using the WF model, calling </span><span class="s4">readFromPopulationFile()</span><span class="s3"> from any context other than a </span><span class="s4">late()</span><span class="s3"> event causes a warning; calling from a </span><span class="s4">late()</span><span class="s3"> event is almost always correct in WF models, so that fitness values can be automatically recalculated by SLiM at the usual time in the tick cycle without the need to force their recalculation (see comments on </span><span class="s4">recalculateFitness()</span><span class="s3">).</span></p>
964963
<p class="p6"><span class="s3">In SLiM 3.0 when using the nonWF model, calling </span><span class="s4">readFromPopulationFile()</span><span class="s3"> from any context other than an </span><span class="s4">early()</span><span class="s3"> event causes a warning; calling from an </span><span class="s4">early()</span><span class="s3"> event is almost always correct in nonWF models, so that fitness values can be automatically recalculated by SLiM at the usual time in the tick cycle without the need to force their recalculation (see comments on </span><span class="s4">recalculateFitness()</span><span class="s3">).</span></p>
965964
<p class="p6">As of SLiM 2.1, this method changes the tick and cycle counters to the tick and cycle read from the file.<span class="Apple-converted-space">  </span>If you do not want these counters to be changed, you can change them back after reading, by setting <span class="s1">community.tick</span> and <span class="s1">sim.cycle</span> to whatever values you wish.<span class="Apple-converted-space">  </span>Note that restoring a saved past state and running forward again will not yield the same simulation results, because the random number generator’s state will not be the same; to ensure reproducibility from a given time point, <span class="s1">setSeed()</span> can be used to establish a new seed value.<span class="Apple-converted-space">  </span>Any changes made to structure of the species (mutation types, genomic element types, etc.) will not be wiped and re-established by <span class="s1">readFromPopulationFile()</span>; this method loads only the population’s state, not the species configuration, so care should be taken to ensure that the species structure meshes coherently with the loaded data.<span class="Apple-converted-space">  </span>Indeed, state such as the selfing and cloning rates of subpopulations, values set into <span class="s1">tag</span> properties, and values set onto objects with <span class="s1">setValue()</span> will also be lost, since it is not saved out by <span class="s1">outputFull()</span>.<span class="Apple-converted-space">  </span>Only information saved by <span class="s1">outputFull()</span> will be restored; all other state associated with the species – subpopulations, individuals, haplosomes, mutations, and substitutions – will be lost, and should be re-established by the model if it is still needed.</p>

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8731,7 +8731,7 @@ In SLiM 3.3 and later, the output format includes the nucleotides associated wit
87318731
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
87328732

87338733
\f3\fs18 \cf0 \'96\'a0(integer$)readFromPopulationFile(string$\'a0filePath\cf2 , [No<Dictionary>$\'a0subpopMap\'a0=\'a0NULL]\cf0 )\
8734-
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
8734+
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
87358735

87368736
\f4\fs20 \cf2 Read from a population initialization file, whether in text or binary format as previously specified to
87378737
\f3\fs18 outputFull()
@@ -8746,24 +8746,17 @@ In SLiM 3.3 and later, the output format includes the nucleotides associated wit
87468746
\f4\fs20 and have element type
87478747
\f3\fs18 Subpopulation
87488748
\f4\fs20 ,
8749-
\f3\fs18 \cf0 Haplosome
8750-
\f4\fs20 \cf2 ,
8749+
\f3\fs18 Haplosome
8750+
\f4\fs20 ,
87518751
\f3\fs18 Mutation
87528752
\f4\fs20 ,
87538753
\f3\fs18 Individual
87548754
\f4\fs20 , or
87558755
\f3\fs18 Substitution
87568756
\f4\fs20 will be removed as a side effect of this method if they contain any element that belongs to the target species, because those objects will no longer exist in the SLiM simulation; if you want to preserve any of that state, you should output it or save it to a file prior to this call. New symbols will be defined to refer to the new
87578757
\f3\fs18 Subpopulation
8758-
\f4\fs20 objects loaded from the file.\
8759-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
8760-
\cf2 If the file being read was written by a version of SLiM prior to 2.3, then for backward compatibility fitness values will be calculated immediately for any new subpopulations created by this call, which will trigger the calling of any activated and applicable
8761-
\f3\fs18 mutationEffect()
8762-
\f4\fs20 and
8763-
\f3\fs18 fitnessEffect()
8764-
\f4\fs20 callbacks. When reading files written by SLiM 2.3 or later, fitness values are not calculated as a side effect of this call (because the simulation will often need to evaluate interactions or modify other state prior to doing so).\
8765-
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
8766-
\cf2 \expnd0\expndtw0\kerning0
8758+
\f4\fs20 objects loaded from the file. Note that fitness values are not calculated as a side effect of this call (because the simulation will often need to evaluate interactions or modify other state prior to doing so).\
8759+
\expnd0\expndtw0\kerning0
87678760
In SLiM 2.3 and later when using the WF model, calling
87688761
\f3\fs18 readFromPopulationFile()
87698762
\f4\fs20 from any context other than a

SLiMgui/SLiMWindowController.mm

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,8 +3098,7 @@ - (IBAction)dumpPopulationToOutput:(id)sender
30983098
slim_tick_t species_cycle = displaySpecies->Cycle();
30993099

31003100
// dump the population
3101-
SLIM_OUTSTREAM << "#OUT: " << community->tick_ << " " << species_cycle << " A" << std::endl;
3102-
displaySpecies->population_.PrintAll(SLIM_OUTSTREAM, true, true, false, false); // output spatial positions and ages if available, but not ancestral sequence
3101+
displaySpecies->population_.PrintAll(SLIM_OUTSTREAM, true, true, false, false, false); // output spatial positions and ages if available, but not ancestral sequence or tags
31033102

31043103
// dump fixed substitutions also; so the dump in SLiMgui is like outputFull() + outputFixedMutations()
31053104
SLIM_OUTSTREAM << std::endl;
@@ -3290,10 +3289,8 @@ - (IBAction)exportPopulation:(id)sender
32903289

32913290
// BCH 3/6/2022: Note that the species cycle has been added here for SLiM 4, in keeping with SLiM's native output formats.
32923291
Species *displaySpecies = [self focalDisplaySpecies];
3293-
slim_tick_t species_cycle = displaySpecies->Cycle();
32943292

3295-
outstring << "#OUT: " << community->tick_ << " " << species_cycle << " A " << std::endl;
3296-
displaySpecies->population_.PrintAll(outstring, true, true, true, false); // include spatial positions, ages, and ancestral sequence, if available
3293+
displaySpecies->population_.PrintAll(outstring, true, true, true, false, true); // include spatial positions, ages, ancestral sequence, and tags, if available
32973294

32983295
std::string &&population_dump = outstring.str();
32993296
NSString *populationDump = [NSString stringWithUTF8String:population_dump.c_str()];

VERSIONS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ development head (in the master branch):
126126
Subpopulation method outputVCFSample(): check that all haplosomes belong to a single chromosome; use chromosome symbols for the CHROM column
127127
add [l$ groupAsIndividuals = T] parameter; if F, each haplosome is emitted as a haploid call rather than forming diploids, regardless of the chromosome's ploidy
128128
Haplosome_Class::ExecuteMethod_readFromVCF(): require VCF data that is single-chromosome, as with output
129+
fix built-in SLiM-format full input/output methods for multiple chromosomes:
130+
Species method outputFull(): allow multi-chromosome output with a new sectioned format, for both text and binary
131+
Species method readFromPopulationFile(): support reading multi-chromosome output, for both text and binary
132+
policy change: readFromPopulationFile() breaks backward compatibility with old file formats, for both text and binary; too much has changed
129133

130134

131135
version 4.3 (Eidos version 3.3):

0 commit comments

Comments
 (0)