#!/usr/bin/env -S awk -f
# Convert a standard GFF 3 file
# into a custom TSV file
# to be used in detect TAGs step
# Usage: gff3_to_gene_positions_table.awk input.gff

BEGIN {
    OFS="\t"
    selected["gene"] = 1
}

/^[^#]/ && selected[$3] {
    chromosome=$1
    info=$9
    split(info, infoarr, ";")
    geneid=infoarr[1]
    gsub("ID=", "", geneid)
    gsub("gene:", "", geneid) # in Ensembl GFF.
    start=$4
    end=$5
    print geneid, chromosome, start, end
}
