gufe.ligandnetwork

Classes

LigandNetwork(edges[, nodes])

A directed graph connecting ligands according to their atom mapping.

class gufe.ligandnetwork.LigandNetwork(edges: Iterable[LigandAtomMapping], nodes: Iterable[SmallMoleculeComponent] | None = None)

A directed graph connecting ligands according to their atom mapping.

A network can be defined by specifying only edges, in which case the nodes are implicitly added.

Parameters:
  • edges (Iterable[LigandAtomMapping]) – Edges for this network, each specified as a LigandAtomMapping between two nodes.

  • nodes (Iterable[SmallMoleculeComponent]) – Nodes for this network. Any nodes already included as a part of the ‘edges’ will be ignored. Nodes not already included in ‘edges’ will be added as isolated, unconnected nodes.

property graph: MultiDiGraph

NetworkX graph for this network.

This graph will have SmallMoleculeComponent objects as nodes and LigandAtomMapping objects as directed edges

property edges: frozenset[LigandAtomMapping]

A read-only view of the edges of this network.

property nodes: frozenset[SmallMoleculeComponent]

A read-only view of the nodes of this network.

to_graphml() str

Return the GraphML string representing this network.

This is the primary serialization mechanism for this class.

Returns:

String representing this network in GraphML format.

Return type:

str

classmethod from_graphml(graphml_str: str) LigandNetwork

Create from a GraphML string.

Parameters:

graphml_str (str) – GraphML string representation of a Network.

Returns:

New network from the GraphML.

Return type:

LigandNetwork

enlarge_graph(*, edges: Iterable[LigandAtomMapping] | None = None, nodes: Iterable[SmallMoleculeComponent] | None = None) LigandNetwork

Create a new network with the given edges and nodes added.

Parameters:
Returns:

A new network adding the given edges and nodes to this network.

Return type:

LigandNetwork

trim_graph(*, edges: Iterable[LigandAtomMapping] | None = None, nodes: Iterable[SmallMoleculeComponent] | None = None) LigandNetwork

Create a new network with the given edges and nodes removed.

Note that for removed nodes, any edges that include them will also be removed.

Parameters:
  • edges (Iterable[LigandAtomMapping]) – Edges to drop from this network.

  • nodes (Iterable[SmallMoleculeComponent]) – Nodes to drop from this network; all edges including these nodes will also be dropped.

Returns:

A new network with the given edges and nodes removed.

Return type:

LigandNetwork

to_rbfe_alchemical_network(solvent: SolventComponent, protein: ProteinComponent, protocol: Protocol, *, autoname: bool = True, autoname_prefix: str = 'easy_rbfe', **other_components) AlchemicalNetwork

Create an AlchemicalNetwork from this LigandNetwork.

Parameters:
  • protocol (Protocol) – The method to apply to edges.

  • autoname (bool) – Whether to automatically name objects by the ligand name and state label.

  • autoname_prefix (str) – Prefix for the autonaming; only used if autonaming is True.

  • other_components – Additional non-alchemical components; keyword will be the string label for the component.

is_connected() bool

Indicates whether all ligands in the network are (directly or indirectly) connected to each other.

A False value indicates that either some nodes have no edges or that there are separate networks that do not link to each other.