<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

my $no = 0;
my $clstr_no = "";
my @this_cluster = ();

print "id	clstr	clstr_size	length	clstr_rep	clstr_iden	clstr_cov\n";
while($ll = &lt;&gt;) {
  if ($ll =~ /^&gt;/) {
    if ($no&gt;0) {
      process_this_cluster();
    }
    if ($ll =~ /^&gt;Cluster (\d+)/) {
      $clstr_no = $1;
    }
    $no = 0;
    @this_cluster = ();
  }
  else {
    my ($id, $len, $rep, $iden);
    if ($ll =~ /\d+\t(\d+)[a-z]{2}, &gt;(.+)\.\.\. \*/) {
      $len = $1;
      $id  = $2;
      $rep = 1;
      $iden = 100;
      
    }
    elsif ($ll =~ /\d+\t(\d+)[a-z]{2}, &gt;(.+)\.\.\./) {
      $len = $1;
      $id  = $2;
      $rep = 0;
      $ll=~/(\d+%|\d+\.\d+%)$/;
      $iden = $1;
    }
    else {
      print STDERR "***********\n";
    }
    push(@this_cluster, [($id, $len, $rep, $iden)]);
    $no++;
  }
}
    if ($no&gt;0) {
      process_this_cluster();
    }

sub process_this_cluster {
  my ($i, $j, $k);
  my @t = sort { ($b-&gt;[2] &lt;=&gt; $a-&gt;[2]) or ( $b-&gt;[1] &lt;=&gt; $a-&gt;[1])  } @this_cluster;
  my $longest = 0;
  foreach $i (@t) {
    $longest = $i-&gt;[1] if ($i-&gt;[2]);
  }
  foreach $i (@t) {
    my $cov = int ( $i-&gt;[1]/$longest * 100);
    print "$i-&gt;[0]\t$clstr_no\t$no\t$i-&gt;[1]\t$i-&gt;[2]\t$i-&gt;[3]\t$cov\%\n";
  }
}
</pre></body></html>