#!/usr/bin/perl
# 2001/11/27 - I. Dutour

# Ignorer toutes les lignes jusqu'au trait horizontal
while (<>) {
    last
	if (/^----------/);
}

my $block_size = 0;

# Lire toutes les lignes.
while (<>) {
    chomp;
    last 
	if (/----------/ or /^$/);
    ($orf,$start,$stop,$gene,$disrupt,
     $length,$cai,$mo,$tm,$class,$desc) =
        ($_ =~ /^
	        \s* ([-\w]+)      \s*    \| # id de l'ORF
  		\s* \((\d+)-(\d+) [^\|]* \| # coordonnées
	        \s* ([^\|]*)      \s*    \| # gene
	        \s* ([\/\w]*)     \s*    \| # disrupt
	        \s* ([\w]*)       \s*    \| # length
	        \s* ([\.\w]*)     \s*    \| # cai
	        \s* ([\w]*)       \s*    \| # mo
	        \s* ([\w]*)       \s*    \| # tm
	        \s* ([\w]*)       \s*    \| # class
	        \s* ([^\|]*)                # desc
	       $/x);

    my $size = abs($stop - $start);

    if ($block_size + $size <= 5000) {
	print "$orf ";
	$block_size += $size; # et continuer
    } else {
	printf "(%4.2f kb)\n", $block_size / 1000.0;
	print "$orf ";
	$block_size = $size;
    }
}

if ($block_size>0) {
    printf "(%4.2f kb)\n", $block_size / 1000.0;
}

print "\n"; # retour à la ligne



