How to do it...

Take a look at the following steps:

  1. Let's start with the boilerplate variable initialization:
from collections import OrderedDictfrom copy import deepcopyimport simuPOP as spnum_loci = 10pop_size = 1000num_gens = 101init_ops = OrderedDict()pre_ops = OrderedDict()post_ops = OrderedDict()def init_accumulators(pop, param):    accumulators = param    for accumulator in accumulators:        pop.vars()[accumulator] = []    return Truedef update_accumulator(pop, param):    accumulator, var = param    pop.vars()[accumulator].append(deepcopy(pop.vars()[var]))    return Truepops = sp.Population(pop_size, loci=[1] * num_loci, infoFields=['fitness'])

Most of this code was explained in the previous recipe, but look at the very last line. There is now an infoFields ...

Get Bioinformatics with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.