in reply to Help regarding the outout of the program
#!/usr/bin/perl use strict; use warnings; print "The DNA sequence is : \n" ; my $seq = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; print "$seq \n"; mutate ($seq); exit; sub mutate{ my($dna) = shift; my $position = randposition($dna); print " mutation at base position ". ($position+1) . "\n"; my $nucleotide = randombase(substr($dna,$position,1)); substr($dna, $position, 1, $nucleotide); print "$dna\n"; } sub randposition{ my($sequence) = @_; return int rand length($sequence); } sub randombase{ my $base=shift; my(%nucleo)=( 'A'=>['T','C','G'], 'T'=>['A','C','G'], 'C'=>['A','T','G'], 'G'=>['A','T','G'], ); return $nucleo{$base}[rand(@{$nucleo{$base}})]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help regarding the outout of the program
by roboticus (Chancellor) on Feb 24, 2010 at 12:04 UTC |