Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

individuals_alive_at( ) does not work with WF models #43

Closed
petrelharp opened this issue Jul 1, 2019 · 1 comment
Closed

individuals_alive_at( ) does not work with WF models #43

petrelharp opened this issue Jul 1, 2019 · 1 comment

Comments

@petrelharp
Copy link
Contributor

petrelharp commented Jul 1, 2019

As discovered in #38, individuals_alive_at( ) doesn't work with WF models.

Here is a simple SLiM recipe:

initialize()
{
    setSeed(23);
    initializeTreeSeq();
    initializeMutationRate(1e-2);
    initializeMutationType("m1", 0.5, "f", -0.1);
    initializeGenomicElementType("g1", m1, 1.0);
    initializeGenomicElement(g1, 0, 99);
    initializeRecombinationRate(1e-2);
}

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

10 {
    sim.treeSeqOutput("remember.trees");
    catn("Done.");
    sim.simulationFinished();
}

but individuals_alive_at() does not show anyone alive at any time:

import pyslim
import numpy as np

ts = pyslim.load("remember.trees")

print(ts.num_individuals)
print([len(ts.individuals_alive_at(x)) for x in range(20)])

A look at the code reveals that the code uses individual_ages, which are all -1 in WF models. Whoops. I guess this wasn't being tested in a WF model. (damn bifurcating code paths)

One solution would be an if statement in the code, checking if it's a WF model. But I think it would make much more sense to actually set individual_ages all to 0 for a WF model, since that's actually what their ages are.

@petrelharp
Copy link
Contributor Author

Fixed in 6121876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant