Hello,
I want to filter records of a file if they fall in range associated with a second file. First the chr number (2nd col of 1st file and 1st col of 2nd file) needs to be matched. Then if the 3rd col of the first file falls within any of the ranges specified by the 2nd and 3rd cols , then that record goes to the output.
All files are sorted from low to high.
File to be filtered looks like
9927 chr1 83 T C
9927 chr1 92 A C
9927 chr1 97 A C
9927 chr2 262 C G
9927 chr2 292 C G
9927 chr2 367 C G
Range file looks like
chr1 46 84
chr1 95 227
chr2 261 326
Filtered output
9927 chr1 83 T C
9927 chr1 97 A C
9927 chr2 262 C G
9927 chr2 292 C G
I have 758 files to be filtered, I think I can do a loop like the following
if I have the inside magic_script.
for file in * do magic_script $file range_file > $file_filtered done