Exemplo n.º 1
0
def run_pipeline(args):
    P = SetupAMR(args)
    input_data = P.setup()
    A = RunFinder(input_data)
    amr_data = A.run()
    C = Collate(amr_data)
    collated_data = C.run()
Exemplo n.º 2
0
def test_prefix_string():
    """
    assert True when non-empty string is given
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.prefix = "some_isolate"
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._check_prefix()
Exemplo n.º 3
0
def test_setup_fail():
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch_fail.txt'}"
        amr_obj.prefix = ''
        amr_obj.jobs = 16
        amr_obj.species = ''
        amr_obj.logger = logging.getLogger(__name__)
        T = collections.namedtuple(
            'T', ['run_type', 'input', 'prefix', 'jobs', 'organism'])
        input_data = T('batch', amr_obj.contigs, amr_obj.prefix, amr_obj.jobs,
                       amr_obj.species)
        with pytest.raises(SystemExit):
            amr_obj.setup()
Exemplo n.º 4
0
def test_setup_contigs():
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'contigs.fa'}"
        amr_obj.prefix = 'somename'
        amr_obj.jobs = 16
        amr_obj.species = ''
        amr_obj.identity = ''
        amr_obj.logger = logging.getLogger(__name__)
        T = collections.namedtuple(
            'T',
            ['run_type', 'input', 'prefix', 'jobs', 'organism', 'identity'])
        input_data = T('assembly', amr_obj.contigs, amr_obj.prefix,
                       amr_obj.jobs, amr_obj.species, amr_obj.identity)
        assert amr_obj.setup() == input_data
Exemplo n.º 5
0
def test_check_run_type_wrong_data():
    """
    assert true when error raised because input is wrong shape
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch_fail.txt'}"
        amr_obj.prefix = ''
        amr_obj.logger = logging.getLogger(__name__)
        with pytest.raises(SystemExit):
            amr_obj._get_input_shape()
Exemplo n.º 6
0
def test_prefix_empty():
    """
    assert True when non-empty string is given
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.prefix = ""
        amr_obj.logger = logging.getLogger(__name__)
        with pytest.raises(SystemExit):
            amr_obj._check_prefix()
Exemplo n.º 7
0
def test_check_run_type_single():
    """
    assert true when a contigs file is provided and batch recorded as assembly
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'contigs.fa'}"
        amr_obj.prefix = 'somename'
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._get_input_shape() == 'assembly'
Exemplo n.º 8
0
def test_check_run_type_batch():
    """
    assert true when a tab file is provided with two columns
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch.txt'}"
        amr_obj.prefix = ''
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._get_input_shape() == 'batch'