1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/usr/bin/env python
# -----------------------------------------------------------------------------
# Copyright (c) 2011-2017, The BIOM Format Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------
from unittest import TestCase, main
import os
import biom
from biom.cli.table_normalizer import _normalize_table
from biom.exception import UnknownAxisError
class TableNormalizerTests(TestCase):
def setUp(self):
"""initialize objects for use in tests"""
self.cmd = _normalize_table
cwd = os.getcwd()
if '/' in __file__:
os.chdir(__file__.rsplit('/', 1)[0])
self.table = biom.load_table('test_data/test.json')
os.chdir(cwd)
def test_bad_inputs(self):
# relative_abund and pa
with self.assertRaises(ValueError):
self.cmd(self.table, relative_abund=True,
presence_absence=True, axis="sample")
# no normalization type
with self.assertRaises(ValueError):
self.cmd(self.table, relative_abund=False,
presence_absence=False, axis="sample")
# bad axis
with self.assertRaises(UnknownAxisError):
self.cmd(self.table, relative_abund=True,
axis="nonsense")
if __name__ == "__main__":
main()
|