biocore / biom-format

The Biological Observation Matrix (BIOM) Format Project
http://biom-format.org
Other
89 stars 95 forks source link

Streamline IO methods #897

Closed wasade closed 1 year ago

wasade commented 1 year ago

A user should be able to issue a table.write('path', format='2.1.0'), using an instance of Table. Similarly, a user should be able to issue a Table.read('path'), without specifying the format.

Naively doing this would introduce a circular dependency and the refactor to support it may be expensive. A stepping stone to simplification would be to allow a user to from biom import read; t = read('path') and similarly, from biom import write; write(t, 'path', format=version)

The current read mechanism is slim (biom.load_table). But the write mechanism is awkward:

from biom import biom_open
with biom_open('your_file', 'w') as fp:
    t.to_hdf5(fp, generated_by='foo')

...this necessitates knowing prior to the biom_open call detail about the format to write.