MHCXGraph.classes.graph

class MHCXGraph.classes.graph.AssociatedGraph(graphs: list[tuple], output_path: str, run_name: str, association_config: dict[str, Any])[source]

Bases: object

Association engine for multiple protein graphs.

This class performs structural association between several residue graphs, computes alignment frames, and generates visualization outputs and structural frames.

graphs

List containing graph tuples generated by preprocessing.

Type:

list[tuple]

output_path

Directory where association outputs are written.

Type:

pathlib.Path

run_name

Identifier for the current association run.

Type:

str

association_config

Configuration dictionary controlling association behavior.

Type:

dict[str, Any]

graphs_data

Processed metadata extracted from the input graphs.

Type:

list[GraphData]

associated_graphs

Resulting association graph structures.

Type:

list or None

align_all_frames()[source]

Align protein structures across all associated graph frames.

The alignment is performed using C-alpha atoms of residues shared across proteins. Frames lacking sufficient common residues are skipped.

Return type:

None

create_pdb_per_protein()[source]

Generate frame structures for each associated graph component.

The method reconstructs residue subsets for each frame and writes them as separate structural models.

Return type:

None

get_dashboard_data(global_proteins: list[str]) dict[source]

Extracts JSON serializable data for the dashboard injection.

class MHCXGraph.classes.graph.Graph(graph_path: str, config: GraphConfig)[source]

Bases: object

Graph representation of a protein structure.

This class loads a structural file (PDB or mmCIF), constructs a residue interaction graph using the configured pipeline, and provides utilities for extracting and exporting filtered subgraphs.

graph_path

Path to the structure file used to construct the graph.

Type:

str

config

Configuration object defining graph construction parameters.

Type:

GraphConfig

graph

Graph representation of the protein structure.

Type:

networkx.Graph

subgraphs

Dictionary storing named subgraphs or node selections.

Type:

dict[str, networkx.Graph | list[str]]

pdb_df

DataFrame containing PDB atom-level information.

Type:

pandas.DataFrame or None

raw_pdb_df

DataFrame containing raw PDB data before filtering.

Type:

pandas.DataFrame or None

dssp_df

DataFrame containing DSSP secondary structure annotations.

Type:

pandas.DataFrame or None

create_subgraph(name: str, node_list: list | None = None, return_node_list: bool = False, **args)[source]

Create and store a subgraph.

A subgraph may be generated either from an explicit list of nodes or by applying filtering arguments passed to the subgraph extraction pipeline.

Parameters:
  • name (str) – Name used to store the subgraph.

  • node_list (list, optional) – Explicit list of node identifiers used to build the subgraph.

  • return_node_list (bool, default=False) – If True, return the node list of the generated subgraph.

  • **args (dict) – Additional keyword arguments forwarded to the subgraph extraction function.

Returns:

nodes – Node identifiers of the generated subgraph if return_node_list is True.

Return type:

list or networkx.classes.reportviews.NodeView, optional

get_subgraph(name: str)[source]

Retrieve a stored subgraph by name.

Parameters:

name (str) – Name of the stored subgraph.

Returns:

subgraph – Requested subgraph or node list if it exists. Returns None if the subgraph is not found.

Return type:

networkx.Graph or list[str] or None

save_filtered_pdb(g: Graph, output_path: str | Path, name: str, use_cif: bool = False)[source]

Save a filtered structural file containing only selected residues.

Parameters:
  • g (networkx.Graph) – Graph containing the subset of residues to export.

  • output_path (str or pathlib.Path) – Directory where the filtered structure file will be written.

  • name (str) – Base filename used when saving the structure.

  • use_cif (bool, default=False) – If True, save the output in mmCIF format. Otherwise, save the structure as a PDB file.

Return type:

None

class MHCXGraph.classes.graph.GraphData[source]

Bases: TypedDict

contact_map: ndarray
graph: Graph
id: int
name: str
pdb_file: str
residue_map: dict
residue_map_all: dict
rsa: ndarray
sorted_nodes: list[str]

Classes

AssociatedGraph(graphs, output_path, ...)

Association engine for multiple protein graphs.

Graph(graph_path, config)

Graph representation of a protein structure.

GraphData