Your file 1 has only one line. Is this going to be the case with your real data? If yes, you only need to pick up the lines of file 2 where column two falls between the range defined by file 1.
But if file 1 has several lines, then you need to explain how to do the match between the two files.
From looking at your data, maybe you want this: for each line in file 1, check the ID (e.g. chr11) in the second field, pick up the pivot value in the 4th field (650), and grab in file 2 all lines whose ID is chr11 and whose second field is within the range (650-500..650+500).
If this is what you want, I suggest that you should read the full file 1 and store ID/4th field of each line in a hash. Close File 1. Read file 2, for each line in file 2, check the ID, lookup the pivot value for this ID in the hash, and check if field 2 falls within the range.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.