blob: 65c351e5629b16974f247f9679c56d8d04a5661f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/env perl
use strict;
use warnings;
use 5.016;
my %dna;
sub check_pair {
my ($name, $other) = @_;
return if $name eq $other;
if (substr($dna{$name}, 0, 3) eq substr($dna{$other}, -3)) {
say "$other $name";
}
if (substr($dna{$other}, 0, 3) eq substr($dna{$name}, -3)) {
say "$name $other";
}
}
my ($name, $dna);
while (<>) {
chomp;
if (/^>(.*)/) {
my $new_name = $1;
if ($name) {
$dna{$name} = $dna;
for my $other (keys %dna) {
check_pair($name, $other);
}
}
$name = $new_name;
$dna = '';
}
else {
$dna .= $_;
}
}
$dna{$name} = $dna;
for my $other (keys %dna) {
check_pair($name, $other);
}
|