| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Fixation rates for mu |
"phillip smith" wrote
>
> From Kimura the time for a neutral mutation to be fixed is the mutation
> rate.
> If I have ten genes each of which can have a neutral mutation. What is the
> mean time taken for there to be no individuals which are free of
mutation.
> That is the whole population carries at least one of the ten mutations
>
Here's a simulation for you, written in C.
(It is portable and should work on any computer with a C compiler. Post here
if you want me to send you a PC executable compiled by me).
#include
#include
#include
#include
#define WILD 0
#define MUTANT 1
typedef struct
{
char *maternal; /* maternal genes */
char *paternal; /* paternal genes */
} ORGANISM;
typedef struct
{
int Nmales; /* number of males */
int Nfemales; /* number of females */
ORGANISM *males; /* list of males */
ORGANISM *females; /* list of females */
int Ngenes; /* no genes each organism has */
} GENERATION;
GENERATION *generation(int N, int Ngenes);
void killgeneration(GENERATION *g);
void addwild(GENERATION *g);
void nextgen(GENERATION *prev, GENERATION *next);
int countmutants(GENERATION *g);
void breed(ORGANISM *mother, ORGANISM *father, ORGANISM *child, int Ngenes);
int hasmutant(ORGANISM *org, int Ngenes);
int random(int N);
int main(int argc, char **argv)
{
int N;
int Ngenes;
int gen = 0;
GENERATION *g1;
GENERATION *g2;
GENERATION *gtemp;
int muts;
srand(time(0));
printf("Traces fixation of mutant genes through a population\n, by genetic
drift.");
printf("Each mutant is originally present in a single copy\n");
printf("The population is diploid and sexual\n");
printf("Population size (min 4)\n");
while( scanf("%d", &N) != 1)
printf("Bad input\n");
if(N < 4)
{
printf("Bad input\n");
exit(EXIT_FAILURE);
}
printf("Number of genes (min 1)\n");
while(scanf("%d", &Ngenes) != 1)
printf("Bad input\n");
if(Ngenes < 1)
{
printf("Bad Input\n");
exit(EXIT_FAILURE);
}
printf("N = %d, Ngenes = %d\n", N, Ngenes);
g1 = generation(N, Ngenes);
if(!g1)
{
printf("Out of memory\n");
exit(EXIT_FAILURE);
}
g2 = generation(N, Ngenes);
if(!g2)
{
killgeneration(g1);
printf("Out of memory\n");
exit(EXIT_FAILURE);
}
addwild(g1);
printf("Gen 0 mutants %d\n", countmutants(g1));
do
{
gen++;
nextgen( g1, g2);
muts = countmutants(g2);
printf("Gen %d mutants %d\n", gen, muts);
gtemp = g1;
g1 = g2;
g2 = gtemp;
}
while(muts > 0 && muts < N);
return 0;
}
/*
Creates the gereration structure
Params: N - population size
Ngenes - number of loci
*/
GENERATION *generation(int N, int Ngenes)
{
GENERATION *answer;
int i;
int ii;
assert(N >= 4);
assert(Ngenes > 0);
answer = malloc(sizeof(GENERATION));
if(!answer)
return 0;
answer->Nmales = N/2;
answer->Nfemales = N - answer->Nmales;
answer->males = malloc( answer->Nmales * sizeof(ORGANISM));
if(!answer->males)
{
killgeneration(answer);
return 0;
}
for(i=0;iNmales;i++)
{
answer->males[i].maternal = 0;
answer->males[i].paternal = 0;
}
answer->females = malloc(answer->Nfemales * sizeof(ORGANISM));
if(!answer->females)
{
killgeneration(answer);
return 0;
}
for(i=0;iNfemales;i++)
{
answer->females[i].maternal = 0;
answer->females[i].paternal = 0;
}
for(i=0;iNmales;i++)
{
answer->males[i].maternal = malloc(Ngenes);
if(!answer->males[i].maternal)
{
killgeneration(answer);
return 0;
}
for(ii=0;ii * Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)SEEN-BY: 633/267 270 @PATH: 278/230 10/345 106/1 2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.