Exemplo n.º 1
0
    def test_two_events(self):
        expected_events = [
            msprime.AncestryModelChange(time=1,
                                        model=msprime.StandardCoalescent()),
            msprime.AncestryModelChange(time=2,
                                        model=msprime.SmcApproxCoalescent()),
        ]
        model, events = ancestry._parse_model_arg(
            ["dtwf", (1, "hudson"), (2, "smc")])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == expected_events

        model, events = ancestry._parse_model_arg(
            ["dtwf", (1, None), (2, msprime.SmcApproxCoalescent())])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == expected_events

        model, events = ancestry._parse_model_arg(
            ["dtwf", expected_events[0], (2, msprime.SmcApproxCoalescent())])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == expected_events

        model, events = ancestry._parse_model_arg(
            ["dtwf", expected_events[0], (2, msprime.SmcApproxCoalescent())])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == expected_events
        assert events[0] is not expected_events[0]

        model, events = ancestry._parse_model_arg(["dtwf"] + expected_events)
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == expected_events
        assert events[0] is not expected_events[0]
        assert events[1] is not expected_events[1]
Exemplo n.º 2
0
    def test_one_event(self):
        expected_event = msprime.AncestryModelChange(
            time=1.33, model=msprime.StandardCoalescent())
        model, events = ancestry._parse_model_arg(["dtwf", (1.33, "hudson")])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == [expected_event]

        model, events = ancestry._parse_model_arg(["dtwf", (1.33, None)])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == [expected_event]

        model, events = ancestry._parse_model_arg(
            ["dtwf", (1.33, msprime.StandardCoalescent())])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == [expected_event]

        model, events = ancestry._parse_model_arg(["dtwf", expected_event])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == [expected_event]
        # We should take a copy of the event.
        assert events[0] is not expected_event

        model, events = ancestry._parse_model_arg(["dtwf", (None, None)])
        assert model == msprime.DiscreteTimeWrightFisher()
        assert events == [
            msprime.AncestryModelChange(time=None,
                                        model=msprime.StandardCoalescent())
        ]
Exemplo n.º 3
0
 def test_many_models_sim_ancestry(self):
     ts = msprime.sim_ancestry(
         samples=10,
         population_size=10_000,
         model=[
             "hudson",
             msprime.AncestryModelChange(10, msprime.StandardCoalescent()),
             msprime.AncestryModelChange(20, msprime.SmcApproxCoalescent()),
             msprime.AncestryModelChange(
                 30, msprime.SmcPrimeApproxCoalescent()),
             msprime.AncestryModelChange(
                 40, msprime.DiscreteTimeWrightFisher()),
             msprime.AncestryModelChange(50,
                                         msprime.BetaCoalescent(alpha=1.1)),
             msprime.AncestryModelChange(60, msprime.StandardCoalescent()),
         ],
         random_seed=10,
     )
     for tree in ts.trees():
         assert tree.num_roots == 1