def print_biogene(gene=None, fh=None, on=None):
    """
    This method accepts a Gene object located on an Assembly object (from things.py) and prints
    the gene in BED format.

    The 4th column of the BED output is to identify the gene.  By default, the locus identifier
    is used but if this isn't present we default to the gene's ID.
    """
    if gene is None:
        raise Exception(
            "ERROR: The print_biogene() function requires a biogene to be passed via the 'gene' argument"
            )
    if on is None:
        on = gene.location().on
    gene_loc = gene.location_on(on)
    locus_tag = gene.id if gene.locus_tag is None else gene.locus_tag
    gene_strand = '+' if gene_loc.strand == 1 else '-'
    for RNA in gene.RNAs():
        fh.write('{0}\t{1}\t{2}\t{3}\t0\t{4}\t'.format(on.id, gene_loc.fmin,
            gene_loc.fmax, locus_tag, gene_strand))
        RNA_loc = RNA.location_on(on)
        if RNA_loc is None:
            raise Exception(
                "ERROR: Expected RNA {0} to be located on {1} but it wasn't"
                .format(RNA.id, on.id))
        exons = sorted(RNA.exons())
        if RNA_loc.strand == -1:
            exons.reverse()
        block_starts = list()
        exon_lengths = list()
        for exon in exons:
            exon_loc = exon.location_on(on)
            block_starts.append(str(exon_loc.fmin - gene_loc.fmin))
            exon_lengths.append(str(exon_loc.fmax - exon_loc.fmin))
        if len(exons):
            thick_start = exons[0].location()
            thick_end = exons[-1].location()
            fh.write('{0}\t{1}\t0\t{2}\t{3},\t{4},\n'.format(thick_start.
                fmin, thick_end.fmax, len(exons), ','.join(exon_lengths),
                ','.join(block_starts)))
        else:
            fh.write('{0}\t{1}\t0\t{2}\t{3},\t0,\n'.format(gene_loc.fmin,
                gene_loc.fmin, 1, gene_loc.fmax - gene_loc.fmin))
