-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutation.c
1938 lines (1885 loc) · 95.8 KB
/
mutation.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file contains functions to generate mutations and maintain data structure
*
* Authors: Joanna Masel, Alex Lancaster, Kun Xiong
* Copyright (c) 2018 Arizona Board of Regents on behalf of the University of Arizona
* This file is part of network-evolution-simulator.
* network-evolution-simulator is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* network-evolution-simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with network-evolution-simulator. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <math.h>
#include "RngStream.h"
#include "netsim.h"
#include "numerical.h"
#include "mutation.h"
enum mutation_bound {BOUND_EXCLUDED=0,BOUND_INCLUDED=1};
/*Mutation rates*/
float DUPLICATION=1.5e-7;
float SILENCING=1.5e-7;
static const float SUBSTITUTION = 3.5e-10; // per bp
static const float MUT_Kd=3.5e-9; //per gene
static const float MUT_identity=3.5e-9; //per gene
static const float MUT_binding_seq=3.5e-9; //per gene
static const float MUT_ACT_to_INT=3.5e-9; //per gene
static const float MUT_mRNA_decay=9.5e-12; //per codon
static const float MUT_protein_decay=9.5e-12; //per codon
static const float MUT_protein_syn_rate=9.5e-12; //per codon
static const float MUT_GENE_LENGTH_RATE=1.2e-11; //per codon
static const float MUT_cooperation=0.0;
/*Mutational effect*/
float miu_ACT_TO_INT_RATE=1.57;
float miu_Kd=-5.0;
float miu_protein_syn_rate=0.021;
static const float sigma_ACT_TO_INT_RATE=0.773;
static const float sigma_mRNA_decay=0.396;
static const float sigma_protein_decay=0.739;
static const float sigma_protein_syn_rate=0.76;
static const float sigma_Kd=0.776;
static const float miu_mRNA_decay=-1.19;
static const float miu_protein_decay=-1.88;
static const float mutational_regression_rate=0.5;
/******************************************************************************
*
* Private function prototypes
*
*****************************************************************************/
static float mut_make_new_value(float, float, float, float, float, RngStream, Mutation *, int);
static void update_protein_pool(Genotype *, int, int, char);
static void update_cisreg_cluster(Genotype *, int, char, int [MAX_GENES][MAX_GENES], int, int);
/*******************************************************************************
*
* Global functions
*
******************************************************************************/
/*single nucleic acid substitution in cis-reg*/
void mut_substitution(Genotype *genotype, Mutation *mut_record, RngStream RS)
{
int which_nucleotide, which_gene,i,N_BS_bf_mutation,flag_difference;
char *Genome,nucleotide;
AllTFBindingSites *container; // used to store binding sites before substitution
// we compare whether substituion changes any binding sites,
// in order to determine whether mutation creates a unique cis-reg
// sequence whose binding configuration always needs computation
/*points to the current cis-reg*/
Genome= &genotype->cisreg_seq[0][0];
/*whether to simulate bias in the frequency of different substitutions*/
#if !SIMPLE_SUBSTITUTION
float random;
while(1)
{
/*this is the nucleic acid that's going to be mutated*/
which_nucleotide=RngStream_RandInt(RS,N_SIGNAL_TF*CISREG_LEN,genotype->ngenes*CISREG_LEN-1);
random=RngStream_RandU01(RS);
if (Genome[which_nucleotide]=='a'||Genome[which_nucleotide]=='t')
{
if(random<=0.2)break; // 20% of mutations hit A or T
}
else
{
if(random>0.2)break; //80% hit C or G
}
}
/*this is gene hit by the mutation*/
which_gene=which_nucleotide/CISREG_LEN;
/*calculate and store the distribution of binding sites before mutation*/
calc_all_binding_sites_copy(genotype,which_gene);
container = malloc(genotype->N_allocated_elements*sizeof(AllTFBindingSites));
N_BS_bf_mutation=genotype->binding_sites_num[which_gene];
for(i=0;i<N_BS_bf_mutation;i++)
{
container[i].BS_pos=genotype->all_binding_sites[which_gene][i].BS_pos;
container[i].tf_id=genotype->all_binding_sites[which_gene][i].tf_id;
container[i].mis_match=genotype->all_binding_sites[which_gene][i].mis_match;
}
/*generate new nucleic acid*/
random=RngStream_RandU01(RS);
switch (Genome[which_nucleotide])
{
case 'a':
if(random<=0.2)
Genome[which_nucleotide]='c'; // 20% of mutation to A changes it to C
else
{
if((random-0.2)<=0.3)
Genome[which_nucleotide]='t'; // 30% changes it to T
else
Genome[which_nucleotide]='g'; // 50% changes it to G
}
break;
case 't':
if(random<=0.2)
Genome[which_nucleotide]='g';
else
{
if((random-0.2)<=0.3)
Genome[which_nucleotide]='a';
else
Genome[which_nucleotide]='c';
}
break;
case 'c':
if(random<=0.2)
Genome[which_nucleotide]='g';
else
{
if((random-0.2)<=0.3)
Genome[which_nucleotide]='t';
else
Genome[which_nucleotide]='a';
}
break;
case 'g':
if(random<=0.2)
Genome[which_nucleotide]='c';
else
{
if((random-0.2)<=0.3)
Genome[which_nucleotide]='a';
else
Genome[which_nucleotide]='t';
}
break;
}
#else // if do not simulate bias in substitution
/*this is the nucleic acid that's going to be mutated*/
which_nucleotide=RngStream_RandInt(RS,N_SIGNAL_TF*CISREG_LEN,genotype->ngenes*CISREG_LEN-1);
/*this is gene hit by the mutation*/
which_gene=which_nucleotide/CISREG_LEN;
/*calculate and store the distribution of binding sites before mutation*/
calc_all_binding_sites_copy(genotype,which_gene);
container = malloc(genotype->N_allocated_elements*sizeof(AllTFBindingSites));
N_BS_bf_mutation=genotype->binding_sites_num[which_gene];
for(i=0;i<N_BS_bf_mutation;i++)
{
container[i].BS_pos=genotype->all_binding_sites[which_gene][i].BS_pos;
container[i].tf_id=genotype->all_binding_sites[which_gene][i].tf_id;
container[i].mis_match=genotype->all_binding_sites[which_gene][i].mis_match;
}
/*generate new nucleic acid*/
nucleotide=set_base_pair(RngStream_RandU01(RS));
while(nucleotide==Genome[which_nucleotide]) // make sure we get a different nucleic acid
nucleotide=set_base_pair(RngStream_RandU01(RS));
Genome[which_nucleotide]=nucleotide;
#endif
/*compare binding site bf and aft substitution to decide whether to update cisreg_cluster*/
calc_all_binding_sites_copy(genotype,which_gene);
if(N_BS_bf_mutation!=genotype->binding_sites_num[which_gene])
{
update_cisreg_cluster(genotype,which_gene,'s',NULL,NA,NA);
}
else
{
/*assuming no change in binding sites*/
flag_difference=0;
/*comparing binding sites pair by pair*/
for(i=0;i<N_BS_bf_mutation;i++)
{
if(container[i].BS_pos!=genotype->all_binding_sites[which_gene][i].BS_pos ||
container[i].tf_id!=genotype->all_binding_sites[which_gene][i].tf_id ||
container[i].mis_match!=genotype->all_binding_sites[which_gene][i].mis_match)
{
flag_difference=1;
break;
}
}
if(flag_difference==1)
update_cisreg_cluster(genotype,which_gene,'s',NULL,NA,NA);
}
free(container);
/*record mutation info*/
mut_record->which_nucleotide=which_nucleotide;
mut_record->which_gene=which_gene;
mut_record->nuc_diff[0]=Genome[which_nucleotide];
genotype->recalc_TFBS[which_gene]=YES; /*the binding sites on this cis-reg needs to be updated*/
}
/*
* Replay substitution. Used when replay the evolution for analysis
*/
void reproduce_substitution(Genotype *genotype, Mutation *mut_record)
{
char *Genome;
int i, N_BS_bf_mutation,which_gene,flag_difference;
AllTFBindingSites *container;
/*get the mutated gene from record*/
which_gene=mut_record->which_gene;
/*calculate and store the distribution of binding sites before mutation*/
calc_all_binding_sites_copy(genotype,which_gene);
container = malloc(genotype->N_allocated_elements*sizeof(AllTFBindingSites));
N_BS_bf_mutation=genotype->binding_sites_num[which_gene];
for(i=0;i<N_BS_bf_mutation;i++)
{
container[i].BS_pos=genotype->all_binding_sites[which_gene][i].BS_pos;
container[i].tf_id=genotype->all_binding_sites[which_gene][i].tf_id;
container[i].mis_match=genotype->all_binding_sites[which_gene][i].mis_match;
}
/*apply the mutation from record*/
Genome= &genotype->cisreg_seq[0][0];
Genome[mut_record->which_nucleotide]=mut_record->nuc_diff[1];
/*compare binding site bf and aft substitution to decide whether to update cisreg_cluster*/
calc_all_binding_sites_copy(genotype,which_gene);
if(N_BS_bf_mutation!=genotype->binding_sites_num[which_gene])
{
update_cisreg_cluster(genotype,which_gene,'s',NULL,NA,NA);
}
else
{
flag_difference=0;
for(i=0;i<N_BS_bf_mutation;i++)
{
if(container[i].BS_pos!=genotype->all_binding_sites[which_gene][i].BS_pos ||
container[i].tf_id!=genotype->all_binding_sites[which_gene][i].tf_id ||
container[i].mis_match!=genotype->all_binding_sites[which_gene][i].mis_match)
{
flag_difference=1;
break;
}
}
if(flag_difference==1)
update_cisreg_cluster(genotype,which_gene,'s',NULL,NA,NA);
}
free(container);
genotype->recalc_TFBS[which_gene]=YES; /*recalc TFBS*/
}
/**
*Deletion whole cis-reg sequence
*/
void mut_whole_gene_deletion(Genotype *genotype, Mutation *mut_record, RngStream RS) // any gene can be deleted
{
int i,j;
int which_gene, offset, cisreg_seq_cluster_id,cisreg_seq_cluster_id_copy;
char *temp;
int protein_id, N_gene_of_selection_protein, puppet_gene,position_of_puppet_gene;
/* check which genes can be deleted*/
N_gene_of_selection_protein=genotype->protein_pool[genotype->nproteins-1][0][0]; //does the effector gene have multipe copies
if(genotype->ntfgenes-N_SIGNAL_TF>1)//if there are more than one copies of genes of non-sensor TF
{
if(N_gene_of_selection_protein==1)//if the effector have only one copies
{
protein_id=genotype->nproteins-1;
while(protein_id==genotype->nproteins-1) //the last copy of the effector cannot be deleted. choose a different gene
{
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
protein_id=genotype->which_protein[which_gene];
}
}
else //otherwise any gene can be deleted
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
}
else //if there's only one copy of non-sensor TF gene
{
while(1)
{
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
protein_id=genotype->which_protein[which_gene];
if(protein_id==genotype->nproteins-1)//obviously we can only delete a copy of the effector gene
break; //it's impossible for deletion when the non-sensor TF and the effector each has only one copy
//function draw_mutation would have set deletion rate to 0 in such a case
}
}
/*record mutation info*/
mut_record->which_gene=which_gene;
/*To preserve data structure, the last gene has to be an effector gene. If this gene is selected for deletion,
* we overwrite it with one of its copy. Then we deleted the original copy.
* For example, assuming ngenes=10, gene 9 is an effector gene and is marked for deletion.
* We know gene 5 was duplicated from gene 9, so we overwrite gene 9 with all the info of gene 5,
* then we delete gene 5 (the puppet gene).*/
if(which_gene==genotype->ngenes-1)
{
cisreg_seq_cluster_id=genotype->which_cluster[which_gene];
/*check if the effector gene has a copy that has the same cis-reg sequence*/
if(genotype->cisreg_cluster[cisreg_seq_cluster_id][1]!=NA)//there is at least one copy that meets the requirement
{
puppet_gene=genotype->cisreg_cluster[cisreg_seq_cluster_id][0];//genes in cisreg_cluster is ordered acendingly
}
else// otherwise, this effector gene has a unique cis-reg sequence. We have to use a copy that has a different cis-reg sequence.
// We also need to remove the cis-reg cluster of the effector gene to be deleted.
{
/*find such a copy -- call it puppet_gene*/
protein_id=genotype->which_protein[which_gene];
position_of_puppet_gene=0;
if(genotype->protein_pool[protein_id][1][position_of_puppet_gene]==which_gene)position_of_puppet_gene++;
puppet_gene=genotype->protein_pool[protein_id][1][position_of_puppet_gene];
/*Add the effector gene to the cis_reg cluster of the puppet_gene, so that we can edit the cluster with standard procedure later*/
cisreg_seq_cluster_id_copy=genotype->which_cluster[puppet_gene];
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]!=NA)j++;//find an empty slot in cisreg_cluster
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=which_gene;
genotype->which_cluster[which_gene]=cisreg_seq_cluster_id_copy;
/*then delete which_gene's original cisreg cluster by shifting cisreg_cluster*/
cisreg_seq_cluster_id_copy=cisreg_seq_cluster_id;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][0]!=NA)
{
/*reset cluster=cisreg_seq_cluster_id*/
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]!=NA)
{
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=NA;
j++;
}
/* copy cisreg_seq_cluster_id+1 to cisreg_seq_cluster_id, and update which_cluster*/
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j]!=NA)
{
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j];
genotype->which_cluster[genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j]]--;
j++;
}
cisreg_seq_cluster_id_copy++;
}
}
/*overwrite which_gene with the info of puppet_gene*/
for(j=0;j<CISREG_LEN;j++)
genotype->cisreg_seq[which_gene][j]=genotype->cisreg_seq[puppet_gene][j];
genotype->min_N_activator_to_transc[which_gene]=genotype->min_N_activator_to_transc[puppet_gene];
genotype->active_to_intermediate_rate[which_gene]=genotype->active_to_intermediate_rate[puppet_gene];
genotype->mRNA_decay_rate[which_gene]=genotype->mRNA_decay_rate[puppet_gene];
genotype->protein_decay_rate[which_gene]=genotype->protein_decay_rate[puppet_gene];
genotype->translation_rate[which_gene]=genotype->translation_rate[puppet_gene];
genotype->locus_length[which_gene]=genotype->locus_length[puppet_gene];
genotype->recalc_TFBS[which_gene]=YES;
/*now the effector gene is same as the puppet_gene, so delete the puppet_gene*/
which_gene=puppet_gene;
}
/*points the first nucleotide of the cis-reg sequence to be deleted*/
temp = &genotype->cisreg_seq[which_gene][0];
offset=CISREG_LEN;
/* shift the cisreg array to overwrite the cis_seq to be deleted */
for(i=0;i<CISREG_LEN*(genotype->ngenes-which_gene-1);i++)
{
*temp=*(temp+offset);
temp++;
}
/* if the to-be-deleted gene is a tf gene*/
protein_id=genotype->which_protein[which_gene];
if(protein_id<genotype->nproteins-1)
{
/*if this tf has only one copy of gene, then we'll delete the binding seq of this tf*/
if(genotype->protein_pool[protein_id][0][0]==1)
{
/* shift the tf_reg array to overwrite the binding sequence to be deleted */
temp=&genotype->tf_seq[protein_id][0];
offset=CONSENSUS_SEQ_LEN;
for(i=0;i<CONSENSUS_SEQ_LEN*(genotype->nproteins-protein_id-1);i++)
{
*temp=*(temp+offset);
temp++;
}
/* shift the tf_reg_rc array to overwrite the binding sequence to be deleted */
temp=&genotype->tf_seq_rc[protein_id][0];
for(i=0;i<CONSENSUS_SEQ_LEN*(genotype->nproteins-protein_id-1);i++)
{
*temp=*(temp+offset);
temp++;
}
}
}
/*update total loci length before removing info of which_gene*/
genotype->total_loci_length-=genotype->locus_length[which_gene];
/* remove it from PIC_assembly, mRNAdecay, proteinDecay, translation and re_calc*/
for(i=which_gene;i<genotype->ngenes;i++)
{
genotype->min_N_activator_to_transc[i]=genotype->min_N_activator_to_transc[i+1];
genotype->active_to_intermediate_rate[i]=genotype->active_to_intermediate_rate[i+1];
genotype->mRNA_decay_rate[i]=genotype->mRNA_decay_rate[i+1];
genotype->protein_decay_rate[i]=genotype->protein_decay_rate[i+1];
genotype->translation_rate[i]=genotype->translation_rate[i+1];
genotype->locus_length[i]=genotype->locus_length[i+1];
genotype->recalc_TFBS[i]=YES;
}
/* if the to-be-deleted gene is a tf gene, change ntfgenes as well*/
if(protein_id!=genotype->nproteins-1)
genotype->ntfgenes--;
/* now change protein_pool and cisreg_cluster*/
update_protein_pool(genotype,protein_id,which_gene,'w');
update_cisreg_cluster(genotype,which_gene,'w',NULL,NA,NA);
genotype->ngenes--;
}
void reproduce_whole_gene_deletion(Genotype *genotype, Mutation *mut_record) // any gene can be deleted
{
int which_gene, offset, i,j, cisreg_seq_cluster_id, cisreg_seq_cluster_id_copy,puppet_gene,position_of_puppet_gene;
char *temp;
int protein_id;
which_gene=mut_record->which_gene;
if(which_gene==genotype->ngenes-1)
{
cisreg_seq_cluster_id=genotype->which_cluster[which_gene];
if(genotype->cisreg_cluster[cisreg_seq_cluster_id][1]!=NA)
{
puppet_gene=genotype->cisreg_cluster[cisreg_seq_cluster_id][0];
}
else
{
protein_id=genotype->which_protein[which_gene];
position_of_puppet_gene=0;
if(genotype->protein_pool[protein_id][1][position_of_puppet_gene]==which_gene)position_of_puppet_gene++;
puppet_gene=genotype->protein_pool[protein_id][1][position_of_puppet_gene];
cisreg_seq_cluster_id_copy=genotype->which_cluster[puppet_gene];
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]!=NA)j++;
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=which_gene;
genotype->which_cluster[which_gene]=cisreg_seq_cluster_id_copy;
cisreg_seq_cluster_id_copy=cisreg_seq_cluster_id;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][0]!=NA)
{
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]!=NA)
{
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=NA;
j++;
}
j=0;
while(genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j]!=NA)
{
genotype->cisreg_cluster[cisreg_seq_cluster_id_copy][j]=genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j];
genotype->which_cluster[genotype->cisreg_cluster[cisreg_seq_cluster_id_copy+1][j]]--;
j++;
}
cisreg_seq_cluster_id_copy++;
}
}
for(j=0;j<CISREG_LEN;j++)
genotype->cisreg_seq[which_gene][j]=genotype->cisreg_seq[puppet_gene][j];
genotype->min_N_activator_to_transc[which_gene]=genotype->min_N_activator_to_transc[puppet_gene];
genotype->active_to_intermediate_rate[which_gene]=genotype->active_to_intermediate_rate[puppet_gene];
genotype->mRNA_decay_rate[which_gene]=genotype->mRNA_decay_rate[puppet_gene];
genotype->protein_decay_rate[which_gene]=genotype->protein_decay_rate[puppet_gene];
genotype->translation_rate[which_gene]=genotype->translation_rate[puppet_gene];
genotype->locus_length[which_gene]=genotype->locus_length[puppet_gene];
genotype->recalc_TFBS[which_gene]=YES;
which_gene=puppet_gene;
}
temp = &genotype->cisreg_seq[which_gene][0];
offset=CISREG_LEN;
for(i=0;i<CISREG_LEN*(genotype->ngenes-which_gene-1);i++)
{
*temp=*(temp+offset);
temp++;
}
protein_id=genotype->which_protein[which_gene];
if(protein_id<genotype->nproteins-1)
{
if(genotype->protein_pool[protein_id][0][0]==1)
{
temp=&genotype->tf_seq[protein_id][0];
offset=CONSENSUS_SEQ_LEN;
for(i=0;i<CONSENSUS_SEQ_LEN*(genotype->nproteins-protein_id-1);i++)
{
*temp=*(temp+offset);
temp++;
}
temp=&genotype->tf_seq_rc[protein_id][0];
for(i=0;i<CONSENSUS_SEQ_LEN*(genotype->nproteins-protein_id-1);i++)
{
*temp=*(temp+offset);
temp++;
}
}
}
/*update total loci length before removing info of which_gene*/
genotype->total_loci_length-=genotype->locus_length[which_gene];
for(i=which_gene;i<genotype->ngenes;i++)
{
genotype->min_N_activator_to_transc[i]=genotype->min_N_activator_to_transc[i+1];
genotype->active_to_intermediate_rate[i]=genotype->active_to_intermediate_rate[i+1];
genotype->mRNA_decay_rate[i]=genotype->mRNA_decay_rate[i+1];
genotype->protein_decay_rate[i]=genotype->protein_decay_rate[i+1];
genotype->translation_rate[i]=genotype->translation_rate[i+1];
genotype->locus_length[i]=genotype->locus_length[i+1];
genotype->recalc_TFBS[i]=YES;
}
/* if the to-be-deleted gene is a tf gene, change ntfgenes as well*/
if(protein_id!=genotype->nproteins-1)
genotype->ntfgenes--;
update_protein_pool(genotype,protein_id,which_gene,'w');
update_cisreg_cluster(genotype,which_gene,'w',NULL,NA,NA);
genotype->ngenes--;
}
/*
* Duplicate a whole cis-reg sequence
*/
void mut_duplication(Genotype *genotype, Mutation *mut_record, RngStream RS)
{
int which_gene, which_gene_copy, i, protein_id;
char *temp1, *temp2;
if(genotype->protein_pool[genotype->nproteins-1][0][0]>=N_EFFECTOR_GENES) // too many effector gene copies
{
//note that it's not possible to have too many effector gene copies and too many tf gene copies at the same time
//because that will make duplication rate 0.
which_gene=genotype->ngenes-1;
while(genotype->which_protein[which_gene]==genotype->nproteins-1)
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
}
else
{
if(genotype->ntfgenes>=N_TF_GENES) // too many tf gene copies
{
while(1)
{
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
if(genotype->which_protein[which_gene]==genotype->nproteins-1)
break;
}
}
else //any gene can be duplicated
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
}
/*record mutation info*/
mut_record->which_gene=which_gene;
/*To preserve data structure, the last gene has to be an effector gene.*/
/*We want to shift the effector gene, and put the duplicated gene to the second last place.
*But if it is the effector gene that gets duplicated, things are a little different */
if(which_gene==genotype->ngenes-1)
which_gene_copy=which_gene+1;
else
which_gene_copy=which_gene;
/* copy the promoter*/
temp1=&genotype->cisreg_seq[which_gene_copy][0]; /* points to the gene to be duplicated*/
temp2=&genotype->cisreg_seq[genotype->ngenes-1][CISREG_LEN-1]; /* points to the end of the effector gene */
/* shift the sequences of the effector gene CISREG_LEN bp */
for(i=0;i<CISREG_LEN;i++)
{
*(temp2+CISREG_LEN)=*temp2;
temp2--;
}
/* point temp2 to the start of the original position of the selection gene */
temp2=&genotype->cisreg_seq[genotype->ngenes-1][0];
/* put the duplicated gene at the original place of the selection gene */
for(i=0;i<CISREG_LEN;i++)
*temp2++=*temp1++;
/* shift the effector genes to make a slot*/
genotype->min_N_activator_to_transc[genotype->ngenes]=genotype->min_N_activator_to_transc[genotype->ngenes-1];
genotype->active_to_intermediate_rate[genotype->ngenes]=genotype->active_to_intermediate_rate[genotype->ngenes-1];
genotype->mRNA_decay_rate[genotype->ngenes]=genotype->mRNA_decay_rate[genotype->ngenes-1];
genotype->protein_decay_rate[genotype->ngenes]=genotype->protein_decay_rate[genotype->ngenes-1];
genotype->translation_rate[genotype->ngenes]=genotype->translation_rate[genotype->ngenes-1];
genotype->locus_length[genotype->ngenes]=genotype->locus_length[genotype->ngenes-1];
genotype->recalc_TFBS[genotype->ngenes]=YES;
/* copy and paste info to the slot*/
genotype->min_N_activator_to_transc[genotype->ngenes-1]=genotype->min_N_activator_to_transc[which_gene_copy];
genotype->active_to_intermediate_rate[genotype->ngenes-1]=genotype->active_to_intermediate_rate[which_gene_copy];
genotype->mRNA_decay_rate[genotype->ngenes-1]=genotype->mRNA_decay_rate[which_gene_copy];
genotype->protein_decay_rate[genotype->ngenes-1]=genotype->protein_decay_rate[which_gene_copy];
genotype->translation_rate[genotype->ngenes-1]=genotype->translation_rate[which_gene_copy];
genotype->locus_length[genotype->ngenes-1]=genotype->locus_length[which_gene_copy];
genotype->recalc_TFBS[genotype->ngenes-1]=YES;
/*update total loci length*/
genotype->total_loci_length+=genotype->locus_length[which_gene_copy];
/* update protein_pool*/
protein_id=genotype->which_protein[which_gene];
update_protein_pool(genotype,protein_id,which_gene,'d');
/* update cisreg_cluster*/
update_cisreg_cluster(genotype,which_gene,'d',NULL,NA,NA);
/* update gene numbers*/
if(protein_id<genotype->nproteins-1)//note duplication do not change nproteins
genotype->ntfgenes++;
genotype->ngenes++;
}
void reproduce_gene_duplication(Genotype *genotype, Mutation *mut_record) //any gene can be duplicated
{
int which_gene,which_gene_copy, i, protein_id;
char *temp1, *temp2;
/*get the gene to be duplicated from record*/
which_gene=mut_record->which_gene;
if(which_gene==genotype->ngenes-1)
which_gene_copy=which_gene+1;
else
which_gene_copy=which_gene;
temp1=&genotype->cisreg_seq[which_gene_copy][0];
temp2=&genotype->cisreg_seq[genotype->ngenes-1][CISREG_LEN-1];
for(i=0;i<CISREG_LEN;i++)
{
*(temp2+CISREG_LEN)=*temp2;
temp2--;
}
temp2=&genotype->cisreg_seq[genotype->ngenes-1][0];
for(i=0;i<CISREG_LEN;i++)
*temp2++=*temp1++;
genotype->min_N_activator_to_transc[genotype->ngenes]=genotype->min_N_activator_to_transc[genotype->ngenes-1];
genotype->active_to_intermediate_rate[genotype->ngenes]=genotype->active_to_intermediate_rate[genotype->ngenes-1];
genotype->mRNA_decay_rate[genotype->ngenes]=genotype->mRNA_decay_rate[genotype->ngenes-1];
genotype->protein_decay_rate[genotype->ngenes]=genotype->protein_decay_rate[genotype->ngenes-1];
genotype->translation_rate[genotype->ngenes]=genotype->translation_rate[genotype->ngenes-1];
genotype->locus_length[genotype->ngenes]=genotype->locus_length[genotype->ngenes-1];
genotype->recalc_TFBS[genotype->ngenes]=YES;
genotype->min_N_activator_to_transc[genotype->ngenes-1]=genotype->min_N_activator_to_transc[which_gene_copy];
genotype->active_to_intermediate_rate[genotype->ngenes-1]=genotype->active_to_intermediate_rate[which_gene_copy];
genotype->mRNA_decay_rate[genotype->ngenes-1]=genotype->mRNA_decay_rate[which_gene_copy];
genotype->protein_decay_rate[genotype->ngenes-1]=genotype->protein_decay_rate[which_gene_copy];
genotype->translation_rate[genotype->ngenes-1]=genotype->translation_rate[which_gene_copy];
genotype->locus_length[genotype->ngenes-1]=genotype->locus_length[which_gene_copy];
genotype->recalc_TFBS[genotype->ngenes-1]=YES;
genotype->total_loci_length+=genotype->locus_length[which_gene_copy];
protein_id=genotype->which_protein[which_gene];
update_protein_pool(genotype,protein_id,which_gene,'d');
update_cisreg_cluster(genotype,which_gene,'d',NULL,NA,NA);
if(protein_id<genotype->nproteins-1)//note duplication do not change nproteins
genotype->ntfgenes++;
genotype->ngenes++;
}
/*
* Mutation to the binding sequence of a TF gene
*/
void mut_binding_sequence(Genotype *genotype, Mutation *mut_record, RngStream RS)
{
int which_gene, which_nucleotide, protein_id, i;
char nucleotide;
char *tf_seq, *tf_seq_rc,*temp1,*temp2;
/*get which gene to mutate*/
which_gene=RngStream_RandInt(RS,0,genotype->ngenes-1);
while(genotype->which_protein[which_gene]==genotype->nproteins-1)
which_gene=RngStream_RandInt(RS,0,genotype->ngenes-1);
/*if this TF has more than one copies of gene, then the mutation adds a new tf
*which requires a new slot in tf_seq and tf_seq_rc to store the new binding seq*/
protein_id=genotype->which_protein[which_gene];
if(genotype->protein_pool[protein_id][0][0]>1)
{
/*points to the first nucleotide of the binding sequence*/
tf_seq=&genotype->tf_seq[protein_id][0];
tf_seq_rc=&genotype->tf_seq_rc[protein_id][0];
/*points to an empty slot*/
temp1=&genotype->tf_seq[genotype->nproteins-1][0];
temp2=&genotype->tf_seq_rc[genotype->nproteins-1][0];
/*copy the binding sequences to empty slots*/
for(i=0;i<CONSENSUS_SEQ_LEN;i++)
{
*temp1++=*tf_seq++;
*temp2++=*tf_seq_rc++;
}
/*point tf_seq and tf_seq_rc to the new slot so that we can apply mutation later*/
tf_seq=&genotype->tf_seq[genotype->nproteins-1][0];
tf_seq_rc=&genotype->tf_seq_rc[genotype->nproteins-1][0];
/*update protein pool*/
update_protein_pool(genotype,protein_id,which_gene,'c');
}
else /*if this tf has only one copy of gene, no new slot is required*/
{
tf_seq=&genotype->tf_seq[protein_id][0];
tf_seq_rc=&genotype->tf_seq_rc[protein_id][0];
}
/*mutate the binding sequence*/
/*mutation only changes one nucleotide in the binding sequence*/
which_nucleotide=RngStream_RandInt(RS,0,CONSENSUS_SEQ_LEN-1);
nucleotide=set_base_pair(RngStream_RandU01(RS));
while (nucleotide == tf_seq[which_nucleotide])
nucleotide=set_base_pair(RngStream_RandU01(RS));
tf_seq[which_nucleotide]=nucleotide;
/*record mutation info*/
mut_record->which_gene=which_gene;
mut_record->which_nucleotide=which_nucleotide;
mut_record->nuc_diff[0]=nucleotide;
/* update the reverse complement sequence*/
switch (nucleotide)
{
case 'g':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='c'; break;
case 'c':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='g'; break;
case 'a':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='t'; break;
case 't':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='a'; break;
}
/* The binding sites on every promoter needs recalculation */
for(i=0;i<genotype->ngenes;i++)
genotype->recalc_TFBS[i]=YES;
/*decide whether to update cisreg clusters. Mutation to binding seq may differ bs distributions among genes in a cluster*/
int new_clusters[MAX_GENES][MAX_GENES]; //
int genes_in_cluster[MAX_GENES];
int N_genes_in_cluster,no_difference,reference_gene,gene_to_be_sorted;
int N_new_clusters,N_genes_in_new_cluster,j,k;
calc_all_binding_sites(genotype);
i=N_SIGNAL_TF;
while(genotype->cisreg_cluster[i][0]!=NA)/*check each cisreg cluster*/
{
N_new_clusters=0;
N_genes_in_cluster=0;
for(j=0;j<MAX_GENES;j++)
{
for(k=0;k<MAX_GENES;k++)
new_clusters[j][k]=NA;
}
while(genotype->cisreg_cluster[i][N_genes_in_cluster]!=NA)
{
genes_in_cluster[N_genes_in_cluster]=genotype->cisreg_cluster[i][N_genes_in_cluster];
N_genes_in_cluster++;
}
/*the while loop below sort genes in a cluster into groups based on whether they have the same BS distributions*/
/*We use one gene in the original cluster as a reference, and sort all genes
*that have the same binding sites as the reference gene into a new cluster.
*After all genes are sorted, we check if the original cluster turns into multiple
*new cluster.*/
while(N_genes_in_cluster>0)//run until every gene in the original cluster has been sorted into new clusters
{
reference_gene=genes_in_cluster[0];//compare each gene to the first gene in cluster
N_genes_in_new_cluster=0;
which_gene=0;//start comparison from the first gene in the cluster
while(which_gene<N_genes_in_cluster)
{
no_difference=1;
gene_to_be_sorted=genes_in_cluster[which_gene];
if(genotype->binding_sites_num[gene_to_be_sorted]==genotype->binding_sites_num[reference_gene])
{
for(j=0;j<genotype->binding_sites_num[reference_gene];j++)
{
if(genotype->all_binding_sites[reference_gene][j].BS_pos!=genotype->all_binding_sites[gene_to_be_sorted][j].BS_pos ||
genotype->all_binding_sites[reference_gene][j].tf_id!=genotype->all_binding_sites[gene_to_be_sorted][j].tf_id ||
genotype->all_binding_sites[reference_gene][j].mis_match!=genotype->all_binding_sites[gene_to_be_sorted][j].mis_match)
{
no_difference=0;
break;
}
}
}
else
no_difference=0;
if(no_difference)//if the gene under comparison has the same binding sites as the reference gene
{
/*put the gene into the new cluster*/
new_clusters[N_new_clusters][N_genes_in_new_cluster]=genes_in_cluster[which_gene];
N_genes_in_new_cluster++;
/*shift to remove the gene from the original cluster*/
for(j=which_gene;j<N_genes_in_cluster-1;j++)
genes_in_cluster[j]=genes_in_cluster[j+1];
N_genes_in_cluster--;
}
else //otherwise, compare next gene with the reference gene
which_gene++;
}
N_new_clusters++;
}
if(N_new_clusters!=1)//if the original cluster turns into multiple clusters
update_cisreg_cluster(genotype,NA,'c',new_clusters,N_new_clusters,i);
i++;
}
/* Calling calc_all_binding_sites reset recalc_TFBS to 0, so we need to turn them on again */
for(i=0;i<genotype->ngenes;i++)
genotype->recalc_TFBS[i]=YES;
}
void reproduce_mut_binding_sequence(Genotype *genotype, Mutation *mut_record)
{
int which_gene, which_nucleotide, protein_id, i;
char *tf_seq, *tf_seq_rc, *temp1,*temp2;
which_gene=mut_record->which_gene;
protein_id=genotype->which_protein[which_gene];
if(genotype->protein_pool[protein_id][0][0]>1)
{
tf_seq=&genotype->tf_seq[protein_id][0];
tf_seq_rc=&genotype->tf_seq_rc[protein_id][0];
temp1=&genotype->tf_seq[genotype->nproteins-1][0];
temp2=&genotype->tf_seq_rc[genotype->nproteins-1][0];
for(i=0;i<CONSENSUS_SEQ_LEN;i++)
{
*temp1++=*tf_seq++;
*temp2++=*tf_seq_rc++;
}
tf_seq=&genotype->tf_seq[genotype->nproteins-1][0];
tf_seq_rc=&genotype->tf_seq_rc[genotype->nproteins-1][0];
update_protein_pool(genotype,protein_id,which_gene,'c');
}
else
{
tf_seq=&genotype->tf_seq[protein_id][0];
tf_seq_rc=&genotype->tf_seq_rc[protein_id][0];
}
which_nucleotide=mut_record->which_nucleotide;
tf_seq[which_nucleotide]=mut_record->nuc_diff[1];
switch (tf_seq[which_nucleotide])
{
case 'g':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='c'; break;
case 'c':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='g'; break;
case 'a':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='t'; break;
case 't':
tf_seq_rc[CONSENSUS_SEQ_LEN-which_nucleotide-1]='a'; break;
}
for(i=0;i<genotype->ngenes;i++)
genotype->recalc_TFBS[i]=YES;
calc_all_binding_sites(genotype);
int new_clusters[MAX_GENES][MAX_GENES],genes_in_cluster[MAX_GENES];
int N_genes_in_cluster,no_difference,reference_gene,gene_to_be_sorted;
int N_new_clusters,N_genes_in_new_cluster,j,k;
i=N_SIGNAL_TF;
while(genotype->cisreg_cluster[i][0]!=NA)
{
N_new_clusters=0;
N_genes_in_cluster=0;
for(j=0;j<MAX_GENES;j++)
{
for(k=0;k<MAX_GENES;k++)
new_clusters[j][k]=NA;
}
while(genotype->cisreg_cluster[i][N_genes_in_cluster]!=NA)
{
genes_in_cluster[N_genes_in_cluster]=genotype->cisreg_cluster[i][N_genes_in_cluster];
N_genes_in_cluster++;
}
while(N_genes_in_cluster>0)
{
reference_gene=genes_in_cluster[0];
N_genes_in_new_cluster=0;
which_gene=0;
while(which_gene<N_genes_in_cluster)
{
no_difference=1;
gene_to_be_sorted=genes_in_cluster[which_gene];
if(genotype->binding_sites_num[gene_to_be_sorted]==genotype->binding_sites_num[reference_gene])
{
for(j=0;j<genotype->binding_sites_num[reference_gene];j++)
{
if(genotype->all_binding_sites[reference_gene][j].BS_pos!=genotype->all_binding_sites[gene_to_be_sorted][j].BS_pos ||
genotype->all_binding_sites[reference_gene][j].tf_id!=genotype->all_binding_sites[gene_to_be_sorted][j].tf_id ||
genotype->all_binding_sites[reference_gene][j].mis_match!=genotype->all_binding_sites[gene_to_be_sorted][j].mis_match)
{
no_difference=0;
break;
}
}
}
else
no_difference=0;
if(no_difference)
{
new_clusters[N_new_clusters][N_genes_in_new_cluster]=genes_in_cluster[which_gene];
N_genes_in_new_cluster++;
for(j=which_gene;j<N_genes_in_cluster-1;j++)
genes_in_cluster[j]=genes_in_cluster[j+1];
N_genes_in_cluster--;
}
else
which_gene++;
}
N_new_clusters++;
}
if(N_new_clusters!=1)
update_cisreg_cluster(genotype,NA,'c',new_clusters,N_new_clusters,i);
i++;
}
for(i=0;i<genotype->ngenes;i++)
genotype->recalc_TFBS[i]=YES;
}
/* Mutations to the rate of mRNA_decay, translation, protein_decay, and pic_disassembly
* will be mutated.
*/
void mut_kinetic_constant(Genotype *genotype, Mutation *mut_record, RngStream RS)
{
float random;
int random2;
int which_gene;
float total_mut_flux;
float total_mut_ACT_to_INT;
float total_mut_mRNA_decay;
float total_mut_translation_rate;
float total_mut_protein_decay;
float total_mut_cooperation;
total_mut_ACT_to_INT=(genotype->ngenes-N_SIGNAL_TF)*MUT_ACT_to_INT;
total_mut_mRNA_decay=genotype->total_loci_length*MUT_mRNA_decay;
total_mut_protein_decay=genotype->total_loci_length*MUT_protein_decay;
total_mut_translation_rate=genotype->total_loci_length*MUT_protein_syn_rate;
total_mut_cooperation=(genotype->ngenes-genotype->ntfgenes)*MUT_cooperation;
total_mut_flux=total_mut_ACT_to_INT+total_mut_mRNA_decay+total_mut_protein_decay+total_mut_translation_rate+total_mut_cooperation;
while(1)
{
random=RngStream_RandU01(RS)*total_mut_flux;
/********************************** mut kdis *******************************/
if(random<=total_mut_ACT_to_INT)
{
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
genotype->active_to_intermediate_rate[which_gene]=mut_make_new_value(genotype->active_to_intermediate_rate[which_gene],
miu_ACT_TO_INT_RATE,
sigma_ACT_TO_INT_RATE,
MAX_ACT_TO_INT_RATE,
MIN_ACT_TO_INT_RATE,
RS,
mut_record,
BOUND_INCLUDED);
/*record mutation info*/
mut_record->which_gene=which_gene;
mut_record->kinetic_type=0;
mut_record->kinetic_diff=genotype->active_to_intermediate_rate[which_gene];
break;
}
else
{
random-=total_mut_ACT_to_INT;
/****************** mut cooperation ***********************/
if(random<=total_mut_cooperation && MUT_cooperation!=0.0)
{
which_gene=0;
while(genotype->which_protein[which_gene]!=genotype->nproteins-1)
which_gene=RngStream_RandInt(RS,N_SIGNAL_TF,genotype->ngenes-1);
mut_record->which_gene=which_gene;
if(genotype->min_N_activator_to_transc[which_gene]==1)
genotype->min_N_activator_to_transc[which_gene]=2;
else
genotype->min_N_activator_to_transc[which_gene]=1;
mut_record->kinetic_type=4;
mut_record->kinetic_diff=(float)genotype->min_N_activator_to_transc[which_gene];
update_cisreg_cluster(genotype,which_gene,'s',NULL,NA,NA);
break;
}
else
{
/* The rest mutation rates are proportional to gene length, so we can pick which genes first*/
random2=RngStream_RandInt(RS,1,genotype->total_loci_length);
which_gene=N_SIGNAL_TF-1;
while(which_gene<genotype->ngenes-1 && random2>0)
{
which_gene++;
random2-=genotype->locus_length[which_gene];
}
mut_record->which_gene=which_gene;
/* now pick which type of mutation*/
random-=total_mut_cooperation;
/******************************** mut mRNAdecay **********************/
if(random<=total_mut_mRNA_decay)
{
genotype->mRNA_decay_rate[which_gene]=mut_make_new_value(genotype->mRNA_decay_rate[which_gene],miu_mRNA_decay,sigma_mRNA_decay, MAX_MRNA_DECAY, MIN_MRNA_DECAY,RS,mut_record,BOUND_INCLUDED);
/*record mutation info*/
mut_record->kinetic_type=1;
mut_record->kinetic_diff=genotype->mRNA_decay_rate[which_gene];
break;
}
else
{
random-=total_mut_mRNA_decay;
/*************************** mut translation *********************/
if(random<=total_mut_translation_rate)
{
genotype->translation_rate[which_gene]=mut_make_new_value(genotype->translation_rate[which_gene],miu_protein_syn_rate,sigma_protein_syn_rate, MAX_PROTEIN_SYN_RATE, MIN_PROTEIN_SYN_RATE,RS,mut_record,BOUND_INCLUDED);
mut_record->kinetic_type=2;
mut_record->kinetic_diff=genotype->translation_rate[which_gene];
break;
}
else
{
random-=total_mut_translation_rate;
/********************* mut protein decay **********************/
if(random<=total_mut_protein_decay)
{
genotype->protein_decay_rate[which_gene]=mut_make_new_value(genotype->protein_decay_rate[which_gene],miu_protein_decay,sigma_protein_decay,MAX_PROTEIN_DECAY,MIN_PROTEIN_DECAY,RS,mut_record,BOUND_INCLUDED);
mut_record->kinetic_type=3;
mut_record->kinetic_diff=genotype->protein_decay_rate[which_gene];
break;
}
}
}
}
}
}
}