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)
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)
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
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)
def test_invalid_data_path_raises_IOError(): checker = CheckRunner(CONFIG) _ = checker.run('foo/bar/baz')
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)
def test_single_apical_no_soma(): checker = CheckRunner(CONFIG) summ = checker.run(NRN_PATH_5) nt.assert_equal(summ, REF_5)
def test_zero_length_sections_neuron(): checker = CheckRunner(CONFIG) summ = checker.run(NRN_PATH_1) nt.assert_equal(summ, REF_1)
def test_single_axon_neuron(): checker = CheckRunner(CONFIG) summ = checker.run(NRN_PATH_4) nt.assert_equal(summ, REF_4)
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"))
def test_ok_neuron_color(): checker = CheckRunner(CONFIG_COLOR) summ = checker.run(NRN_PATH_0) nt.assert_equal(summ, REF_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']
def test_directory_input(): checker = CheckRunner(CONFIG) summ = checker.run(SWC_PATH)