/[Perly]/examples/Code/05-random.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /examples/Code/05-random.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 45 - (show annotations)
Sun Jun 8 18:09:07 2008 UTC (15 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 729 byte(s)
and examples
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 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26