in reply to Sorting Data By Overlapping Intervals
I would propose two modifications. First, when you load the data from file, already extract the fourth column and store it alongside the lines:
my @SNPs = map { [ (split /\t/)[3], $_ ] } <CG>;
So each element of @SNPs is now an array reference, whose first element is the fourth column and the second element is the full line.
As the second change, in your loop over the intervals pick all elements that fall in this interval using grep and the extract the line from the array reference using map:
my @inInterval = map { $_->[1] } grep { $start <= $_->[0] and $_->[0] +<= $end } @SNPs;
All you need then is to print these lines into the relevant file.
I am not sure whether I explain this well...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting Data By Overlapping Intervals
by ccelt09 (Sexton) on Oct 31, 2013 at 10:59 UTC | |
by hdb (Monsignor) on Oct 31, 2013 at 11:20 UTC |