Alexander Martinez-Marchese's Home Page

Simple cell model

This program recreates the results obtained in this paper: Self-maintenance and Self-reproduction in an Abstract Cell Model. The paper presents a compartmentalized chemical reactor model that aims to show in an abstract way how chemical reactions can produce cell like entities that maintain themselves and replicate. I was impressed how it could do all these things while still being a chemical reactor simulation. This model demonstrates in an abstract way abiogenesis, autopoiesis and self-replication.

This is done by having 5 different particles that can move in 200 (this value can be changed in the program) different sites arranged side by side. The boundaries are periodic. The particles move and change to other particles based on the particles present in their site and in the two adjacent sites. The number of particles in the system is always constant. For more information on the reaction and motion rules consult the paper.

Here are the c programs: artificialCellFast.c, functionsFast.h and random.h.

Abiogenesis means the origin of life and in the program this is shown by the generation of cells from uniform initial conditions as shown in the following two graphs:

Autopoiesis means self maintenance and in the program this is shown by having a cell without a membrane as an initial condition and showing how the contents of the cell diffuse outward over time (with the membrane there has to be self-maintenance since the insides of the cell (mostly A particles) stay on the inside when there are M (membrane) particles around them as shown in the self-replication demonstration). The initial condition and end state graphs are shown below:

Self-replication is shown by having one complete cell as an initial condition and showing how it divides into two cells over time (the cell should be able to divide into more than two cells as shown in the paper but that was observed only once). There are two types of replication reported in the paper: internal cell replication (the usual kind of biological replication) and external replication (cells form besides already fomed cells). The problem with this statement is that cells can also form by abiogenesis also although the appearance of membranes close to the initial cell in an early time in the simulation suggests external replication. The replication process is shown in the two graphs below:

Design issues:

How do you choose from a site at random and then from a non chosen site until all sites are chosen?

You use another array to mark the chosen sites and then choose a number at random between 1 and (total sites-chosen sites) as shown in the following code fragment:

for(remainingSpaces = LATTICE_SIZE; remainingSpaces > 0; remainingSpaces--) {

       locationSite = genrand_int32()%remainingSpaces + 1;

       for(j=0; j < LATTICE_SIZE; j++){
           if(sites[j] == 0)
           locationSite--;

           if(locationSite == 0){
           sites[j] = 1;
           mobility(j);
           j = LATTICE_SIZE;
           }
       }
}

Here is a program to test this code fragment: artificialCellTest.c

Programming issues:

How do you make a function that gives you a 1 or 0 based on a very small probability?

The small size of the probabilities actually caused a bug in the simulation since the random number generator native to C can't produce large enough numbers (I use the inverse of the probabilities) as shown in functions.h so I used another random number generator from the internet which is also faster and more random.

How do you conserve the amount of particles?

This seems like a simple problem at first. The paper states to just grab a particle at random and place it where the particle that moved was but you have to check if one of the 5 particles you chose are actually there. This caused a hard to trace bug since the cases where there are no of the chosen particles are low, so you end up with predictable numbers after 100 iterations but after 100000 iterations you end up with  -1535876 particles.
What was needed was the following function:

void addParticle(int i, int side){
int j, caseNum, chemical[5] = {1,1,1,1,1};

if(pA2[side] == 0)
chemical[0] = 0;
if(pE2[side] == 0)
chemical[1] = 0;
if(pM2[side] == 0)
chemical[2] = 0;
if(pR2[side] == 0)
chemical[3] = 0;
if(pW2[side] == 0)
chemical[4] = 0;

if((chemical[0]+chemical[1]+chemical[2]+chemical[3]+chemical[4]) == 0)
return;
else caseNum = 1 + genrand_int32()%(chemical[0]+chemical[1]+chemical[2]+chemical[3]+chemical[4]);

for(j=0; j < 5; j++){
       if(chemical[j] == 1)
       caseNum--;
       if(caseNum == 0)
       {caseNum = j; j = 5;}
}

if(caseNum == 0) {pA2[side]--; pA2[i]++;}
if(caseNum == 1) {pE2[side]--; pE2[i]++;}
if(caseNum == 2) {pM2[side]--; pM2[i]++;}
if(caseNum == 3) {pR2[side]--; pR2[i]++;}
if(caseNum == 4) {pW2[side]--; pW2[i]++;}
}

This is functionally like one iteration of the loop shown in the design issues section.

Can the simulation be speeded up using pointers?

After some experimentation the simulation became faster but not by that much. First of all the random number generation is most of the computational overhead and secondly the mobility function can't be speeded up using pointers; you can't use the normal "trick" used in cellular automata simulations were the next state is computed in array2 from array1 for example and then the addresses are switched. This can only be done in the transition function since the next state of the site doesn't depend on the neighbours.