Skip to content

Commit

Permalink
Made a small change in _parse_BooleanNet_file() to allow the 'filenam…
Browse files Browse the repository at this point in the history
…e' argument to be a string containing the BooleanNet model definition. So, now, a user can pass a string with the model definition or the name of a file with the model definition in it.
  • Loading branch information
lh64 committed Mar 8, 2024
1 parent 5ccb87a commit 0ab8b94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pysb/importers/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from StringIO import StringIO # for Python 2
except ImportError:
from io import StringIO # for Python 3
import os.path


class BooleanTranslationError(Exception):
Expand Down Expand Up @@ -159,7 +160,7 @@ def __init__(self, filename, format='BooleanNet', mode='GSP', force=False):

# minimize the ROBDD paths
orderedNodes = self._findMinPathOrderHeap(self.functions, self.function_nodes)

# create Rules
BDDs = self._grove(self.functions, orderedNodes)
for bdd in BDDs:
Expand All @@ -177,7 +178,9 @@ def _parse_BooleanNet_file(self, filename):
Creates and populates the instance dictionaries ``initial_states``,
``functions``, ``function_nodes``, and ``function_ranks``.
"""
text = open(filename, 'r').read()
text = filename # allow the 'filename' argument to be a string with the Boolean model in it
if os.path.isfile(filename):
text = open(filename, 'r').read()
parser = boolmodel.BoolModel(mode='rank', text=text)
parser.initialize()
# Initial conditions
Expand All @@ -201,7 +204,7 @@ def _parse_BooleanNet_file(self, filename):
self.functions[node].append(token.value)
if token.type == 'ID' and token.value not in self.function_nodes[node]:
self.function_nodes[node].append(token.value)

def _constructTree(self, current_node):
"""
Expands the tree via Shannon expansion and computes values of the leaves
Expand Down

0 comments on commit 0ab8b94

Please sign in to comment.