#!/usr/bin/perl -w use strict; use List::Util 'shuffle'; use List::Util 'shuffle'; #g=generation #G=Generation # my @g0; my %allgen; my $i; my $j; @g0= ("ATTGTACATGTAGTTCTA"); #Initial generation "seeding generation" %allgen=(0 =>\@g0); for($i=1;$i<20;$i++) # This $i determines the number of replications { my @new_gen=(); my @last_gen=@{$allgen{$i-1}}; foreach my $seq_string(@last_gen) { chomp $seq_string; my @nucleotide_array = split(//,$seq_string); my $rand_virus=(int rand(0+10)); # this will randomly select a number of viruses that will seed the new generation from the pool of the last generation for($j=0;$j<$rand_virus;$j++) #This loop should allow only $rand_virus sequnces from the new generation to be selected for"multiplying" { my $new_string; foreach my $nucleotide(@nucleotide_array) { chomp $nucleotide; my($T,$G,$C,$A); #These mutations rates are just for testing now they dont reflect accurate viral mutation rates yet if ($nucleotide eq 'A'){ # $T=.1;$G=.2;$C=.3;$A=.7; my $score = (int rand(0+1000))/1000; if( $score>=000 && $score<=.099){ $nucleotide=~s/A/T/g;} if( $score>=.100 && $score<=.199){ $nucleotide=~s/A/G/g;} if( $score>=.200 && $score<=.299){ $nucleotide=~s/A/C/g;} # if( $score>=.300 && $score<=1.00){ Do NOTHING } } } elsif ($nucleotide eq 'T'){ # $A=.1;$G=.2;$C=.3;$T=.7; my $score = (int rand(0+1000))/1000; if( $score>=0 && $score<=.099){ $nucleotide=~s/T/A/g;} if( $score>=.100 && $score<=.199){ $nucleotide=~s/T/G/g;} if( $score>=.200 && $score<=.299){ $nucleotide=~s/T/C/g;} #if( $score>=.300 && $score<=1.00){ DO NOTHING } } } elsif ($nucleotide eq 'C'){ # $T=.1;$G=.2;$A=.3;$C=.7; my $score = (int rand(0+1000))/1000; if( $score>=0 && $score<=.099){ $nucleotide=~s/C/T/g;} if( $score>=.100 && $score<=.199){ $nucleotide=~s/C/G/g;} if( $score>=.200 && $score<=.299){ $nucleotide=~s/C/A/g;} #if( $score>=.300 && $score<=1.00){ #No mutation} } elsif ($nucleotide eq 'G'){ # $T=.1;$A=.2;$C=.3;$G=.7; my $score = (int rand(0+1000))/1000; if( $score>=0 && $score<=.099){ $nucleotide=~s/G/T/g;} if( $score>=.100 && $score<=.199){ $nucleotide=~s/G/A/g;} if( $score>=.200 && $score<=.299){ $nucleotide=~s/G/C/g;} #if( $score>=.300 && $score<=1.00){ #No mutation} } $new_string= $new_string . $nucleotide; } push(@new_gen,$new_string); } } @new_gen=shuffle(@new_gen); #print $allgen{0}[0] . "\n"; $allgen{$i}=\@new_gen; } for my $ii(0..20){ for (my $jj=0;$jj<(length($jj));$jj++){ print "$ii\t$allgen{$ii}[$jj] \n"; } }