Write the BIOM table to a file.
    :type biom_tbl: biom.table.Table
    :param biom_tbl: A BIOM table containing the per-sample OTU counts and metadata
                  to be written out to file.
    :type output_fp str
    :param output_fp: Path to the BIOM-format file that will be written.
    :type fmt: str
    :param fmt: One of: hdf5, json, tsv. The BIOM version the table will be
                output (2.x, 1.0, 'classic').

def write_biom(biom_tbl, output_fp, fmt="hdf5", gzip=False):
    """
    Write the BIOM table to a file.
    :type biom_tbl: biom.table.Table
    :param biom_tbl: A BIOM table containing the per-sample OTU counts and metadata
                  to be written out to file.
    :type output_fp str
    :param output_fp: Path to the BIOM-format file that will be written.
    :type fmt: str
    :param fmt: One of: hdf5, json, tsv. The BIOM version the table will be
                output (2.x, 1.0, 'classic').
    """
    opener = open
    mode = 'w'
    if gzip and fmt != "hdf5":
        if not output_fp.endswith(".gz"):
            output_fp += ".gz"
        opener = gzip_open
        mode = 'wt'

    # HDF5 BIOM files are gzipped by default
    if fmt == "hdf5":
        opener = h5py.File

    gen_str = "PhyloToAST v{} (phylotoast.org)".format(phylotoast.__version__)
    biom_tbl.generated_by = gen_str

    with opener(output_fp, mode) as biom_f:
        if fmt == "json":
            biom_tbl.to_json(biom_tbl.generated_by, direct_io=biom_f)
        elif fmt == "tsv":
            biom_f.write(biom_tbl.to_tsv())
        else:
            biom_tbl.to_hdf5(biom_f, biom_tbl.generated_by)

    return output_fp