Skip to content

unreferenced mutation from multiple reload #642

Description

@petrelharp

I suspect there is a simpler way to make this happen, but I haven't been able to arrive at it. If you first run this script to create in.trees:

initialize()
{
    setSeed(23);
    initializeSLiMOptions(nucleotideBased=T);
    initializeTreeSeq(timeUnit="generations");
	 initializeSex();
	 initializeMutationTypeNuc("m1", 0.5, "f", 0.0);
	 initializeMutationType("m2", 0.5, "n", 0.0, 0.1);
	 initializeGenomicElementType("g1", m1, 1.0, mmJukesCantor(8e-2));
    defineConstant("L", 100);
	 initializeChromosome(1, L, type="X", symbol="X");
    initializeGenomicElement(g1, 0, L-1);
    initializeAncestralNucleotides(randomNucleotides(L));
    initializeRecombinationRate(1e-2);
}

1 early() { 
    sim.addSubpop("p1", 10);
}

10 late() {
    sim.treeSeqOutput("in.trees");
}

And then you reload it into SLiM and write it out again immediately as out.trees by running this script:

initialize()
{
   setSeed(25);
   if (!exists("TREES_FILE")) defineGlobal("TREES_FILE", "out.trees"); 
   if (!exists("TREES_IN")) defineGlobal("TREES_IN", "in.trees"); 
	defineConstant("L", 1e2);
	initializeSLiMOptions(keepPedigrees=T, nucleotideBased=T);
   initializeTreeSeq(timeUnit="generations");
   initializeSex();
	initializeMutationTypeNuc("m1", 0.5, "f", 0.0);
   initializeMutationTypeNuc("m2", 0.5, "n", 0.0, 0.1);
	initializeGenomicElementType("g1", m1, 1.0, mmJukesCantor(4e-2));
   initializeChromosome(1, L, type="X", symbol="X");
	initializeAncestralNucleotides(paste0(rep("A", L)));
	initializeGenomicElement(g1, 0, L-1);
	initializeRecombinationRate(1e-2);
}

1 late() { 
    // output immediately! Nothing should have changed.
    md = treeSeqMetadata(TREES_IN, userData=F).getValue("SLiM").getValue("user_metadata");
    sim.readFromPopulationFile(TREES_IN);
    sim.treeSeqOutput(TREES_FILE, simplify=F, metadata=md);
}

2 early() {
    sim.simulationFinished();
}

And then you re-run the script above as follows: with the script named restart.slim, running

slim -d "TREES_IN='out.trees'" -d "TREES_FILE='out2.trees'" restart.slim

then I get

ERROR (Species::__TabulateMutationsFromTables): mutation id 809 referenced by a derived state is not in the mutation metadata table.

Error on script line 22, character 8:

    sim.readFromPopulationFile(TREES_IN);

Seems like some important mutational info read in from in the top-level metadata didn't make it into wherever it needed to be to written out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions