Kajed has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to generate random strings from a set string with all of them being the same length and can be found already present inside the known string.
my $DNA = "AACCGTTAATGGGCATCGATGCTATGCGAGCT"; $DNA_length = length($DNA); my $random_sequence = &random_sequence($DNA); my $random_position = &random_position($DNA_length); my $random_base = &mutate(); $DNA[$random_sequence] = $DNA; my @DNA_array = split("", $DNA); print "$random_position\t$random_base\n"; $DNA_array[$random_position] = $random_base; print join("", @DNA_array), "\n"; sub random_sequence { my $sequence = m/\w*[ACTG]{5}*/; my $new_sequence = int(rand(scalar $sequence) return $sequence[$new_sequence]; sub random_position { my ($seed) = @_; return int(rand($seed)); } sub mutate { my @base_array = ('A','C','G','T'); my $random_base = int(rand(scalar @base_array)); return $base_array[$random_base]; }
I can get the random replacement but i cannot get the random sequence that the replacement is supposed to occur in. I have searched for a similar problem but none that I found helped solve the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Generating mulitple random strings of a set length
by thomas895 (Deacon) on May 08, 2015 at 05:23 UTC | |
|
Re: Generating mulitple random strings of a set length
by aaron_baugher (Curate) on May 08, 2015 at 10:01 UTC | |
|
Re: Generating mulitple random strings of a set length
by vinoth.ree (Monsignor) on May 08, 2015 at 10:45 UTC | |
|
Re: Generating mulitple random strings of a set length
by edimusrex (Monk) on May 08, 2015 at 14:36 UTC |