Hello,
I have written a program to simulate CNV, into the reference genome.
It take the Reference Genome/Chromosome as input. The program then generates a Random number(X), copies the segment from that position(X), size specified by user.
Then generates another random number(Y), and inserts the copied segment from X position, at Y position. The output is the modified input file with inserted CNV and a txt file with Location of CNVs ie. position where copied from (X) and where Inserted (Y).
I give the Random Number generation function MIN and MAX value. MIN =1 and MAX=last Position(Size), it then generates a Random number within these limits.
Problem is, with same input(MIN & MAX) the random numbers generated is same. eg. If I make my program run once and generate 100 numbers, they are random. But if I generate 100 numbers by running the program again, the numbers are same as before.
CODE:
//call this function first to seed
void initialize_rand(){
srand((unsigned)(time(0)));
}
//generates a psuedo-random integer between min and max
long int randint(long int min, long int max){
if(min>max){
return lrand48()%(min-max)+max;
}
else{
return lrand48()%(max-min)+min;
}
}
I have written a program to simulate CNV, into the reference genome.
It take the Reference Genome/Chromosome as input. The program then generates a Random number(X), copies the segment from that position(X), size specified by user.
Then generates another random number(Y), and inserts the copied segment from X position, at Y position. The output is the modified input file with inserted CNV and a txt file with Location of CNVs ie. position where copied from (X) and where Inserted (Y).
I give the Random Number generation function MIN and MAX value. MIN =1 and MAX=last Position(Size), it then generates a Random number within these limits.
Problem is, with same input(MIN & MAX) the random numbers generated is same. eg. If I make my program run once and generate 100 numbers, they are random. But if I generate 100 numbers by running the program again, the numbers are same as before.
CODE:
//call this function first to seed
void initialize_rand(){
srand((unsigned)(time(0)));
}
//generates a psuedo-random integer between min and max
long int randint(long int min, long int max){
if(min>max){
return lrand48()%(min-max)+max;
}
else{
return lrand48()%(max-min)+min;
}
}
Comment