Hallo,
I have problem in my subroutine, I want to DNA mutate my DNA at position 3 and 9. can some one here tel me how can I do it.
best regards
#!/usr/bin/perl
use strict;
use warnings;
my $DNA = 'ATGCATGCAT';
my $mutated_DNA = mutate_DNA($DNA);
print "$DNA imutates to $mutated_DNA\n";
exit;
sub mutate_DNA {
my($DNA) = @_;
my @bases = qw(A C G T);
my $position = 3;
my $base = $bases[$position];
my $newbase;
do {
$newbase = $bases[rand @bases];
} until ($newbase ne $base);
substr($DNA, $position, 1) = $newbase;
return $DNA;
}
I have problem in my subroutine, I want to DNA mutate my DNA at position 3 and 9. can some one here tel me how can I do it.
best regards
#!/usr/bin/perl
use strict;
use warnings;
my $DNA = 'ATGCATGCAT';
my $mutated_DNA = mutate_DNA($DNA);
print "$DNA imutates to $mutated_DNA\n";
exit;
sub mutate_DNA {
my($DNA) = @_;
my @bases = qw(A C G T);
my $position = 3;
my $base = $bases[$position];
my $newbase;
do {
$newbase = $bases[rand @bases];
} until ($newbase ne $base);
substr($DNA, $position, 1) = $newbase;
return $DNA;
}