Skip to content

Commit

Permalink
Merge pull request #1447 from sorgerlab/networkx_dep
Browse files Browse the repository at this point in the history
Networkx 3 compatibility
  • Loading branch information
kkaris authored Jun 8, 2024
2 parents afa7d81 + a59be39 commit b3e9023
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions indra/assemblers/pysb/kappa_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,24 @@ def cm_json_to_networkx(cm_json):
return graph


def get_cm_cycles(cm_graph):
def get_cm_cycles(cm_graph, root_node=None):
"""Return cycles from a model's Kappa contact map graph representation.
Parameters
----------
cm_graph : networkx.Graph
A networkx graph produced by cm_json_to_networkx.
root_node : Optional[str]
The root node of the graph. If None, the root node will be determined
by networkx.cycle_basis.
Returns
-------
list
A list of base cycles found in the contact map graph. Each cycle
is represented as a list of strings of the form Monomer(site).
"""
cycles = cycle_basis(cm_graph)
cycles = cycle_basis(cm_graph, root_node)
processed_cycles = []
for cycle in cycles:
processed_cycle = []
Expand Down
2 changes: 1 addition & 1 deletion indra/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def run_function(self, func_dict, statements=None, **kwargs):
new_kwargs['statements'] = statements
if kwargs:
for k, v in kwargs.items():
if k not in new_kwargs and k in inspect.getargspec(func).args:
if k not in new_kwargs and k in inspect.getfullargspec(func).args:
new_kwargs[k] = v
return self.run_simple_function(func, *new_args, **new_kwargs)

Expand Down
4 changes: 3 additions & 1 deletion indra/tests/test_pysb_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,9 @@ def test_contact_map_cycles_1():
assert len(graph.nodes()) == 9, len(graph.nodes)
assert len(graph.edges()) == 9, len(graph.edges)

cycles = get_cm_cycles(graph)
# Specify the root node to be 0 - corresponding to Agent 'a' - to
# ensure that the order of the output cycles is predictable
cycles = get_cm_cycles(graph, root_node=0)
assert len(cycles) == 1, cycles
assert cycles[0] == ['a(b)', 'b(a)', 'b(c)', 'c(b)', 'c(a)', 'a(c)']

Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def main():
install_list = ['pysb>=1.3.0', 'objectpath',
'requests>=2.11', 'lxml', 'ipython', 'future',
'networkx>=2,<3', 'pandas', 'ndex2==2.0.1', 'jinja2',
'networkx>=3', 'pandas>=2', 'ndex2==2.0.1', 'jinja2',
'protmapper>=0.0.29', 'obonet',
'tqdm', 'pybiopax>=0.0.5']

Expand All @@ -38,7 +38,9 @@ def main():
'api': ['flask<2.0', 'flask_restx<0.4', 'flask_cors',
'docstring-parser', 'gunicorn',
'markupsafe<2.1.0'],
'sklearn_belief': ['scikit-learn'],
# scikit-learn 1.5.0 breaks DisambManager.run_adeft_disambiguation
# see: https://github.com/gyorilab/adeft/issues/80
'sklearn_belief': ['scikit-learn<1.5.0'],
'owl': ['pronto'],
'tests':
['pytest',
Expand Down

0 comments on commit b3e9023

Please sign in to comment.