Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networkx 3 compatibility #1447

Merged
merged 6 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading