Skip to content

Commit

Permalink
Merge pull request #218 from OpenFreeEnergy/issue_217_ligand_network_…
Browse files Browse the repository at this point in the history
…no_edges

Issue 217 ligand network no edges
  • Loading branch information
IAlibay authored Aug 11, 2023
2 parents fdcfe3b + f362f34 commit 2a54c3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gufe/ligandnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# For details, see https://github.com/OpenFreeEnergy/gufe
from __future__ import annotations

from itertools import chain
import json
import networkx as nx
from typing import FrozenSet, Iterable, Optional
Expand Down Expand Up @@ -30,7 +31,8 @@ def __init__(
nodes = []

self._edges = frozenset(edges)
edge_nodes = set.union(*[{edge.componentA, edge.componentB} for edge in edges])
edge_nodes = set(chain.from_iterable((e.componentA, e.componentB)
for e in edges))
self._nodes = frozenset(edge_nodes) | frozenset(nodes)
self._graph = None

Expand Down
8 changes: 8 additions & 0 deletions gufe/tests/test_ligand_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,11 @@ def test_is_connected(self, simple_network):

def test_is_not_connected(self, singleton_node_network):
assert not singleton_node_network.network.is_connected()


def test_empty_ligand_network(mols):
# issue #217
n = LigandNetwork(edges=[], nodes=[mols[0]])

assert len(n.edges) == 0
assert len(n.nodes) == 1

0 comments on commit 2a54c3f

Please sign in to comment.