def test_selfing_after_outcrossing(self):
        """Test scinario: generations of selfing after generations of outcrossing."""

        # outcrossing
        self.sim.evolve(initOps=self.initOps,
                        matingScheme=simu.RandomMating(
                            subPopSize=10,
                            sexMode=self.sexMode,
                            ops=[
                                simu.MendelianGenoTransmitter(),
                                cf.MyOutcrossingTagger()
                            ]),
                        gen=10)

        for pop in self.sim.populations():
            for ind in pop.individuals():
                assert ind.info('self_gen') == 0

        assert pop.dvars().gen == 10

        # selfing
        self.sim.evolve(
            initOps=self.initOps,
            matingScheme=simu.SelfMating(
                subPopSize=10,
                sexMode=self.sexMode,
                ops=[simu.SelfingGenoTransmitter(),
                     cf.MySelfingTagger()]),
            gen=10)

        for pop in self.sim.populations():
            for ind in pop.individuals():
                assert ind.info('self_gen') == 10

        assert pop.dvars().gen == 20
    def test_pure_selfing(self):
        """Test pure inbreeding population.

        When all individuals undergo selfing, the values in `self_gen` should be identical
        to the number of generations since simulations started.
        """
        self.sim.evolve(
            initOps=self.initOps,
            matingScheme=simu.SelfMating(
                subPopSize=10,
                sexMode=self.sexMode,
                ops=[simu.SelfingGenoTransmitter(),
                     cf.MySelfingTagger()]),
            gen=10)

        for pop in self.sim.populations():
            for ind in pop.individuals():
                assert ind.info('self_gen') == 10
Ejemplo n.º 3
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This script is an example in the simuPOP user's guide. Please refer to
# the user's guide (http://simupop.sourceforge.net/manual) for a detailed
# description of this example.
#

import simuPOP as sim
pop = sim.Population(100, loci=5 * 3, infoFields='parent_idx')
pop.evolve(initOps=[sim.InitGenotype(freq=[0.2] * 5)],
           preOps=sim.Dumper(structure=False, max=5),
           matingScheme=sim.HomoMating(
               sim.SequentialParentChooser(),
               sim.OffspringGenerator(ops=[
                   sim.SelfingGenoTransmitter(),
                   sim.ParentsTagger(infoFields='parent_idx'),
               ])),
           postOps=sim.Dumper(structure=False, max=5),
           gen=1)
Ejemplo n.º 4
0
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This script is an example in the simuPOP user's guide. Please refer to
# the user's guide (http://simupop.sourceforge.net/manual) for a detailed
# description of this example.
#

import simuPOP as sim
def traj(gen):
    return [0.5 + gen * 0.01]

pop = sim.Population(1000, loci=[10]*2)
# evolve the sim.Population while keeping allele frequency 0.5
pop.evolve(
    initOps=[
        sim.InitSex(),
        sim.InitGenotype(freq=[0.5, 0.5])
    ],
    matingScheme=sim.HomoMating(sim.RandomParentChooser(),
        sim.ControlledOffspringGenerator(loci=5,
            alleles=[0], freqFunc=traj,
            ops = sim.SelfingGenoTransmitter())),
    postOps=[
        sim.Stat(alleleFreq=[5, 15]),
        sim.PyEval(r'"%.2f\t%.2f\n" % (alleleFreq[5][0], alleleFreq[15][0])')
    ],
    gen = 5
)

Ejemplo n.º 5
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This script is an example in the simuPOP user's guide. Please refer to
# the user's guide (http://simupop.sourceforge.net/manual) for a detailed
# description of this example.
#

import simuPOP as sim
pop = sim.Population(size=[1000],
                     loci=2,
                     infoFields=['father_idx', 'mother_idx'])
pop.setVirtualSplitter(sim.ProportionSplitter([0.2, 0.8]))
pop.evolve(
    initOps=sim.InitSex(),
    matingScheme=sim.HeteroMating(matingSchemes=[
        sim.SelfMating(subPops=[(0, 0)],
                       ops=[sim.SelfingGenoTransmitter(),
                            sim.ParentsTagger()]),
        sim.RandomMating(
            subPops=[(0, 1)],
            ops=[sim.SelfingGenoTransmitter(),
                 sim.ParentsTagger()])
    ]),
    gen=10)
[int(ind.father_idx) for ind in pop.individuals(0)][:15]
[int(ind.mother_idx) for ind in pop.individuals(0)][:15]