Skip to content

Commit

Permalink
Handle negative self-reg and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Feb 21, 2024
1 parent 883dac4 commit 14219bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mira/sources/sif.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ def template_model_from_sif_edges(edges):
controllers=[source_concept, target_concept],
outcome=target_concept)
elif rel == 'NEGATIVE':
t = ControlledDegradation(
controller=source_concept,
subject=target_concept)
if source == target:
t = NaturalDegradation(subject=source_concept)
else:
t = ControlledDegradation(
controller=source_concept,
subject=target_concept)
templates.append(t)
tm = TemplateModel(templates=templates)
return tm
Expand Down
16 changes: 16 additions & 0 deletions tests/test_sif.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from mira.sources.sif import template_model_from_sif_edges
from mira.modeling.amr.regnet import template_model_to_regnet_json


def test_sif_processing():
# Lotka volterra example
edges = [
('prey', 'POSITIVE', 'predator'),
('predator', 'NEGATIVE', 'prey'),
('prey', 'POSITIVE', 'prey'),
('predator', 'NEGATIVE', 'predator')
]
tm = template_model_from_sif_edges(edges)
assert len(tm.templates) == 4
regnet = template_model_to_regnet_json(tm)
assert len(regnet['model']['edges']) == 2

0 comments on commit 14219bc

Please sign in to comment.