The pairing is true if the difference between end of one string and start value of the other string is greater than 300.
Just turn your words into code :)
#!/usr/bin/perl use strict; use warnings; my @data; while (<DATA>) { push @data, [ $_, (split ' ')[2,3] ]; # [ input-line, start, end +] } my $cnt; for my $d1 (@data) { for my $d2 (@data) { my $dist = $d1->[1] - $d2->[2]; # start of one - end of the + other if ($dist > 300) { print "Pair", ++$cnt, ":\n"; print " ", $d2->[0]; print " ", $d1->[0]; print "Distance: $dist\n"; } } } __DATA__ ACNGYNDHNG 10 1333 1343 1152 AVDVHVHNGG 10 209 219 2916 ACNGYNDHNGARRT 14 1333 1347 4608 GNDNNVNNRHNNNNVMNNVNNT 22 1589 1611 6291456
Output:
Pair1: AVDVHVHNGG 10 209 219 2916 ACNGYNDHNG 10 1333 1343 1152 Distance: 1114 Pair2: AVDVHVHNGG 10 209 219 2916 ACNGYNDHNGARRT 14 1333 1347 4608 Distance: 1114 Pair3: AVDVHVHNGG 10 209 219 2916 GNDNNVNNRHNNNNVMNNVNNT 22 1589 1611 6291456 Distance: 1370
In reply to Re: how to pair strings based on positional differences
by almut
in thread how to pair strings based on positional differences
by BhariD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |