MHCXGraph.core.subgraphs.extract_subgraph

MHCXGraph.core.subgraphs.extract_subgraph(g: Graph, node_list: list[str] | None = None, sequence_positions: list[int] | None = None, chains: list[str] | None = None, residue_types: list[str] | None = None, atom_types: list[str] | None = None, bond_types: list[str] | None = None, centre_point: ndarray | tuple[float, float, float] | None = None, radius: float | None = None, ss_elements: list[str] | None = None, rsa_threshold: float | None = None, asa_threshold: float | None = None, k_hop_central_node: str | None = None, k_hops: int | None = None, k_only: bool | None = None, filter_dataframe: bool = True, update_coords: bool = True, recompute_distmat: bool = False, inverse: bool = False, return_node_list: bool = False) Graph | list[str][source]

Aggregate subgraph selector with a unified API.

Parameters:
  • g (nx.Graph) – Input graph.

  • node_list (list of str, optional) – Explicit nodes to include.

  • sequence_positions (list of int, optional) – Residue numbers to include.

  • chains (list of str, optional) – Chain IDs to include.

  • residue_types (list of str, optional) – Residue names to include.

  • atom_types (list of str, optional) – Atom types to include.

  • bond_types (list of str, optional) – Edge kinds whose incident nodes to include.

  • centre_point (array-like, optional) – Center for point-radius selection.

  • radius (float, optional) – Radius for point-radius selection.

  • ss_elements (list of str, optional) – Secondary structure labels to include.

  • rsa_threshold (float, optional) – Minimum RSA to include.

  • k_hop_central_node (str, optional) – Node ID for k-hop selection.

  • k_hops (int, optional) – Number of hops for k-hop selection.

  • k_only (bool, optional) – If True, include exactly k-hop nodes; else all <= k.

  • filter_dataframe – See extract_subgraph_from_node_list().

  • update_coords – See extract_subgraph_from_node_list().

  • recompute_distmat – See extract_subgraph_from_node_list().

  • inverse – See extract_subgraph_from_node_list().

  • return_node_list – See extract_subgraph_from_node_list().

Returns:

Subgraph or node list.

Return type:

nx.Graph or list of str