[Forwarding Bruno's reply.... -Dave]
---------- Forwarded message ----------
From: Bruno Vecchi <
vecchi.b@...>
Date: Fri, Jun 26, 2009 at 14:44
Subject: Re: [Bioperl-l] Random nucleotide string generator?
To: Dave Messina <
David.Messina@...>
Here's a little script that I used for a somewhat related task. It produces
a randomized version of an input sequence (thus keeping the original's
composition). Maybe you could adjust it to your needs; providing an input
sequence with the desired length and composition you should get what you
want.
#!perl
use List::Util qw(shuffle);
use Bio::SeqIO;
my ($seqfile, $number) = @ARGV;
my $in = Bio::SeqIO->new(-file => $seqfile);
my $fh = Bio::SeqIO->newFh(-format => 'fasta');
my $seq = $in->next_seq;
my @chars = split '', $seq->seq;
for my $i (1 .. $number) {
@chars = shuffle @chars;
my $new_seq = Bio::Seq->new(-id => $i, -seq => join '', @chars);
print $fh $new_seq;
}
You can use it like this from the command line (assuming you want 20 output
sequences):
shuffle.pl input_sequence.fasta 20 > random_sequences.fasta
Bruno.
2009/6/26 Dave Messina <
David.Messina@...>
_______________________________________________
Bioperl-l mailing list
Bioperl-l@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l