1 |
#!/usr/bin/perl -w |
2 |
use strict; |
3 |
|
4 |
# randomize 10% of nucleotides |
5 |
|
6 |
my @nucleotides = ( 'A', 'C', 'G', 'T' ); |
7 |
|
8 |
while ( my $DNA = <> ) { |
9 |
chomp( $DNA ); |
10 |
my $DNA_length = length( $DNA ); |
11 |
warn "DNA has $DNA_length nucleotides\n"; |
12 |
my $mutations = int( $DNA_length / 10 ); |
13 |
warn "We will perform $mutations mutations\n"; |
14 |
my @mutated_DNA = split( //, $DNA ); |
15 |
for ( 1 .. $mutations ) { |
16 |
my $mutation_position = int( rand( $DNA_length ) ); |
17 |
my $random_position = int( rand( $#nucleotides ) ); |
18 |
my $random_nucleotide = $nucleotides[ $random_position ]; |
19 |
$mutated_DNA[ $mutation_position ] = $random_nucleotide; |
20 |
warn "mutation on $mutation_position to $random_nucleotide\n"; |
21 |
} |
22 |
warn "$DNA\n"; |
23 |
print join('', @mutated_DNA),"\n"; |
24 |
} |