#!/usr/local/bin/perl -w

# Author: kdj@sanger.ac.uk
# purpose: Converts Glimmer output to an EMBL feature table

use strict;

my $get;

while (<>)
{
    /Putative Genes/ and $get++;

    next unless $get;

    if (/\s+(\d+)\s+(\d+)\s+(\d+)\s+\[([+-]\d+)\s+L=\s*\d+\]\s*(.*)/)
    {
	my ($id, $start, $end, $frame, $message) = ($1, $2, $3, $4, $5);
	my $location;

	if ($frame > 0)
	{
	    $location = "$start..$end";
	}
	else
	{
	    $location = "complement($end..$start)";
	}

	print "FT   CDS             $location\n";
	print "FT                   /note=\"$message\"\n";
	print "FT                   /label=$id\n";
	print "FT                   /colour=4\n";
    }
}

