#!/usr/bin/perl
#
# This script assumes that the input GFF file has only CDS/tRNA/rRNA/tmRNA
# features. It adds gene features to all of them, and also adds "mRNA" features
# to each CDSs.
#
#
while (<>) {
chomp;
print $_, "\n" if /^#/;
last if /^##FASTA/ || /^>/;
my @data = split /\t/, $_;
if ($data[2] =~ /(CDS|rRNA|tRNA|tmRNA)/) { # skip e.g. repeat_region
$type = $1;
$data[2] = 'gene';
print join "\t", @data; print "\n"; # add gene feature
if ($type eq 'CDS') {
$data[2] = 'mRNA';
print join "\t", @data; print "\n";
}
}
print $_, "\n"; # print the original line
}