Beispiel #1
0
    def test_biom_open_gz(self):
        with biom_open(get_data_path('test.json.gz')) as f:
            self.assertTrue(isinstance(f, gzip.GzipFile))

        with biom_open(get_data_path('test_writing.json.gz'), 'w') as f:
            self.assertTrue(isinstance(f, gzip.GzipFile))

        remove(get_data_path('test_writing.json.gz'))
Beispiel #2
0
    def test_biom_open_hdf5(self):
        with biom_open(get_data_path('test.biom')) as f:
            self.assertTrue(isinstance(f, h5py.File))

        with biom_open(get_data_path('test_writing.biom'), 'w') as f:
            self.assertTrue(isinstance(f, h5py.File))

        remove(get_data_path('test_writing.biom'))
Beispiel #3
0
    def test_biom_open_hdf5(self):
        with biom_open(get_data_path('test.biom')) as f:
            self.assertTrue(isinstance(f, h5py.File))

        with biom_open(get_data_path('test_writing.biom'), 'w') as f:
            self.assertTrue(isinstance(f, h5py.File))

        remove(get_data_path('test_writing.biom'))
Beispiel #4
0
    def test_biom_open_gz(self):
        with biom_open(get_data_path('test.json.gz')) as f:
            self.assertTrue(isinstance(f, gzip.GzipFile))

        with biom_open(get_data_path('test_writing.json.gz'), 'w') as f:
            self.assertTrue(isinstance(f, gzip.GzipFile))

        remove(get_data_path('test_writing.json.gz'))
Beispiel #5
0
    def test_load_classic(self):
        tab = load_table(get_data_path('test.json'))
        with NamedTemporaryFile(mode='w') as fp:
            fp.write(str(tab))
            fp.flush()

            obs = load_table(fp.name)

        npt.assert_equal(obs.ids(), tab.ids())
        npt.assert_equal(obs.ids(axis='observation'),
                         tab.ids(axis='observation'))
        npt.assert_equal(obs.matrix_data.toarray(), tab.matrix_data.toarray())
Beispiel #6
0
 def test_biom_open_json(self):
     with biom_open(get_data_path('test.json')) as f:
         self.assertTrue(isinstance(f, file))
Beispiel #7
0
 def test_is_hdf5_file(self):
     self.assertTrue(is_hdf5_file(get_data_path('test.biom')))
     self.assertFalse(is_hdf5_file(get_data_path('test.json')))
Beispiel #8
0
 def test_load_table_unicode(self):
     t = load_table(get_data_path('bad_table.txt'))
     self.assertEqual(u's__Cortinarius grosmornënsis',
                      t.metadata('otu1', 'observation')['taxonomy'])
Beispiel #9
0
 def test_biom_open_json(self):
     with biom_open(get_data_path('test.json')) as f:
         self.assertTrue(hasattr(f, 'read'))
Beispiel #10
0
 def test_biom_open_hdf5_no_h5py(self):
     with self.assertRaises(RuntimeError):
         with biom_open(get_data_path('test.biom')) as f:
             pass
Beispiel #11
0
 def test_biom_open_empty(self):
     with self.assertRaises(ValueError) as e:
         with biom_open(get_data_path('no-contents.biom'), 'r') as f:
             pass
     self.assertTrue("is empty and can't be parsed" in str(e.exception))
Beispiel #12
0
 def test_is_hdf5_file(self):
     self.assertTrue(is_hdf5_file(get_data_path('test.biom')))
     self.assertFalse(is_hdf5_file(get_data_path('test.json')))
Beispiel #13
0
 def test_biom_open_hdf5_no_h5py(self):
     with self.assertRaises(RuntimeError):
         with biom_open(get_data_path('test.biom')) as f:
             pass
Beispiel #14
0
 def test_biom_open_json(self):
     with biom_open(get_data_path("test.json")) as f:
         self.assertTrue(hasattr(f, "read"))
Beispiel #15
0
 def test_biom_open_empty(self):
     with self.assertRaises(ValueError) as e:
         with biom_open(get_data_path("no-contents.biom"), "r") as f:
             pass
     self.assertTrue("is empty and can't be parsed" in str(e.exception))
Beispiel #16
0
 def test_biom_open_json(self):
     with biom_open(get_data_path('test.json')) as f:
         self.assertTrue(isinstance(f, file))