当前位置: 首页>>代码示例>>Python>>正文


Python Population.genPopulation方法代码示例

本文整理汇总了Python中Population.Population.genPopulation方法的典型用法代码示例。如果您正苦于以下问题:Python Population.genPopulation方法的具体用法?Python Population.genPopulation怎么用?Python Population.genPopulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Population.Population的用法示例。


在下文中一共展示了Population.genPopulation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generateTests

# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import genPopulation [as 别名]
def generateTests():
    # Test IP
    # 6 alleles, 6 loci, popSize /  3 mothers and fathers, 5 children
    for i in range(10, 26, 5):
        for j in range(10):
            rSeed = 1399 * i + 931 * j
            pop = Population(6, 6, i / 3, i / 3, 5, 5, randomSeed=rSeed)
            pop.genPopulation(i)
            random.shuffle(pop.individuals)

            pop.saveState("tests/ip/%d_6_6_%d.pkl" % (i, j))

    # Test number of alleles
    # 6 loci, 7 mothers, 7 fathers, 5 children, 40 individuals
    alleles = [2, 5, 10, 15, 20]
    for i in alleles:
        for j in range(10):
            rSeed = 293 * i + 13 * j
            pop = Population(i, 6, 7, 7, 5, 5, randomSeed=rSeed)
            pop.genPopulation(40)
            random.shuffle(pop.individuals)

            if i < 10:
                nA = "0%d" % (i)
            else:
                nA = str(i)
            pop.saveState("tests/alleles/40_%s_6_%s.pkl" % (nA, str(j)))

    # Test number of loci
    # 6 alleles, 7 mothers, 7 fathers, 5 children, 40 individuals
    loci = [2, 5, 10, 15, 20]
    for i in loci:
        for j in range(10):
            rSeed = 631 * i + 17 * j
            pop = Population(6, i, 7, 7, 5, 5, randomSeed=rSeed)
            pop.genPopulation(40)
            random.shuffle(pop.individuals)

            if i < 10:
                nL = "0%d" % (i)
            else:
                nL = str(i)
            pop.saveState("tests/loci/40_6_%s_%d.pkl" % (nL, j))

    # Test number of individuals
    # 6 alleles, 6 loci, popSize /  3 mothers and fathers, 5 children
    popSizes = [10, 50, 100, 200]
    for i in popSizes:
        for j in range(10):
            rSeed = 37 * i + 931 * j
            pop = Population(6, 6, i / 3, i / 3, 5, 5, randomSeed=rSeed)
            pop.genPopulation(i)
            random.shuffle(pop.individuals)

            if i < 10:
                nI = "00%d" %False
            elif i < 100:
                nI = "0%d" % (i)
            else:
                nI = str(i)
            pop.saveState("tests/indivs/%s_6_6_%d.pkl" % (nI, j))

    # Test family size
    # 80 individuals, 6 alleles, 6 loci, 7 mothers and fathers
    famSizes = [1, 5, 10, 20]
    for i in famSizes:
        for j in range(10):
            rSeed = 31 * i + 1931 * j
            pop = Population(6, 6, 20, 20, i, i, randomSeed=rSeed)
            pop.genPopulation(80)
            random.shuffle(pop.individuals)

            if i < 10:
                nI = "0%d" % (i)
            else:
                nI = str(i)
            pop.saveState("tests/famsize/80_6_6_%s_%d.pkl" % (nI, j))

    # Test included families
    # 40 individuals, 6 alleles, 6 loci, 7 mothers and fathers
    for i in range(10):
        rSeed = 329019 * i
        pop = Population(6, 6, 8, 8, 5, 5, randomSeed=rSeed)
        pop.genPopulation(40)
        random.shuffle(pop.individuals)

        pop.saveState("tests/big/40_6_6_%d.pkl" % (i))

    popSizes = [500, 1000, 2000]
    for i in popSizes:
        for j in range(10):
            rSeed = 371 * i + 1931 * j
            pop = Population(6, 10, i / 20, i / 20, 20, 20, randomSeed=rSeed)
            pop.genPopulation(i)
            random.shuffle(pop.individuals)

            nI = ''
            if i < 1000:
                nI = "0%d" % (i)
            else:
#.........这里部分代码省略.........
开发者ID:BioinformaticsArchive,项目名称:SibJoin,代码行数:103,代码来源:testSibships.py


注:本文中的Population.Population.genPopulation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。