I have this file
427 A C A/C 12
436 G C G/C 12
445 C T C/T 12
447 A G A/G 9
451 T C T/C 5
456 A G A/G 12
493 G A G/A 12
I wanted to read the first column and find all other ids which are differences less than 10.
427 A C A/C 12 436
436 G C G/C 12 427,445
445 C T C/T 12 436,447,451
447 A G A/G 9 445,451,456
451 T C T/C 5 445,447,456
456 A G A/G 12 451,447
493 G A G/A 12
The last column should be like the above. All id’s which are + or – 10 bases apart from that specific id. For example for 436, the boundaries are {426 – 446} other id’s which are in that range are 427 and 445 so i displayed them in 6th column..
Here’s one way using Perl:
Output: