Sorry, mir war gerade danach:
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
use strict;
use warnings;
{
my @POOL = qw( A C G T );
sub mutate {
my $str = shift;
my @positions = @_;
for my $pos ( @positions ) {
my $original = substr $str, $pos-1, 1;
my @replacer = grep { $_ ne $original } @POOL;
substr( $str, $pos-1, 1) = $replacer[ rand @replacer ];
}
return $str;
}
}
my $sequence = "ACTA";
print mutate($sequence,3,4);
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!