C Code


molecules.h:


typedef enum Boolean_e

{False, // 0

True } // 1

Boolean_t;


typedef struct Molecule_s

{

long number;

double Pgenerate; // probability

double Pdegrade; // probability

} Molecule_t;


typedef struct PhosphorylatedTranscriptionFactor_s

{

Molecule_t mRNA;

Molecule_t native;

Molecule_t phosphorylated;

} PhosphorylatedTranscriptionFactor_t;


typedef struct InducedTranscriptionFactor_s

{

Molecule_t mRNA;

Molecule_t protein;

} InducedTranscriptionFactor_t;


typedef struct RegularorySequence_s

{

Molecule_t Site0;

Molecule_t Site1;

Molecule_t Site2;

} RegularorySequence_t;




functions.h:


#include "molecules.h"

#include <time.h>


double GetRandom();

Boolean_t RandomAction(double r);




functions.c:


#include <stdlib.h>

#include <time.h>

#include "functions.h"


double GetRandom() // [o;1[

{

static Boolean_t firstcall = True;

double value;

if (firstcall)

{

srand(time(NULL));

firstcall=False;

}

value=rand()/(double)RAND_MAX;

return value;

}



Boolean_t RandomAction(double r)

{

Boolean_t act = False;

if (GetRandom()<=r)

act = True;

return act;

}



main.c:



#ifdef HAVE_CONFIG_H

#include <config.h>

#endif


#include <stdio.h>

#include <stdlib.h>

#include "functions.h"


int main(int argc, char *argv[])

