MesserLab / SLiM

SLiM is a genetically explicit forward simulation software package for population genetics and evolutionary biology. It is highly flexible, with a built-in scripting language, and has a cross-platform graphical modeling environment called SLiMgui.
https://messerlab.org/slim/
GNU General Public License v3.0
160 stars 30 forks source link

treeSeqSimplify not recognized by SLiM #450

Closed bguo068 closed 2 months ago

bguo068 commented 2 months ago

Hi @bhaller,

I am working on sampling some ancestors from 2000 generations before the last generation during a forward simulation in SLiM. According to the SLiM Manual (v4.2.2) and SLiMgui Help, one can disable SLiM's auto-simplification by setting simplificationRatio=INF in the initializeTreeSeq() function and then manually calling the treeSeqSimplify() method. However, it seems that SLiM does not recognize the treeSeqSimplify function. Below is my SLiM script:

initialize()
{
    initializeTreeSeq(simplificationRatio=INF); // turn off autosimplifcation
    initializeMutationRate(0);
    initializeMutationType("m1", 0.5, "f", 0.0); // neutral
    initializeGenomicElementType("g1", m1, 1.0);
    initializeGenomicElement(g1, 0, 50*1000);
    initializeRecombinationRate(1e-8);

}

late()
{
    // manually simplify treeseq at interval of 1000 generations 
    // but leave unsimplified for recent 1000 generations
    if (sim.cycle == 1000) {
        treeSeqSimplify();
    }else   if (sim.cycle > 1000 & sim.cycle % 1000 == 0){
        treeSeqSimplify();
    }

}

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

200000 early()
{
    sim.simulationFinished();
    sim.treeSeqOutput("slim.trees");
}

It generates error message below:

// Initial random seed:
3525993084394076220

// RunInitializeCallbacks():
initializeTreeSeq(simplificationRatio = inf);
initializeMutationRate(0);
initializeMutationType(1, 0.5, "f", 0);
initializeGenomicElementType(1, m1, 1);
initializeGenomicElement(g1, 0, 50000);
initializeRecombinationRate(1e-08);

// Starting run at tick <start>:
1 

ERROR (EidosInterpreter::Evaluate_Call): unrecognized function name treeSeqSimplify.

Error on script line 17, character 2:

      treeSeqSimplify();

Any suggestions?

bguo068 commented 2 months ago

Just found it's under sim (sim.treeSeqSimplify()). Closing it now.

bhaller commented 2 months ago

Yes, "functions" are called independently (like, say, sum()), whereas "methods" are called on an object of a particular class (like sim.treeSeqSimplify()). If you look in the doc you can find out whether something is a function or a method, what type of object a method needs to be called on, etc.

bguo068 commented 2 months ago

I apologize for not reading it carefully. Thank you for the explanation. Happy 4th of July!