Skip to content

Commit 47f01d3

Browse files
committed
Add test for PC-query with paths and fix bug
1 parent 4b393e8 commit 47f01d3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pybiopax/paths.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def find_objects(start_obj: BioPaxObject, path_str: str) -> List[BioPaxObject]:
8787
def _get_object_list(val):
8888
if isinstance(val, BioPaxObject):
8989
return [val]
90-
elif isinstance(val, list):
90+
elif isinstance(val, (list, set)):
9191
return [v for v in val if isinstance(v, BioPaxObject)]
9292
else:
9393
return []

pybiopax/tests/test_paths.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from pybiopax.biopax import *
3+
from pybiopax import model_from_pc_query
34
from pybiopax.paths import find_objects, BiopaxClassConstraintError
45

56

@@ -74,3 +75,12 @@ def test_recursive():
7475
objects = find_objects(c2, 'member_physical_entity*')
7576
assert len(objects) == 2, objects
7677
assert set(objects) == {p1, c1}
78+
79+
80+
def test_multi_step():
81+
model = model_from_pc_query('pathsfromto', ['MAP2K1'], ['MAPK1'])
82+
bcr = model.objects['BiochemicalReaction_4f689747397d98089c551022a3ae2d88']
83+
assert len(find_objects(bcr, 'left')) == 1
84+
assert len(find_objects(bcr, 'left/entity_reference')) == 1
85+
objs = find_objects(bcr, 'left/entity_reference/entity_reference_of')
86+
assert len(objs) == 10

0 commit comments

Comments
 (0)