Jeff and larryk,
Thanks for your suggestions.
Jeff, I had already checked out your suggestions but they didn't cut the mustard. I probably wasn't specific enough in my original question but I need all the possibilities not the permutations (I'm not sure if that is the correct usage of possibilities/permutations . . .). Specifically I also need to generate sequences containing all the same base e.g. AAA, TTT etc.

The Ordered Combinations solution as suggested by larryk does what I need, an awesome little piece of code. Thanks to MeowChow, sachmet and tilly.

Here is the final piece of code for the record:

use strict; #generate all posibilites of a DNA sequence my @Bases = qw(A C G T); my $SequenceMinLenght = 1; my $SequenceMaxLength = 3; my @SequenceLenghts = ($SequenceMinLenght...$SequenceMaxLength); #print "@SequenceLenghts\n"; my $SequenceListLength = $#SequenceLenghts; $SequenceListLength ++; print "Number of Sequence lenghts to permute is $SequenceListLength\n" +; my @allSequence = (); my $sequence; my $currLenght; my @Ordered_Combinations_input = (); foreach $currLenght (@SequenceLenghts){ @Ordered_Combinations_input = (); @Ordered_Combinations_input = ($currLenght, @Bases); @allSequence = (@allSequence, (&Ordered_Combinations (@Ordered_Com +binations_input))); } #Prints sequences to screen # - Too many entries after lenght of sequence is grater than 4. my $i=0; foreach my $finalsequence (@allSequence){ $i ++; if ($i == 4){ print "$finalsequence\n"; $i= 0; } else{ print "$finalsequence\t"; } } #Completely blow the GOLF chalange by using a sub name almost as long +as the sub #See http://www.perlmonks.com/index.pl?node_id=75261 for details sub Ordered_Combinations {my$n=shift;--$n?map{my$d=$_;map$d.$_,Ordered +_Combinations($n,@_)}@_:@_};

In reply to Re: Generate all possibilities by lostcause
in thread Generate all possibilities by lostcause

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.