As a humble seeker of assistance... I am looking to generate a script that returns the frequency of a short word in a longer original (a DNA sequence).... I have a one-liner for generating all possible short words of a certain length (k), e.g.;
perl -se '$,="\t"; print split / /, qx/echo @{["{$a}" x $k]}/;' -- -k= +4 -a='A,T,G,C'
This gives 256 tab delimited short DNA sequences. I would like to use these as column names, and score the frequency of each short DNA sequence in a set of longer sequences, e.g.
ACTG ATTG ATGC etc ATGCTGTACTG 1 0 1 ATGATGATCTG 0 0 0 ATGCGTATGCA 0 0 1 ATGCTAGACTG 1 0 1
The files are >20000 lines, and it would be nice to scale to larger short word sizes (i.e. 7 letter words such as'AGTGTAT' would generate >16000 columns for every combination), so efficiency is fairly important. Unfortunately I haven't been able to find a ready made example to do precisely what is required. Any guidance to this would be much appreciated. Thanks.

In reply to Find number of short words in long word by sedm1000

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.