[Bioperl-l] Random nucleotide string generator?

Dave Messina David.Messina at sbc.su.se
Fri Jun 26 08:58:20 EDT 2009


[Forwarding Bruno's reply.... -Dave]
---------- Forwarded message ----------
From: Bruno Vecchi <vecchi.b at gmail.com>
Date: Fri, Jun 26, 2009 at 14:44
Subject: Re: [Bioperl-l] Random nucleotide string generator?
To: Dave Messina <David.Messina at sbc.su.se>


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 at sbc.su.se>

> The Bioperl solution piggybacks on EMBOSS. See Chris Fields' comment on
> this
> post from Neil Saunders' blog:
>
> http://nsaunders.wordpress.com/2007/07/25/howto-generate-random-sequences-using-emboss-and-perl/
>
>
> You can also do this outside of BioPerl using shuffle from Sean Eddy's
> SQUID
> package, available here:
> [ SQUID ftp site ] <ftp://selab.janelia.org/pub/software/squid/>
>
> <ftp://selab.janelia.org/pub/software/squid/>
>
> If not - what should the namespace be for such a module should it be undone
> > and desirable?
>
>
> Perhaps add it to Bio::SeqUtils?
>
>
> Dave
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>


More information about the Bioperl-l mailing list