Exemplo n.º 1
0
def main(datapath, config, output):
    """Main function that checks morphologies.

    Args:
        datapath (str|Path): path to a morphology file or folder
        config (str|Path): path to a statistics config file
        output (str|Path): path to output the resulted checks file
    """
    config = get_config(config, EXAMPLE_CONFIG)
    checker = CheckRunner(config)
    summary = checker.run(datapath)
    with open(output, 'w') as json_output:
        json.dump(summary, json_output, indent=4)
Exemplo n.º 2
0
def test__sanitize_config():
    # fails if missing 'checks'
    nt.assert_raises(ConfigError, CheckRunner._sanitize_config, {})

    # creates minimal config
    new_config = CheckRunner._sanitize_config({'checks': {}})
    nt.eq_(new_config, {'checks':
                        {'structural_checks': [],
                         'neuron_checks': [],
                         },
                        'options': {},
                        'color': False,
                        })

    # makes no changes to already filled out config
    new_config = CheckRunner._sanitize_config(CONFIG)
    nt.eq_(CONFIG, new_config)
Exemplo n.º 3
0
def test__sanitize_config():
    # fails if missing 'checks'
    with pytest.raises(ConfigError):
        CheckRunner._sanitize_config({})

    # creates minimal config
    new_config = CheckRunner._sanitize_config({'checks': {}})
    assert new_config == {
        'checks': {
            'neuron_checks': [],
        },
        'options': {},
        'color': False,
    }

    # makes no changes to already filled out config
    new_config = CheckRunner._sanitize_config(CONFIG)
    assert CONFIG == new_config
Exemplo n.º 4
0
def test__sanitize_config():
    # fails if missing 'checks'
    nt.assert_raises(ConfigError, CheckRunner._sanitize_config, {})

    # creates minimal config
    new_config = CheckRunner._sanitize_config({'checks': {}})
    nt.eq_(
        new_config, {
            'checks': {
                'structural_checks': [],
                'neuron_checks': [],
            },
            'options': {},
            'color': False,
        })

    # makes no changes to already filled out config
    new_config = CheckRunner._sanitize_config(CONFIG)
    nt.eq_(CONFIG, new_config)
Exemplo n.º 5
0
def test_invalid_data_path_raises_IOError():
    checker = CheckRunner(CONFIG)
    _ = checker.run('foo/bar/baz')
Exemplo n.º 6
0
def test_directory_input():
    checker = CheckRunner(CONFIG)
    summ = checker.run(SWC_PATH)
    nt.eq_(summ['files'][NRN_PATH_0]['Has axon'], True)
    nt.eq_(summ['files'][NRN_PATH_2]['Has axon'], False)
Exemplo n.º 7
0
def test_single_apical_no_soma():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_5)
    nt.assert_equal(summ, REF_5)
Exemplo n.º 8
0
def test_directory_input():
    checker = CheckRunner(CONFIG)
    summ = checker.run(SWC_PATH)
    nt.eq_(summ['files'][NRN_PATH_0]['Has axon'], True)
    nt.eq_(summ['files'][NRN_PATH_2]['Has axon'], False)
Exemplo n.º 9
0
def test_zero_length_sections_neuron():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_1)
    nt.assert_equal(summ, REF_1)
Exemplo n.º 10
0
def test_single_axon_neuron():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_4)
    nt.assert_equal(summ, REF_4)
Exemplo n.º 11
0
def _run_test(path, ref, config=CONFIG, should_pass=False):
    """Run checkers with the passed "config" on file "path"
    and compare the results to 'ref'"""
    results = CheckRunner(config).run(path)
    assert dict(results['files'][str(path)]) == ref
    assert (results['STATUS'] == ("PASS" if should_pass else "FAIL"))
Exemplo n.º 12
0
def test_ok_neuron_color():
    checker = CheckRunner(CONFIG_COLOR)
    summ = checker.run(NRN_PATH_0)
    nt.assert_equal(summ, REF_0)
Exemplo n.º 13
0
def test_directory_input():
    checker = CheckRunner(CONFIG)
    summ = checker.run(SWC_PATH)
    assert summ['files'][str(SWC_PATH / 'Single_axon.swc')]['Has axon']
    assert not summ['files'][str(SWC_PATH / 'Single_apical.swc')]['Has axon']
Exemplo n.º 14
0
def test_invalid_data_path_raises_IOError():
    checker = CheckRunner(CONFIG)
    _ = checker.run('foo/bar/baz')
Exemplo n.º 15
0
def test_single_apical_no_soma():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_5)
    nt.assert_equal(summ, REF_5)
Exemplo n.º 16
0
def test_single_axon_neuron():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_4)
    nt.assert_equal(summ, REF_4)
Exemplo n.º 17
0
def test_zero_length_sections_neuron():
    checker = CheckRunner(CONFIG)
    summ = checker.run(NRN_PATH_1)
    nt.assert_equal(summ, REF_1)
Exemplo n.º 18
0
def test_ok_neuron_color():
    checker = CheckRunner(CONFIG_COLOR)
    summ = checker.run(NRN_PATH_0)
    nt.assert_equal(summ, REF_0)
Exemplo n.º 19
0
def test_directory_input():
    checker = CheckRunner(CONFIG)
    summ = checker.run(SWC_PATH)