process TAG_FINDER {

    input:
    path positions
    path families

    output:
    path 'tags.tsv'

    script:
    """
    "${baseDir}/../../rust/tagfinder/target/release/tagfinder" --positions "${positions}" --families "${families}" --definitions 0,1 > 'tags.tsv'
    """
}


process GENE_POSITION_TABLE {

    input:
    path gff3

    output:
    path 'gene_positions.tsv'

    script:
    """
    awk -f "${baseDir}/scripts/gff3_to_gene_positions_table.awk" "${gff3}" > 'gene_positions.tsv'
    """
}


workflow TAGs {

    take:
    families
    gff3

    main:
    GENE_POSITION_TABLE(gff3)
    TAG_FINDER(GENE_POSITION_TABLE.out, families)

    emit:
    TAG_FINDER.out
}
