quemb.molbe.graphfrag.GraphGenUtility.get_subgraphs¶
- static GraphGenUtility.get_subgraphs(motifs_per_frag, edge_list, origin_per_frag, adx_map, fdx=None, options={})¶
Construct labeled subgraphs for fragments using motif, edge, and label data.
If a fragment index (fdx) is provided, returns a dictionary containing the subgraph for that single fragment. Otherwise, returns a dictionary of subgraphs for all fragments, keyed by their respective fragment indices (fdx).
- Parameters:
motifs_per_frag (
list
[Sequence
[int
]]) – A list where each item is a sequence of node indices (motifs) per fragment.edge_list (
list
[Sequence
]) – A list of edge groupings, each corresponding to a fragment’s set of edges.origin_per_frag (
list
[Sequence
[int
]]) – A list where each item is a sequence of node indices marking origin nodes within each fragment.adx_map (
dict
) – A mapping from node index to metadata, where each value must contain a “label” field for node annotation.fdx (
int
|None
) – Index of a specific fragment to extract. If None (default), subgraphs for all fragments are returned.options (
dict
) – Optional keyword arguments passed to the nx.Graph constructor for each subgraph.
- Returns:
subgraph_dict – a dictionary mapping fragment indices to networkx.graph objects. If fdx is given, the dictionary will contain only one entry for that fragment.
- Return type:
Notes
Origin nodes are highlighted by enclosing their labels in square brackets.
Returned graphs include labeled nodes and edges per fragment.
The structure and labels are derived from adx_map and origin_per_frag.