Skip to content

Commit f2e9c04

Browse files
committed
marker reprogramming: extract relevant sub-network beforhand
1 parent 4b05330 commit f2e9c04

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bonesis/reprogramming.py

+17
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,23 @@
2929
# knowledge of the CeCILL license and that you accept its terms.
3030
#
3131

32+
33+
from colomoto import minibn
34+
35+
import networkx as nx
36+
from functools import reduce
37+
3238
import bonesis
3339

40+
def prune_domain_for_marker(f, M):
41+
def get_doi(g):
42+
return reduce(set.union, (nx.ancestors(g, m) for m in M), set(M))
43+
if isinstance(f, minibn.BooleanNetwork):
44+
keep = get_doi(f.influence_graph())
45+
return f.__class__({i: f[i] for i in keep})
46+
else:
47+
return f.subgraph(get_doi(f))
48+
3449
def marker_reprogramming_fixpoints(f, M, k, at_least_one=True, **some_opts):
3550
bo = bonesis.BoNesis(f)
3651
control = bo.Some(max_size=k, **some_opts)
@@ -57,6 +72,7 @@ def trapspace_reprogramming(f, M, k, algorithm="cegar", **some_opts):
5772
Returns mutations which ensure that all the minimal trap spaces match with
5873
the given marker `M`.
5974
"""
75+
f = prune_domain_for_marker(f, M)
6076
if algorithm == "cegar":
6177
meth = _trapspace_reprogramming_cegar
6278
else:
@@ -75,6 +91,7 @@ def _trapspace_reprogramming_complementary(f, M, k, **some_opts):
7591
return bad_control.complementary_assignments()
7692

7793
def source_marker_reprogramming(f, z, M, k, **some_opts):
94+
f = prune_domain_for_marker(f, M)
7895
bo = bonesis.BoNesis(f)
7996
bad_control = bo.Some(max_size=k, **some_opts)
8097
with bo.mutant(bad_control):

0 commit comments

Comments
 (0)