Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
balazs1987 committed May 22, 2019
2 parents e7f2932 + 504e7c3 commit 8d00fe5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 15 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_KbGenerator(self):
gen = wc_kb_gen.KbGenerator()

self.assertEqual(gen.component_generators, [])
self.assertEqual(gen.options, {'id': None, 'name': None, 'version': None})
self.assertEqual(gen.options, {'id': None, 'name': None, 'version': None, 'input_kb': None})

def test_ModelGenerator_run(self):
gen = wc_kb_gen.KbGenerator(options={
Expand All @@ -36,6 +36,20 @@ def test_ModelGenerator_run(self):
self.assertEqual(kb.id, 'test_kb')
self.assertEqual(kb.version, '0.0.1')

kb_input = wc_kb.core.KnowledgeBase(id='kb_input')
kb_input.cell = wc_kb.core.Cell(id='kb_input_cell')
gen = wc_kb_gen.KbGenerator(options={
'id': 'test_kb',
'version': '0.0.1',
'input_kb': kb_input,
})
kb = gen.run()

self.assertEqual(kb.id, 'kb_input')
self.assertEqual(kb.version, '')
self.assertEqual(kb.cell.id, 'kb_input_cell')
self.assertTrue(kb.is_equal(kb_input))

def test_ModelGenerator_run_with_components(self):
class TestComponentGenerator1(wc_kb_gen.KbComponentGenerator):
def get_data(self):
Expand Down
15 changes: 12 additions & 3 deletions wc_kb_gen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ class KbGenerator(object):
Options:
* id
* name
* component
* id (:obj:`str`): id
* name (:obj:`str`): name
* version (:obj:`str`): version
* input_kb (:obj:`wc_kb.core.KnowledgeBase`, optional): knowledge base input if
one wants to build upon an existing knowledge base
* component (:obj:`dict`): dictionary of options whose keys are the names
of component generator classes and whose values are dictionaries of options
for the component generator classes
Attributes:
component_generators (:obj:`list` of :obj:`KbComponentGenerator`): component
Expand Down Expand Up @@ -61,6 +66,10 @@ def clean_and_validate_options(self):
assert(isinstance(version, str) or version is None)
options['version'] = version

input_kb = options.get('input_kb', None)
assert(isinstance(input_kb, wc_kb.core.KnowledgeBase) or input_kb is None)
options['input_kb'] = input_kb

def run(self):
""" Generate a knowledge base of experimental data for a whole-cell model
Expand Down

0 comments on commit 8d00fe5

Please sign in to comment.