Graph — mdpath.src.graph
This module contains the class GraphBuilder which generates a graph of residues within a certain distance of each other. Graph edges are assigned weights based on mutual information differences. Paths between distant residues are calculated based on the shortest path with the highest total weight.
Classes
GraphBuilder
- class mdpath.src.graph.GraphBuilder(pdb: str, last_residue: int, mi_diff_df: DataFrame, graphdist: int)[source]
Bases:
objectBuild and analyze residue interaction graphs based on residue distances and mutual information between residue pais.
- Attributes:
pdb (str): Path to the PDB file.
end (int): The last residue number to consider in the graph.
mi_diff_df (pd.DataFrame): DataFrame containing mutual information differences between residue pairs.
dist (int): Cutoff distance for graph edges in Angstroms.
graph (nx.Graph): The constructed residue interaction graph.
- collect_path_total_weights(df_distant_residues: DataFrame) list[source]
Wrapper function to collect the shortest path and total weight between distant residues.
- Args:
residue_graph (nx.Graph): Residue graph.
df_distant_residues (pd.DataFrame): Panda dataframe with distant residues.
- Returns:
path_total_weights (list): List of tuples with the shortest path and total weight between distant residues.
- graph_assign_weights(residue_graph: Graph) Graph[source]
Assignes edge weights to the graph based on mutual information between the residue pair.
- Args:
residue_graph (nx.Graph): Base residue graph (graph skeleton).
- Returns:
residue_graph (nx.Graph): Residue graph with edge weights assigned.
- graph_builder() Graph[source]
Wrapper function to build the residue graph.
- Returns:
residue_graph (nx.Graph): Full residue graph with edge weights assigned.
- graph_skeleton() Graph[source]
Generates a graph of residues with edges for residues within in a given distance of each other.
- Returns:
residue_graph (nx.Graph): Graph of residues within a certain distance of each other.
- max_weight_shortest_path(source: int, target: int) Tuple[source]
Finds the shortest path between 2 nodes with the highest total weight among all shortest paths.
- Args:
source (int): Starting node.
target (int): Target node.
- Returns:
best_path (List): List of nodes in the shortest path with the highest weight.
total_weight (float): Total weight of the shortest path.