Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Introduction
mfrpy is a Python package for finding the minimal functional routes of signal transduction networks. The package builds on work done at Pennsylvania State University by Réka Albert, Rui-Sheng Wang, and others. This is part of the *rtmod* pipeline for calculating the modulus of a family of routes. This is done in two parts - first, the graph is expanded by the *update_expand.py* method. Our approach sees expansion mediated by an update table, simplifying computations in lieu of graph-theoretic expansion "by hand". For users interested in expansion, see [1]. Secondly, the minimal functional routes, minimal subgraphs of the expanded graph, are found using *sgmfr.py*, an algorithm adopted into Python from [2]. After computation, the minimal routes are returned in terms of original graph vertices and edges to the user. The following is meant to be an introduction to the package for novel users. For a more thorough explanation, refer to *rtmod tutorial.ipynb*. For more information on signal transduction networks in general, see [3].
mfrpy is a Python package for finding the minimal functional routes of signal transduction networks. The package builds on work done at Pennsylvania State University by Réka Albert, Rui-Sheng Wang, and others. This is part of the *rtmod* pipeline for calculating the modulus of a family of routes.

## Authors
Igor Sokolov, Cory Brunson, Sean Hershkowitz

This is done in two parts - first, the graph is expanded by the *update_expand.py* method. Our approach sees expansion mediated by an update table, simplifying computations in lieu of graph-theoretic expansion "by hand". For users interested in expansion, see [1]. Secondly, the minimal functional routes, minimal subgraphs of the expanded graph, are found using *sgmfr.py*, an algorithm adopted into Python from [2]. After computation, the minimal routes are returned in terms of original graph vertices and edges to the user. The following is meant to be an introduction to the package for novel users. For a more thorough explanation, refer to *rtmod tutorial.ipynb*. For more information on signal transduction networks in general, see [3].

# mfrpy: Package Initialization

Expand Down
26 changes: 22 additions & 4 deletions mfrpy/sgmfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_mfrs(graph, source, target, expanded = False, verbose = False, mode = "e
source -- array of integer indices of source node
target -- integer index of target node
expanded -- if the input graph is already expanded
verbose -- option to diplay MFRs, defaults to False
verbose -- option to display MFRs, defaults to False
mode -- output option, defaults to "es"

Supported output options:
Expand Down Expand Up @@ -186,7 +186,7 @@ def get_mfrs(graph, source, target, expanded = False, verbose = False, mode = "e
final_MFRs.append(mfr)

for mfr in final_MFRs:
# Removes unecessary last row of MFR
# Removes unnecessary last row of MFR
for item in mfr:
if item == [0,[]]:
mfr.remove(item)
Expand Down Expand Up @@ -274,8 +274,26 @@ def get_mfrs(graph, source, target, expanded = False, verbose = False, mode = "e
for mfr in final_MFRs:
id = []
for chunk in mfr:
id.append(oggraph.get_eid(chunk[0], chunk[1]))
id.sort()
# BUG FIX #4: Missing edge handling
# PROBLEM: Original code called oggraph.get_eid(chunk[0], chunk[1]) without
# error handling. If an edge from the MFR doesn't exist in the
# original graph, get_eid() raises an exception, causing the
# entire MFR calculation to crash.
# IMPACT: Program would crash with KeyError or ValueError when processing
# MFRs that contain edges not present in the original graph structure.
# This could happen with expanded graphs where composite nodes create
# edges that don't map back to the original graph.
# SOLUTION: Added try-except block to gracefully handle missing edges by
# skipping them with a warning message, allowing the MFR calculation
# to continue processing other edges.
try:
eid = oggraph.get_eid(chunk[0], chunk[1])
id.append(eid)
except Exception:
# Edge doesn't exist in original graph, skip it
if verbose:
print(f"Warning: Edge ({chunk[0]}, {chunk[1]}) not found in original graph")
id.sort()
ids.append(id)

if verbose:
Expand Down
Loading