in reply to Re^3: Comparing array of aligned sequences
in thread Comparing array of aligned sequences

Dear JohnGG, Thank you very much for your time and suggestions. It feels good to learn alternate ways to code for the same input. I have another question to ask regarding generating multiple strings from a general rule. I am trying to generate a string of 10 bases based on certain rule:C)2N3(A|G)4-6N7T8(A|T)9(A|T)10 where N could be (A or T or G or C). So according to the above rule, 1st and 2nd position could be a combination of (GG or GC or CG or CC) followed by (A or T or G or C) at position 3 followed by a combination of (AAA or AAG or AGG .. and so on). The thing which I am not able to figure out is do I need to put lot of loops to do it or is there any short way using perl. Thank you for any help or suggestions.

  • Comment on Re^4: Comparing array of aligned sequences

Replies are listed 'Best First'.
Re^5: Comparing array of aligned sequences
by johngg (Canon) on Jul 14, 2014 at 22:27 UTC

    The glob function is your friend :-)

    $ perl -Mstrict -Mwarnings -E ' my $rule = q{{c,g}} x 2; $rule .= q{{a,t,g,c}}; $rule .= q{{a,g}} x 3; $rule .= q{{a,t,g,c}}; $rule .= q{t}; $rule .= q{{a,t}} x 2; say $rule; say for glob $rule;' {c,g}{c,g}{a,t,g,c}{a,g}{a,g}{a,g}{a,t,g,c}t{a,t}{a,t} ccaaaaataa ccaaaaatat ccaaaaatta ccaaaaattt ccaaaattaa ccaaaattat ccaaaattta ccaaaatttt ccaaaagtaa ccaaaagtat ccaaaagtta ccaaaagttt ccaaaactaa ccaaaactat ... ggcgggatat ggcgggatta ggcgggattt ggcgggttaa ggcgggttat ggcgggttta ggcgggtttt ggcggggtaa ggcggggtat ggcggggtta ggcggggttt ggcgggctaa ggcgggctat ggcgggctta ggcgggcttt $

    Hopefully I've understood your rules correctly and this is helpful.

    Cheers,

    JohnGG

      Wow. I learn something every day here. Thank you.