biocore/biom-format — pull request #310 by teravest (2014-04-24 22:23:58+00:00)
Title: convert tests/bench/tables to hdf5

This was done using

for i in `find ./ -iname '*biom.gz' `; do python ~/Downloads/convert_to_hdf5.py $i; done
for i in `find ./ -iname '*bench.biom.gz' `; do python ~/Downloads/compare_hdf5.py $i; done

convert_to_hdf5.py
```python
from __future__ import division

from sys import argv
from biom.parse import parse_biom_table
import h5py
from biom.util import biom_open

def main():
input_path = argv[1]
biom_path = input_path[0:-8] + '_hdf5.biom.gz'
with biom_open(input_path) as t_jsonf:
t_json = parse_biom_table(t_jsonf)
f = h5py.File(biom_path, 'w')
t_json.to_hdf5(f, input_path, compress=True)
f.attrs['type'] = 'otu table'
f.close()

if __name__ == "__main__":
main()
```
compare_hdf5.py
```python
from __future__ import division

from sys import argv
from biom.parse import parse_biom_table
import h5py
from biom.util import biom_open

def main():
input_path = argv[1]
input_path = argv[1]
biom_path = input_path[0:-8] + '_hdf5.biom.gz'
with biom_open(input_path) as t_jsonf:
with biom_open(biom_path) as t_hdf5f:
t_json = parse_biom_table(t_jsonf)
t_hdf5 = parse_biom_table(t_hdf5f)

print input_path, t_hdf5 == t_json

if __name__ == "__main__":
main()
```