How do I export my biom object to a file in biom format? I'm using the python API for the biom-format package. I read in two files in biom format and merged them, like so:

In [1]: import biom

In [2]: a = biom.load_table('./table-a.biom')

In [3]: b = biom.load_table('./table-b.biom')

In [4]: a
Out[4]: 51116 x 46 &lt;class 'biom.table.Table'&gt; with 185077 nonzero entries (7% dense)

In [5]: b
Out[5]: 37479 x 26 &lt;class 'biom.table.Table'&gt; with 100124 nonzero entries (10% dense)

In [6]: c = a.merge(b)

In [7]: c
Out[7]: 67022 x 47 &lt;class 'biom.table.Table'&gt; with 254555 nonzero entries (8% dense)


How do I now export this biom object (c) as a biom file? There are a few methods available, eg, .to_tsv(), but I don't see a way to save this object in biom format.
You can use the functions to_hdf5 and to_json from the biom-format package:

to_hdf5

with biom.util.biom_open('output.biom', 'w') as f:
    merged_table.to_hdf5(f, "example")


to_json

with open('output.txt', 'w') as f:
    f.write(merged_table.to_json("example"))