Dear Monks!
I have a file in the following format:
ID:A0AWZ5 HIT:PF12951 SCORE:40.0 EVALUE:2.2e-10 HMM_START:2 HMM_END: +32 SEQ_START:421 SEQ_END:455 HIT:PF03797 SCORE:130.7 EVALUE:3.6e-40 HMM_START:7 HMM_END +:261 SEQ_START:822 SEQ_END:1073 HIT:PF12951 SCORE:38.7 EVALUE:5.5e-10 HMM_START:1 HMM_END: +32 SEQ_START:515 SEQ_END:547 //

I have generated an array of arrays from this file:
$/="//\n"; while(<>) { if($_=~/^ID:(.*)/m) { $id=$1; $seq=$hash_f{$id}; @AoA=(); while($_=~/^HIT:(.*?)\tSCORE:[\d\.]+\tEVALUE:[\d\.\-\w]+\tHMM_ +START:\d+\tHMM_END:\d+\tSEQ_START:(\d+)\tSEQ_END:(\d+)/mg) { $pfam_name=$1; $seq_start=$2; $seq_end=$3; push @AoA, [ $pfam_name, $seq_start, $seq_end ]; } } print $id."\n"; for $i ( 0 .. $#AoA ) { print "$i\t [ @{$AoA[$i]} ],\n"; } } $/="\n";

which prints:
A0AWZ5 0 [ PF12951 421 455 ], 1 [ PF03797 822 1073 ], 2 [ PF12951 515 547 ],

My question is the following:
Some of the codes (like PF03797 for example) are different than the rest for the scope of my program. What I need to do is, when I find such codes (I have them stored in a hash), then I would need to find the elements in the array of arrays that are before and after them (if any) and then print the range from the end of the preceding element until the start of the subsequent one.
For example, in the case of A0AWZ5 that I have listed in my example, I would need to print, since PF03797 is indeed one of these "important" codes, the range from 548 (the end of the preceding element in the array of arrays until the end (since there is no subsequent element in this case).

In reply to Stuck in my final step of code using array of arrays by Anonymous Monk

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.