Hello Perl Monks,

I am very new to Perl and I have a question. I have two input files.

In the fist file I have ID with sequence.

File1:

string1 (C)C(T)A string2 T(A)GG(A)GGG(G)

In File2, the second column gives the position where the bracket is located in File1. And the 3rd Column has the same character as located in File1 at that position. And the 4th Column gives the character that it can be replaced with the one in the 3rd Coulmn.

File2:

string1 1 C A string1 3 T C string2 2 A C string2 5 A T string2 9 G A

I looking for an output, which has all the possible combinations (provided in file2).

For example, For string1 Position1, the two characters that this position can have is C and A. Again, string1 Position8, the two characters that this position can gave is T and C. Therefore, I am looking for all the possible combinations possible between C/A and T/C. Similarly, for string2, I am looking for all the possible combinations between A/T , C/A and T/G.

Expected Output:

string1 (C)C(T)A string1 (C)C(C)A string1 (A)C(T)A string1 (A)C(C)A string2 T(A)GG(A)GGG(G) string2 T(A)GG(A)GGG(A) string2 T(A)GG(T)GGG(A) string2 T(A)GG(T)GGG(G) string2 T(C)GG(A)GGG(G) string2 T(C)GG(A)GGG(G) string2 T(C)GG(T)GGG(A) string2 T(C)GG(T)GGG(A)

I am very new to PERL would highly appreciate if somebody can help me with this.

Thank you.


In reply to Looking for Printing all possible combinations by sarkar

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.