Learning Scientific Programming with Python (2nd edition)

P6.6.3: A simple model for chemotaxis

Question P6.6.3

Some bacteria, such as E. coli, possess helical flagella which enable them to move towards attractants such as nutrients, process known as chemotaxis. When the flagella rotate anti-clockwise the bacterium is propelled forwards; when they rotate clockwise, it tumbles randomly, changing its orientation. A combination of such movements enables the bacterium to perform a biased random walk: if the bacterium senses it is moving up a concentration gradient towards an attractant it will rotate its flagella anti-clockwise more often than clockwise so as to continue moving in that direction; conversely, if it is moving away it is more likely to rotate its flagella clockwise so as to tumble with the aim of randomly changing its orientation to one which points it towards the attractant.

The chemotaxis of E. coli may be modelled (very) simplistically by considering a bacterium to move in a two-dimensional "world" populated by an attractant with a constant concentration gradient away from some location. At each of a series of time steps, a model bacterium detects whether it is moving up or down this gradient and either continues moving or tumbles according to some pair of probabilities.

Write a Python program to implement this simple model of chemotaxis for a world consisting of the unit square with an attractant at its centre. Plot the locations of 10 model bacteria which start off evenly spaced around the unit circle centred on the attractant location.