Please read Markup in the Monastery. Note how your square backets have been turned into a link. I see the bare </code> in your post, but that should have been written (I think) as
<code> if($seqR =~m/\G([A-Z]{3,7})+?$_/g) { #print "All repeated sequences $_\n"; }; </code>

This also sounds a bit like homework, and a bit like you are getting ahead of yourself. As discussed in How do I post a question effectively?, think about what you are trying to do and where you are hitting issues. Are you sure your randomly generated strings contain what you think they do?.

Where did you get the code you've posted. You have a \G in there, which does not really make sense in the context you're calling here. See Assertions in perlre for documentation. You are also inlining $_ into your regex, which makes no sense to me. And going for a non-greedy match, which is strange as well (see Metacharacters). What was the source material for this construction? Have you read perlretut for a basic description of what regular expression do?

You probably want to use backreferences -- see Capture groups in perlre. Perhaps you confused \G and \g? You also probably want to use pos, $& and/or $-[0] in some combination to figure out positions, however you'd like to define that. So ending up with something like:

while($seqR =~m/([ATGC])\g1{2,6})+/g) { my $position = pos; print "$& found at $position\n" };

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: find all repeating sequences by kennethk
in thread find all repeating sequences by charm

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.