oxydeepu has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Hexamer combination from 3mers.
by marto (Cardinal) on Oct 10, 2012 at 15:44 UTC

    Which part are you having problems with? How would you solve the problem using a pen and paper? I suspect you've been given this as a learning exercise, asking others to solve the problem word defeat the purpose of such an exercise

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Hexamer combination from 3mers.
by daxim (Curate) on Oct 10, 2012 at 15:53 UTC
    use 5.010; use Algorithm::Combinatorics qw(variations_with_repetition); say join q(), @{ $_ } for variations_with_repetition [qw(ABC EFG KLM XYZ)], 2; __END__ ABCABC ABCEFG ABCKLM ABCXYZ EFGABC EFGEFG EFGKLM EFGXYZ KLMABC KLMEFG KLMKLM KLMXYZ XYZABC XYZEFG XYZKLM XYZXYZ
Re: Hexamer combination from 3mers.
by choroba (Cardinal) on Oct 10, 2012 at 15:47 UTC
    #!/usr/bin/perl use strict; use warnings; use feature 'say'; my @trimers = <>; chomp @trimers; say for glob +('{' . join(',', @trimers) . '}' ) x 2;
    Update: Using glob is safe only if the data do not contain any special characters like ? * [] {} , or whitespace.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Hi,
      Thanks alot. That works.
      Best,
      Deepak

Re: Hexamer combination from 3mers.
by 2teez (Vicar) on Oct 10, 2012 at 16:34 UTC

    Or you could simply use a foreach loop like so:

    use warnings; use strict; my @three_mers = qw( ABC EFG KLM XYZ); foreach my $mers_first (@three_mers) { foreach my $mers_sec (@three_mers) { print $mers_first, $mers_sec, $/; } }
    OUTPUT
    ABCABC ABCEFG ABCKLM ABCXYZ EFGABC EFGEFG EFGKLM EFGXYZ KLMABC KLMEFG KLMKLM KLMXYZ XYZABC XYZEFG XYZKLM XYZXYZ

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me