Ejemplo n.º 1
0
 def test_register_engine(self):
     class MyEngine(stdpopsim.Engine):
         id = "test-engine"
         name = "test"
         citations = []
     engine1 = MyEngine()
     stdpopsim.register_engine(engine1)
     engine2 = stdpopsim.get_engine(engine1.id)
     self.assertEqual(engine1, engine2)
     # remove engine to avoid possible problems with other tests
     del stdpopsim.engines._registered_engines[engine1.id]
Ejemplo n.º 2
0
 def test_register_duplicate(self):
     engine = stdpopsim.get_default_engine()
     with self.assertRaises(ValueError):
         stdpopsim.register_engine(engine)
Ejemplo n.º 3
0
        SLiM tree sequence following the procedure that would have been used
        if stdpopsim had run SLiM itself.
        The parameters after ``ts`` have the same meaning as for :func:`simulate`,
        and the values for ``demographic_model``, ``contig``, ``samples``,
        and ``slim_scaling_factor`` should match those that were used to
        generate the SLiM script with :func:`simulate`.

        :param ts: The tree sequence output by SLiM.
        :type ts: :class:`pyslim.SlimTreeSequence`

        .. warning::
            The :func:`recap_and_rescale` function is provided in the hope that
            it will be useful. But as we can't anticipate what changes you'll
            make to the SLiM code before using it, the stdpopsim source code
            should be consulted to determine if it's behaviour is appropriate
            for your case.
        """
        with open(os.devnull, "w") as script_file:
            recap_epoch = slim_makescript(script_file, "unused.trees",
                                          demographic_model, contig, samples,
                                          slim_scaling_factor, 1)

        ts = self._recap_and_rescale(ts, seed, recap_epoch, contig,
                                     contig.mutation_rate, slim_scaling_factor)
        return ts


# SLiM does not currently work on Windows.
if sys.platform != "win32":
    stdpopsim.register_engine(_SLiMEngine())