-
Notifications
You must be signed in to change notification settings - Fork 129
/
clstr2tree.pl
executable file
·51 lines (48 loc) · 956 Bytes
/
clstr2tree.pl
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
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env perl
$clstr = shift;
$fr = shift; # for nr80.clstr $fr = 0.8
$fra = 1 - $fr;
print "(\n";
open(TMP, $clstr) || die;
my $ll;
my $no = 0;
my @ids = ();
my $rep = "";
while($ll=<TMP>) {
if ($ll =~ /^>/) {
if ($no) {
if ($no ==1 ) { print "$rep:1.0,\n";}
else {
my @mms = ();
foreach my $tid (@ids) {
push(@mms, "$tid:$fra");
}
my $mm = join(",\n", @mms);
print "(\n$mm\n):$fr,\n";
}
}
$no = 0;
@ids = ();
$rep = "";
}
else {
my $tid= "";
if ($ll =~ /(aa|nt), >(.+)\.\.\./) { $tid=$2;}
push(@ids,$tid);
if ($ll =~ /\*/) {$rep = $tid;}
$no++;
}
}
if ($no) {
if ($no ==1 ) { print "$rep:1.0\n";}
else {
my @mms = ();
foreach my $tid (@ids) {
push(@mms, "$tid:$fra");
}
my $mm = join(",\n", @mms);
print "(\n$mm\n):$fr\n";
}
}
close(TMP);
print ");\n";