Good day, dear Monks!
Unfortinatly I use Perl rather rarely. At the current moment I'm dealing with genomic coordinates. I have two large arrays with data. The fist contains some coordinates and the second contains distances. Among coordinates there are unique ones and repeats. Although distance value for every coordinate is unique. I would like to compose the final set of unique coordinates and corresponding distances. The main thing is excluding the repeating coordinates. The condition is the following: to chose those pare of coordinate - distance which has the smallest distance value.
So the example of the data the following:
coordinate distance 567 344 1345 567 2346 78 3456 67 3456 789 4678 45 5349 6 6700 124 6700 50 8964 560
I have written some very simple script
$coord = 'coordinate.txt'; open(COORD, $coord) || die("Couldn't read file $coord\n"); $dist = 'dist.txt'; open(DIST, $dist) || die("Couldn't read file $dist\n"); @d = <DIST>; @c = <COORD>; for ( $i = 0; $i <= 13; $i++ ) { if ( $c[$i] != $c[$i+1] ) { printf "%d %d\n", $c[$i], $d[$i]; } }
It selects the last line of repeat without comparing the distance values. How would you advise to change it to get only unique coordinetes-distances pairs. And to chose those pare of coordinate - distance which has the smallest distance value if there are repetative coordinates.
So for those data, given earlier I try to get the output like this:coordinate distance 567 344 1345 567 2346 78 3456 67 4678 45 5349 6 6700 50 8964 560
Thank you in advance!
In reply to Repeats exclusion by Grig
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |