gawk 'BEGIN{OFS="\t"} $4 ~ /CDSf|CDSi|CDSl/ \
{ print "apo1", "fgenesh", $4, start=($5<$7 ? $5 : $7), \
end=($7<$5 ? $5 : $7), $8, $2, $3, $1; }' \
apo1.masked.fgenesh.txt | sed 's/.[0-9][0-9]$//' > apo1.masked.fgenesh.gff