Dear CountZero and other senior Perlmonks who replied to my post: This is basically what I am trying to do:

you have a text file with string like this

CGAATTAATGGGAATTG

and you have your reference sequence saying

CGAATTAAGGAATTG

note your input has two letters inserted, which are TG

So you will get CIGAR ID from your alignment program saying

8M2I7M

To help you understand visually (so originally no blank), I manually aligned these two string variables.

CGAATTAATGGGAATTG

CGAATTAA GGAATTG

So using this I would like to keep the same original letter position for inputs... that is why I have to compare input string variables to reference string variables to make them have the same letter position (basically insertions are useless)

For deletions, I have the exact opposite situation.. so lets flip my first example's situation This case it will be 8M2D7M

CGAATTAA GGAATTG <--- my input for 2nd example (the gap is again intentionally made)

CGAATTAATGGGAATTG <--- my output for 2nd example

you see I am missing two letters and I need some letter holders to keep the input's letter positions the same compared to the reference.. so I want to fill two X's

CGAATTAAXXGGAATTG <--- same length, other letter positions will be the same

I also posted the link which leads to the original post that I had with a different problem (already fixed) there you can find my input files. Thank you for your help


In reply to Re^2: string manipulation with Regex by FluffyBunny
in thread string manipulation with Regex by FluffyBunny

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.