{


FILE *outhandle1;

FILE *outhandle2;

FILE *outhandle3;

FILE *outhandle4;

FILE *outhandle5;

FILE *outhandle6;


long step, i, phosphorylate, dephosphorylate, decay;

const char * const outfilename1="data1.crv";

const char * const outfilename2="data2.crv";

const char * const outfilename3="data3.crv";

const char * const outfilename4="data4.crv";

const char * const outfilename5="data5.crv";

const char * const outfilename6="data6.crv";


PhosphorylatedTranscriptionFactor_t TFA, TFB, TFC;

InducedTranscriptionFactor_t TFStart, TFmove, TFfound, TFdelay;

RegularorySequence_t Start, move, found, delay, A, B, C;


Boolean_t StatisticTFdelayATA[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFdelayATASum=0;

Boolean_t StatisticTFdelayATB[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFdelayATBSum=0;

Boolean_t StatisticTFdelayATC[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFdelayATCSum=0;

Boolean_t StatisticTFCStart[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFCStartSum=0;

Boolean_t StatisticTFdelayStart[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFdelayStartSum=0;

Boolean_t StatisticTFABStart[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFABStartSum=0;


Boolean_t StatisticTFfoundATmove[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFfoundATmoveSum=0;

Boolean_t StatisticTFStartATmove[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFStartATmoveSum=0;


Boolean_t StatisticTFmoveATfound[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFmoveATfoundSum=0;

Boolean_t StatisticTFdelayATfound[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFdelayATfoundSum=0;


Boolean_t StatisticTFfoundATdelay[1000]={False}; // Ansi C fills whole array with 0 = False

long StatisticTFfoundATdelaySum=0;



// Signaling molecules, variable total number, get phosphorylated when receptor activated


TFA.mRNA.number=40;

TFA.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFA.mRNA.Pdegrade=0.001; // probability mRNA decay


TFA.native.number=150;

TFA.native.Pgenerate=0.00015; // probability mRNA translation = protein generation per molecule of mRNA

TFA.native.Pdegrade=0.00005; // probability protein decay


TFA.phosphorylated.number=0;

TFA.phosphorylated.Pgenerate=0.04; // if receptor A = active

TFA.phosphorylated.Pdegrade=0.002; // phosphatases



TFB.mRNA.number=40;

TFB.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFB.mRNA.Pdegrade=0.001; // probability mRNA decay


TFB.native.number=120;

TFB.native.Pgenerate=0.00015; // probability mRNA translation = protein generation per molecule of mRNA

TFB.native.Pdegrade=0.0000625; // probability protein decay


TFB.phosphorylated.number=0;

TFB.phosphorylated.Pgenerate=0.04; // if receptor B = active

TFB.phosphorylated.Pdegrade=0.002; // phosphatases



TFC.mRNA.number=40;

TFC.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFC.mRNA.Pdegrade=0.001; // probability mRNA decay


TFC.native.number=215;

TFC.native.Pgenerate=0.00015; // probability mRNA translation = protein generation per molecule of mRNA

TFC.native.Pdegrade=0.000035; // probability protein decay


TFC.phosphorylated.number=0;

TFC.phosphorylated.Pgenerate=0.04; // if receptor C = active

TFC.phosphorylated.Pdegrade=0.002; // phosphatases



// regulatory sites


Start.Site0.number=0;

Start.Site0.Pgenerate=0.000012; // times number of TFC-phos homodimers

Start.Site0.Pdegrade=0.03; // off rate (first order) des TFs


Start.Site1.number=0;

Start.Site1.Pgenerate=0.00003; // times number of TFdelay-TF-delay heterodimers

Start.Site1.Pdegrade=0.03; // off rate (first order) des TFs


Start.Site2.number=0;

Start.Site2.Pgenerate=0.000012; // times number of TFA-phos/TFB-phos heterodimers

Start.Site2.Pdegrade=0.03; // off rate (first order) des TFs



A.Site0.number=0;

A.Site0.Pgenerate=0.00003; // times number of TFdelay-TF-delay heterodimers

A.Site0.Pdegrade=0.03; // off rate (first order) des TFs


B.Site0.number=0;

B.Site0.Pgenerate=0.00003; // times number of TFdelay-TF-delay heterodimers

B.Site0.Pdegrade=0.03; // off rate (first order) des TFs


C.Site0.number=0;

C.Site0.Pgenerate=0.00003; // times number of TFdelay-TF-delay heterodimers

C.Site0.Pdegrade=0.03; // off rate (first order) des TFs



move.Site0.number=0;

move.Site0.Pgenerate=0.000012; // times number of TFfound homodimers

move.Site0.Pdegrade=0.03; // off rate (first order) des TFs


move.Site1.number=0;

move.Site1.Pgenerate=0.000012; // times number of TFStart heterodimers

move.Site1.Pdegrade=0.03; // off rate (first order) des TFs


found.Site0.number=0;

found.Site0.Pgenerate=0.000012; // times number of TFmove homodimers

found.Site0.Pdegrade=0.03; // off rate (first order) des TFs


found.Site1.number=0;

found.Site1.Pgenerate=0.0000012; // times number of TFdelay homodimers

found.Site1.Pdegrade=0.03; // off rate (first order) des TFs



delay.Site0.number=0;

delay.Site0.Pgenerate=0; // not in use

delay.Site0.Pdegrade=0; //


delay.Site1.number=0;

delay.Site1.Pgenerate=0.000006; // times number of TFfound homodimers

delay.Site1.Pdegrade=0.03; // off rate (first order) des TFs



// TFs


TFStart.mRNA.number=0;

TFStart.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFStart.mRNA.Pdegrade=0.001; // probability mRNA decay


TFStart.protein.number=0;

TFStart.protein.Pgenerate=0.0015; // probability mRNA translation = protein generation per molecule of mRNA

TFStart.protein.Pdegrade=0.0005; // probability protein decay


TFmove.mRNA.number=40;

TFmove.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFmove.mRNA.Pdegrade=0.001; // probability mRNA decay


TFmove.protein.number=140;

TFmove.protein.Pgenerate=0.0015; // probability mRNA translation = protein generation per molecule of mRNA

TFmove.protein.Pdegrade=0.0003; // probability protein decay


TFfound.mRNA.number=0;

TFfound.mRNA.Pgenerate=0.05; // probability mRNA transcription (this value is regulated!)

TFfound.mRNA.Pdegrade=0.001; // probability mRNA decay


TFfound.protein.number=0;

TFfound.protein.Pgenerate=0.0015; // probability mRNA translation = protein generation per molecule of mRNA

TFfound.protein.Pdegrade=0.0003; // probability protein decay



TFdelay.mRNA.number=3; // estimate 3

TFdelay.mRNA.Pgenerate=0.0005; // probability mRNA transcription (this value is regulated!)

TFdelay.mRNA.Pdegrade=0.00001; // probability mRNA decay


TFdelay.protein.number=15; // estimate 15

TFdelay.protein.Pgenerate=0.00003; // probability mRNA translation = protein generation per molecule of mRNA

TFdelay.protein.Pdegrade=0.000006; // probability protein decay



// open files for write


if ((outhandle1=fopen(outfilename1,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename1);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename1);


if ((outhandle2=fopen(outfilename2,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename2);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename2);


if ((outhandle3=fopen(outfilename3,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename3);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename3);


if ((outhandle4=fopen(outfilename4,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename4);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename4);


if ((outhandle5=fopen(outfilename5,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename5);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename5);


if ((outhandle6=fopen(outfilename6,"w"))==0)

{

printf("Error opening file %s for write!\n", outfilename6);

return EXIT_FAILURE;

}

printf("File %s opened for write!\n", outfilename6);



// start simulation


printf("Beginn der Simulation, Start der Zeitschleife!\n");

for (step=0; step < 400000; step=step++) // long-time: 1500000

{


// TFdelay-TFdelay binding at sites A, B, C


if (A.Site0.number == 0)

{

if (RandomAction(A.Site0.Pgenerate*TFdelay.protein.number*TFdelay.protein.number)) // on rate depends on TFC^2 numbers = binding of homodimer

{

//printf("At %ld Homodimer TFdelay-TFdelay binds!\n", step);

A.Site0.number=1;

}

}

else

if (RandomAction(A.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFC-TFC goes off!\n", step);

A.Site0.number=0;

}

StatisticTFdelayATASum=StatisticTFdelayATASum-StatisticTFdelayATA[step%1000]+A.Site0.number; // step modulo 1000

StatisticTFdelayATA[step%1000]=A.Site0.number;


if (B.Site0.number == 0)

{

if (RandomAction(B.Site0.Pgenerate*TFdelay.protein.number*TFdelay.protein.number)) // on rate depends on TFC^2 numbers = binding of homodimer

{

//printf("At %ld Homodimer TFdelay-TFdelay binds!\n", step);

B.Site0.number=1;

}

}

else

if (RandomAction(B.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFC-TFC goes off!\n", step);

B.Site0.number=0;

}

StatisticTFdelayATBSum=StatisticTFdelayATBSum-StatisticTFdelayATB[step%1000]+B.Site0.number; // step modulo 1000

StatisticTFdelayATB[step%1000]=B.Site0.number;


if (C.Site0.number == 0)

{

if (RandomAction(C.Site0.Pgenerate*TFdelay.protein.number*TFdelay.protein.number)) // on rate depends on TFC^2 numbers = binding of homodimer

{

//printf("At %ld Homodimer TFdelay-TFdelay binds!\n", step);

C.Site0.number=1;

}

}

else

if (RandomAction(C.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFC-TFC goes off!\n", step);

C.Site0.number=0;

}

StatisticTFdelayATCSum=StatisticTFdelayATCSum-StatisticTFdelayATC[step%1000]+C.Site0.number; // step modulo 1000

StatisticTFdelayATC[step%1000]=C.Site0.number;


// mRNA transcription of transcription factors TFA, TFB and TFC


decay=0;

for (i=1; i<=TFA.mRNA.number; i=i++)

{

if (RandomAction(TFA.mRNA.Pdegrade)) decay=decay++;

}

TFA.mRNA.number=TFA.mRNA.number-decay;

if (A.Site0.number==0) // TFdelay provides receptor desensitization

{

if (RandomAction(TFA.mRNA.Pgenerate)) // transcription rate

TFA.mRNA.number=TFA.mRNA.number++;

}

else

if (RandomAction(TFA.mRNA.Pgenerate/20)) // transcription rate if blocked

TFA.mRNA.number=TFA.mRNA.number++;


decay=0;

for (i=1; i<=TFB.mRNA.number; i=i++)

{

if (RandomAction(TFB.mRNA.Pdegrade)) decay=decay++;

}

TFB.mRNA.number=TFB.mRNA.number-decay;

if (B.Site0.number==0) // TFdelay provides receptor desensitization

{

if (RandomAction(TFB.mRNA.Pgenerate)) // transcription rate

TFB.mRNA.number=TFB.mRNA.number++;

}

else

if (RandomAction(TFB.mRNA.Pgenerate/20)) // transcription rate if blocked

TFB.mRNA.number=TFB.mRNA.number++;


decay=0;

for (i=1; i<=TFC.mRNA.number; i=i++)

{

if (RandomAction(TFC.mRNA.Pdegrade))

decay=decay++;

}

TFC.mRNA.number=TFC.mRNA.number-decay;

if (C.Site0.number==0) // TFdelay provides receptor desensitization

{

if (RandomAction(TFC.mRNA.Pgenerate)) // transcription rate

TFC.mRNA.number=TFC.mRNA.number++;

}

else

if (RandomAction(TFC.mRNA.Pgenerate/20)) // transcription rate if blocked

TFC.mRNA.number=TFC.mRNA.number++;



// translation of mRNAs for natives TFA, TFB, TFC


decay=0;

for (i=1; i<=TFA.native.number; i++)

{

if (RandomAction(TFA.native.Pdegrade)) // both native protein

decay=decay++;

}

TFA.native.number=TFA.native.number-decay;

decay=0;

for (i=1; i<=TFA.phosphorylated.number; i++)

{

if (RandomAction(TFA.native.Pdegrade)) // and phosphorylated protein decay at same rate

decay=decay++; // namely TFA.native.Pdegrade

}

TFA.phosphorylated.number=TFA.phosphorylated.number-decay;

for (i=1; i<=TFA.mRNA.number; i++)

{

if (RandomAction(TFA.native.Pgenerate))

TFA.native.number=TFA.native.number++;

}


decay=0;

for (i=1; i<=TFB.native.number; i++)

{

if (RandomAction(TFB.native.Pdegrade)) // both native protein

decay=decay++;

}

TFB.native.number=TFB.native.number-decay;

decay=0;

for (i=1; i<=TFB.phosphorylated.number; i++)

{

if (RandomAction(TFB.native.Pdegrade)) // and phosphorylated protein decay at same rate

decay=decay++; // namely TFA.native.Pdegrade

}

TFB.phosphorylated.number=TFB.phosphorylated.number-decay;

for (i=1; i<=TFB.mRNA.number; i++)

{

if (RandomAction(TFB.native.Pgenerate))

TFB.native.number=TFB.native.number++;

}


decay=0;

for (i=1; i<=TFC.native.number; i++)

{

if (RandomAction(TFC.native.Pdegrade)) // both native protein

decay=decay++;

}

TFC.native.number=TFC.native.number-decay;

decay=0;

for (i=1; i<=TFC.phosphorylated.number; i++)

{

if (RandomAction(TFC.native.Pdegrade)) // and phosphorylated protein decay at same rate

decay=decay++; // namely TFA.native.Pdegrade

}

TFC.phosphorylated.number=TFC.phosphorylated.number-decay;

for (i=1; i<=TFC.mRNA.number; i++)

{

if (RandomAction(TFC.native.Pgenerate))

TFC.native.number=TFC.native.number++;

}



// TFA phosphorylation & dephosphorylation


phosphorylate=0;

if (((step>5000)&&(step<15000)) || ((step>55000)&&(step<80000)) || ((step>105000)&&(step<185000)) || ((step>350000)&&(step<360000)) || ((step>650000)&&(step<660000)) || ((step>850000)&&(step<860000)) || ((step>1050000)&&(step<1060000)) || ((step>1250000)&&(step<1260000)))// receptor A = active

{

for (i=1; i<=TFA.native.number; i=i++)

{

if (RandomAction(TFA.phosphorylated.Pgenerate))

phosphorylate=phosphorylate++;

}

}

dephosphorylate=0;

for (i=1; i<=TFA.phosphorylated.number; i=i++)

{

if (RandomAction(TFA.phosphorylated.Pdegrade))

dephosphorylate=dephosphorylate++;

}

TFA.native.number=TFA.native.number-phosphorylate+dephosphorylate;

TFA.phosphorylated.number=TFA.phosphorylated.number+phosphorylate-dephosphorylate;



// TFB phosphorylation & dephosphorylation


phosphorylate=0;

if (((step>25000)&&(step<35000)) || ((step>55000)&&(step<80000)) || ((step>125000)&&(step<158000)) || ((step>350000)&&(step<360000)) || ((step>650000)&&(step<660000)) || ((step>850000)&&(step<860000)) || ((step>1050000)&&(step<1060000)) || ((step>1250000)&&(step<1260000))) // receptor B = active

{

for (i=1; i<=TFB.native.number; i=i++)

{

if (RandomAction(TFB.phosphorylated.Pgenerate))

phosphorylate=phosphorylate++;

}

}

dephosphorylate=0;

for (i=1; i<=TFB.phosphorylated.number; i=i++)

{

if (RandomAction(TFB.phosphorylated.Pdegrade))

dephosphorylate=dephosphorylate++;

}

TFB.native.number=TFB.native.number-phosphorylate+dephosphorylate;

TFB.phosphorylated.number=TFB.phosphorylated.number+phosphorylate-dephosphorylate;



// TFC phosphorylation & dephosphorylation


phosphorylate=0;

if (((step>57500)&&(step<95000)) || ((step>115000)&&(step<135000))) // receptor C = active

{

for (i=1; i<=TFC.native.number; i=i++)

{

if (RandomAction(TFC.phosphorylated.Pgenerate))

phosphorylate=phosphorylate++;

}

}

dephosphorylate=0;

for (i=1; i<=TFC.phosphorylated.number; i=i++)

{

if (RandomAction(TFC.phosphorylated.Pdegrade))

dephosphorylate=dephosphorylate++;

}

TFC.native.number=TFC.native.number-phosphorylate+dephosphorylate;

TFC.phosphorylated.number=TFC.phosphorylated.number+phosphorylate-dephosphorylate;



// Binding of TFs at regulatory site "Start"


if (Start.Site0.number == 0)

{

if (RandomAction(Start.Site0.Pgenerate*TFC.phosphorylated.number*TFC.phosphorylated.number)) // on rate depends on TFC^2 numbers = binding of homodimer

{

//printf("At %ld Homodimer TFC-TFC binds!\n", step);

Start.Site0.number=1;

}

}

else

if (RandomAction(Start.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFC-TFC goes off!\n", step);

Start.Site0.number=0;

}

StatisticTFCStartSum=StatisticTFCStartSum-StatisticTFCStart[step%1000]+Start.Site0.number; // step modulo 1000

StatisticTFCStart[step%1000]=Start.Site0.number;


if (Start.Site1.number == 0)

{

if (RandomAction(Start.Site1.Pgenerate*TFdelay.protein.number*TFdelay.protein.number)) // on rate depends on TFC^2 numbers = binding of homodimer

{

//printf("At %ld Homodimer TFdelay-TFdelay binds!\n", step);

Start.Site1.number=1;

}

}

else

if (RandomAction(Start.Site1.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFC-TFC goes off!\n", step);

Start.Site1.number=0;

}

StatisticTFdelayStartSum=StatisticTFdelayStartSum-StatisticTFdelayStart[step%1000]+Start.Site1.number; // step modulo 1000

StatisticTFdelayStart[step%1000]=Start.Site1.number;


if (Start.Site2.number == 0)

{

if (RandomAction(Start.Site2.Pgenerate*TFA.phosphorylated.number*TFB.phosphorylated.number)) // on rate depends on TFA & TFB numbers = binding of heterodimer

{

//printf("At %ld Heterodimer TFA-TFB binds!\n", step);

Start.Site2.number=1;

}

}

else

if (RandomAction(Start.Site2.Pdegrade)) // decay rate

{

//printf("At %ld Heterodimer TFA-TFB goes off!\n", step);

Start.Site2.number=0;

}

StatisticTFABStartSum=StatisticTFABStartSum-StatisticTFABStart[step%1000]+Start.Site2.number; // step modulo 1000

StatisticTFABStart[step%1000]=Start.Site2.number;



// mRNA transcription at site "Start"


decay=0;

for (i=1; i<=TFStart.mRNA.number; i=i++)

{

if (RandomAction(TFStart.mRNA.Pdegrade))

decay=decay++;

}

TFStart.mRNA.number=TFStart.mRNA.number-decay;

// if (decay!=0) printf("At %ld decay von mRNA Molekuel(en) - total = %ld!\n", step, TFStart.mRNA.number);

if ((Start.Site0.number==0)&&(Start.Site1.number == 0)&&(Start.Site2.number == 1)) // Kern der logischen Verknuepfung

{

if (RandomAction(TFStart.mRNA.Pgenerate)) // transcription rate

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFStart.mRNA.number);

TFStart.mRNA.number=TFStart.mRNA.number++;

}

}

else

if (RandomAction(TFStart.mRNA.Pgenerate/20)) // transcription rate, 5% of maximum rate (as 0% seems unlikely)

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFStart.mRNA.number);

TFStart.mRNA.number=TFStart.mRNA.number++;

}


// protein translation of mRNA "Start"


decay=0;

for (i=1; i<=TFStart.protein.number; i++)

{

if (RandomAction(TFStart.protein.Pdegrade))

decay=decay++;

}

TFStart.protein.number=TFStart.protein.number-decay;

for (i=1; i<=TFStart.mRNA.number; i++)

{

if (RandomAction(TFStart.protein.Pgenerate))

TFStart.protein.number=TFStart.protein.number++;

}




// Binding of TFs at regulatory site "move"


if (move.Site0.number == 0)

{

if (RandomAction(move.Site0.Pgenerate*TFfound.protein.number*TFfound.protein.number)) // on rate depends on TFfound^2 numbers = binding of homodimers

{

//printf("At %ld Homodimer TFfound-TFfound binds!\n", step);

move.Site0.number=1;

}

}

else

if (RandomAction(move.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFfound-TFfound goes off!\n", step);

move.Site0.number=0;

}

StatisticTFfoundATmoveSum=StatisticTFfoundATmoveSum-StatisticTFfoundATmove[step%1000]+move.Site0.number; // step modulo 1000

StatisticTFfoundATmove[step%1000]=move.Site0.number;


if (move.Site1.number == 0)

{

if (RandomAction(move.Site1.Pgenerate*TFStart.protein.number*TFStart.protein.number)) // on rate depends on TFStart^2 numbers = binding of hemodimer

{

//printf("At %ld Homodimer TFStart-TFStart binds!\n", step);

move.Site1.number=1;

}

}

else

if (RandomAction(move.Site1.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFStart-TFStart goes off!\n", step);

move.Site1.number=0;

}

StatisticTFStartATmoveSum=StatisticTFStartATmoveSum-StatisticTFStartATmove[step%1000]+move.Site1.number; // step modulo 1000

StatisticTFStartATmove[step%1000]=move.Site1.number;



// mRNA transcription at site "move"


decay=0;

for (i=1; i<=TFmove.mRNA.number; i=i++)

{

if (RandomAction(TFmove.mRNA.Pdegrade))

decay=decay++;

}

TFmove.mRNA.number=TFmove.mRNA.number-decay;

// if (decay!=0) printf("At %ld decay von mRNA Molekuel(en) - total = %ld!\n", step, TFmove.mRNA.number);

if ((move.Site0.number == 0)&&(move.Site1.number==0)) // Kern der logischen Verknuepfung

if (RandomAction(TFmove.mRNA.Pgenerate)) // transcription rate

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFmove.mRNA.number);

TFmove.mRNA.number=TFmove.mRNA.number++;

}



// protein translation of mRNA "move"


decay=0;

for (i=1; i<=TFmove.protein.number; i++)

{

if (RandomAction(TFmove.protein.Pdegrade))

decay=decay++;

}

TFmove.protein.number=TFmove.protein.number-decay;

for (i=1; i<=TFmove.mRNA.number; i++)

{

if (RandomAction(TFmove.protein.Pgenerate))

TFmove.protein.number=TFmove.protein.number++;

}



// Binding of TFs at regulatory site "found"


if (found.Site0.number == 0)

{

if (RandomAction(found.Site0.Pgenerate*TFmove.protein.number*TFmove.protein.number)) // on rate depends on TFfound^2 numbers = binding of homodimers

{

//printf("At %ld Homodimer TFfound-TFfound binds!\n", step);

found.Site0.number=1;

}

}

else

if (RandomAction(found.Site0.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFfound-TFfound goes off!\n", step);

found.Site0.number=0;

}

StatisticTFmoveATfoundSum=StatisticTFmoveATfoundSum-StatisticTFmoveATfound[step%1000]+found.Site0.number; // step modulo 1000

StatisticTFmoveATfound[step%1000]=found.Site0.number;


if (found.Site1.number == 0)

{

if (RandomAction(found.Site1.Pgenerate*TFdelay.protein.number*TFdelay.protein.number)) // on rate depends on TFdelay^2 numbers = binding of hemodimer

{

//printf("At %ld Homodimer TFStop-TFStop binds!\n", step);

found.Site1.number=1;

}

}

else

if (RandomAction(found.Site1.Pdegrade)) // decay rate

{

//printf("At %ld Homodimer TFStop-TFStop goes off!\n", step);

found.Site1.number=0;

}

StatisticTFdelayATfoundSum=StatisticTFdelayATfoundSum-StatisticTFdelayATfound[step%1000]+found.Site1.number; // step modulo 1000

StatisticTFdelayATfound[step%1000]=found.Site1.number;



// mRNA transcription at site "found"


decay=0;

for (i=1; i<=TFfound.mRNA.number; i=i++)

{

if (RandomAction(TFfound.mRNA.Pdegrade))

decay=decay++;

}

TFfound.mRNA.number=TFfound.mRNA.number-decay;

// if (decay!=0) printf("At %ld decay von mRNA Molekuel(en) - total = %ld!\n", step, TFfound.mRNA.number);

if ((found.Site0.number == 0)&&(found.Site1.number==0)) // Kern der logischen Verknuepfung

if (RandomAction(TFfound.mRNA.Pgenerate)) // transcription rate

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFfound.mRNA.number);

TFfound.mRNA.number=TFfound.mRNA.number++;

}


// protein translation of mRNA "found"


decay=0;

for (i=1; i<=TFfound.protein.number; i++)

{

if (RandomAction(TFfound.protein.Pdegrade))

decay=decay++;

}

TFfound.protein.number=TFfound.protein.number-decay;

for (i=1; i<=TFfound.mRNA.number; i++)

{

if (RandomAction(TFfound.protein.Pgenerate))

TFfound.protein.number=TFfound.protein.number++;

}

// printf("Site occupation at step%ld\t AB = %ld\tC = %ld\n", step, StatisticTFABSum, StatisticTFCSum);




// Binding of TFs at regulatory site "delay"


if (delay.Site1.number == 0)

{

if (RandomAction(delay.Site1.Pgenerate*TFfound.protein.number*TFfound.protein.number)) // on rate depends on TFA & TFB numbers = binding of heterodimer

{

//printf("At %ld Homodimer TFfound-TFfound binds!\n", step);

delay.Site1.number=1;

}

}

else

if (RandomAction(delay.Site1.Pdegrade)) // decay rate

{

//printf("At %ld Heterodimer TFA-TFB goes off!\n", step);

delay.Site1.number=0;

}

StatisticTFfoundATdelaySum=StatisticTFfoundATdelaySum-StatisticTFfoundATdelay[step%1000]+delay.Site1.number; // step modulo 1000

StatisticTFfoundATdelay[step%1000]=delay.Site1.number;



// mRNA transcription at site "delay"


decay=0;

for (i=1; i<=TFdelay.mRNA.number; i=i++)

{

if (RandomAction(TFdelay.mRNA.Pdegrade))

decay=decay++;

}

TFdelay.mRNA.number=TFdelay.mRNA.number-decay;

// if (decay!=0) printf("At %ld decay von mRNA Molekuel(en) - total = %ld!\n", step, TFStart.mRNA.number);

if ((delay.Site1.number == 1))

{

if (RandomAction(TFdelay.mRNA.Pgenerate)) // transcription rate

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFStart.mRNA.number);

TFdelay.mRNA.number=TFdelay.mRNA.number++;

}

}

else

if (RandomAction(TFdelay.mRNA.Pgenerate/20)) // transcription rate, 5% of maximum rate (as 0% seems unlikely)

{

//printf("At %ld Bildung eines mRNA Molekuels - total = %ld!\n", step, TFStart.mRNA.number);

TFdelay.mRNA.number=TFdelay.mRNA.number++;

}


// protein translation of mRNA "TFdelay"


decay=0;

for (i=1; i<=TFdelay.protein.number; i++)

{

if (RandomAction(TFdelay.protein.Pdegrade))

decay=decay++;

}

TFdelay.protein.number=TFdelay.protein.number-decay;

for (i=1; i<=TFdelay.mRNA.number; i++)

{

if (RandomAction(TFdelay.protein.Pgenerate))

TFdelay.protein.number=TFdelay.protein.number++;

}




if (step%10 ==0)

{

fprintf(outhandle1, "%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t%ld\n", step, StatisticTFdelayATASum/10, TFA.mRNA.number, TFA.native.number+TFA.phosphorylated.number, StatisticTFdelayATBSum/10, TFB.mRNA.number, TFB.native.number+TFB.phosphorylated.number, StatisticTFdelayATCSum/10, TFC.mRNA.number, TFC.native.number+TFC.phosphorylated.number);

fprintf(outhandle2, "%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t%ld\n", step, TFA.native.number, TFA.phosphorylated.number, TFB.native.number, TFB.phosphorylated.number, TFC.native.number, TFC.phosphorylated.number);

fprintf(outhandle3, "%ld\t%ld\t%ld\t%ld\t%ld\t%ld\n", step, StatisticTFABStartSum/10, StatisticTFdelayStartSum/10, StatisticTFCStartSum/10, TFStart.mRNA.number, TFStart.protein.number);

fprintf(outhandle4, "%ld\t%ld\t%ld\t%ld\t%ld\n", step, StatisticTFfoundATmoveSum/10, StatisticTFStartATmoveSum/10, TFmove.mRNA.number, TFmove.protein.number);

fprintf(outhandle5, "%ld\t%ld\t%ld\t%ld\t%ld\n", step, StatisticTFmoveATfoundSum/10, StatisticTFdelayATfoundSum/10, TFfound.mRNA.number, TFfound.protein.number);

fprintf(outhandle6, "%ld\t%ld\t%ld\t%ld\n", step, StatisticTFfoundATdelaySum/10, TFdelay.mRNA.number, TFdelay.protein.number);

}


}


printf("Ende der Simulation!\n");


fclose(outhandle1);

fclose(outhandle2);

fclose(outhandle3);

fclose(outhandle4);

fclose(outhandle5);

fclose(outhandle6);

printf("File %s closed!\n", outfilename1);

printf("File %s closed!\n", outfilename2);

printf("File %s closed!\n", outfilename3);

printf("File %s closed!\n", outfilename4);

printf("File %s closed!\n", outfilename5);

printf("File %s closed!\n", outfilename6);

system("gnuplot plot0.gp");

system("gnuplot plot1.gp");

system("gnuplot plot2.gp");

system("gnuplot plot3.gp");

system("gnuplot plot4.gp");

system("gnuplot plot5.gp");

system("gnuplot plot6.gp");

return EXIT_SUCCESS;

}