Skip to content

Commit b0e1d14

Browse files
authored
Merge pull request #200 from BlueBrain/apical_and_yaml
new option for no apical + str for yaml
2 parents 3b20798 + 02136a8 commit b0e1d14

File tree

9 files changed

+39
-23
lines changed

9 files changed

+39
-23
lines changed

bluepymm/prepare_combos/parse_files.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def read_mm_recipe_yaml(recipe_filename):
128128
mecombos = pandas.DataFrame(columns=["layer", "fullmtype", "etype"])
129129
for region in recipe['neurons']:
130130
for etype in region['traits']['etype'].keys():
131-
n_combos = len(mecombos)
132-
mecombos.loc[n_combos, 'layer'] = region['traits']['layer']
133-
mecombos.loc[n_combos, 'fullmtype'] = region['traits']['mtype']
134-
mecombos.loc[n_combos, 'etype'] = etype
131+
end = len(mecombos)
132+
mecombos.loc[end, 'layer'] = str(region['traits']['layer'])
133+
mecombos.loc[end, 'fullmtype'] = str(region['traits']['mtype'])
134+
mecombos.loc[end, 'etype'] = str(etype)
135135
return mecombos
136136

137137

bluepymm/prepare_combos/prepare_emodel_dirs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,4 @@ def prepare_emodel_dirs(
305305
for emodel_dir_dict in pool.map(prepare_emodel_dir, arg_list, chunksize=1):
306306
for emodel, emodel_dir in emodel_dir_dict.items():
307307
emodel_dirs[emodel] = emodel_dir
308-
309308
return emodel_dirs

bluepymm/run_combos/calculate_scores.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def run_emodel_morph(
139139
if hasattr(setup, 'multieval'):
140140

141141
prefix = 'mm'
142-
143142
altmorph = [[prefix, morph_path, apical_point_isec]]
144143
evaluator = setup.evaluator.create(etype='%s' % emodel,
145144
altmorph=altmorph)
@@ -193,7 +192,7 @@ def run_emodel_morph(
193192

194193

195194
def create_arg_list(scores_db_filename, emodel_dirs, final_dict,
196-
extra_values_error=False):
195+
extra_values_error=False, use_apical_points=True):
197196
"""Create list of argument tuples to be used as an input for
198197
run_emodel_morph.
199198
@@ -203,6 +202,7 @@ def create_arg_list(scores_db_filename, emodel_dirs, final_dict,
203202
input files
204203
final_dict: a dict mapping e-models to dicts with e-model parameters
205204
extra_values_error: boolean to raise an exception upon a missing key
205+
use_apical_points: boolean to use apical points or not
206206
207207
Raises:
208208
ValueError, if one of the database entries contains has value None for
@@ -217,7 +217,7 @@ def create_arg_list(scores_db_filename, emodel_dirs, final_dict,
217217

218218
apical_points_isec = {}
219219
setup = tools.load_module('setup', emodel_dirs[one_row['emodel']])
220-
if hasattr(setup, 'multieval'):
220+
if hasattr(setup, 'multieval') and use_apical_points:
221221
apical_points_isec = tools.load_json(
222222
os.path.join(one_row['morph_dir'], "apical_points_isec.json")
223223
)
@@ -320,7 +320,8 @@ def expand_scores_to_score_values_table(scores_sqlite_filename):
320320

321321

322322
def calculate_scores(final_dict, emodel_dirs, scores_db_filename,
323-
use_ipyp=False, ipyp_profile=None, timeout=10):
323+
use_ipyp=False, ipyp_profile=None, timeout=10,
324+
use_apical_points=True):
324325
"""Calculate scores of e-model morphology combinations and update the
325326
database accordingly.
326327
@@ -333,10 +334,14 @@ def calculate_scores(final_dict, emodel_dirs, scores_db_filename,
333334
use_ipyp: bool indicating whether ipyparallel is used. Default is
334335
False.
335336
ipyp_profile: path to ipyparallel profile. Default is None.
337+
use_apical_points: boolean to use apical points or not
336338
"""
337339

338340
print('Creating argument list for parallelisation')
339-
arg_list = create_arg_list(scores_db_filename, emodel_dirs, final_dict)
341+
arg_list = create_arg_list(scores_db_filename,
342+
emodel_dirs,
343+
final_dict,
344+
use_apical_points=use_apical_points)
340345

341346
print('Parallelising score evaluation of %d me-combos' % len(arg_list))
342347

bluepymm/run_combos/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ def run_combos_from_conf(conf_dict, ipyp=None, ipyp_profile=None, timeout=10):
5656
'emodel_dirs.json'))
5757
scores_db_path = os.path.abspath(conf_dict['scores_db'])
5858

59+
if 'use_apical_points' in conf_dict:
60+
use_apical_points = conf_dict['use_apical_points']
61+
else:
62+
use_apical_points = True
63+
5964
print('Calculating scores')
6065
calculate_scores.calculate_scores(
6166
final_dict,
6267
emodel_dirs,
6368
scores_db_path,
6469
use_ipyp=ipyp,
6570
ipyp_profile=ipyp_profile,
66-
timeout=timeout)
71+
timeout=timeout,
72+
use_apical_points=use_apical_points)
6773

6874

6975
def run_combos(conf_filename, ipyp=None, ipyp_profile=None):

bluepymm/tests/test_calculate_scores.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,12 @@ def test_calculate_scores():
379379
time.sleep(10)
380380

381381
with tools.cd(TEST_DIR):
382-
run_combos.calculate_scores.calculate_scores(final_dict,
383-
emodel_dirs,
384-
test_db_filename,
385-
use_ipyp=use_ipyp
386-
)
382+
run_combos.calculate_scores.calculate_scores(
383+
final_dict,
384+
emodel_dirs,
385+
test_db_filename,
386+
use_ipyp=use_ipyp
387+
)
387388

388389
if use_ipyp:
389390
ip_proc.terminate()

bluepymm/tests/test_parse_files.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ def test_read_mm_recipe_yaml():
158158
recipe_filename = os.path.join(
159159
BASE_DIR,
160160
'examples/simple1/data/simple1_recipe.yaml')
161-
expected_records = [(1, "mtype1", "etype1"),
162-
(1, "mtype1", "etype2"),
163-
(1, "mtype2", "etype1"),
164-
(2, "mtype1", "etype2"), ]
161+
expected_records = [("1", "mtype1", "etype1"),
162+
("1", "mtype1", "etype2"),
163+
("1", "mtype2", "etype1"),
164+
("2", "mtype1", "etype2"), ]
165165
expected_df = pandas.DataFrame(expected_records,
166166
columns=["layer", "fullmtype", "etype"],
167167
)

bluepymm/tests/test_run_combos.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ def test_run_combos():
5454

5555
# verify output
5656
_verify_run_combos_output(config['scores_db'])
57+
58+
# with use_apical_points
59+
config['use_apical_points'] = False
60+
run_combos.main.run_combos_from_conf(config)
61+
_verify_run_combos_output(config['scores_db'])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
name="bluepymm",
2828
version=versioneer.get_version(),
2929
cmdclass=versioneer.get_cmdclass(),
30-
install_requires=['sh', 'bluepyopt', 'matplotlib', 'pandas', 'numpy',
30+
install_requires=['sh', 'bluepyopt', 'matplotlib', 'pandas', 'numpy', 'NEURON',
3131
'ipyparallel', 'lxml', 'h5py', 'pyyaml'],
3232
packages=setuptools.find_packages(exclude=('notebook',)),
3333
author="BlueBrain Project, EPFL",

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ setenv =
2121
PYTHONPATH={env:TOX_NRNDIR}/local/lib/python:{env:TOX_NRNDIR}/local/lib64/python
2222
commands =
2323
make clean
24-
./.install_neuron.sh {env:TOX_NRNDIR}/src {env:TOX_NRNDIR}/local {basepython}
24+
; ./.install_neuron.sh {env:TOX_NRNDIR}/src {env:TOX_NRNDIR}/local {basepython}
2525

26-
make toxbinlinks
26+
; make toxbinlinks
2727

2828
make simple1_git
2929
style: pycodestyle --ignore=E402,W503,W504 bluepymm

0 commit comments

Comments
 (0)