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
4 changes: 4 additions & 0 deletions docker-wrappers/MinCostFlow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ docker run -w /data --mount type=bind,source=/${PWD},target=/data reedcompbio/mi
This will run MinCostFlow on the test input files and write the output files to the root of the `spras` repository.

Windows users may need to escape the absolute paths so that `/data` becomes `//data`, etc.

## Versions
- v1: Initial version. Handles undirected edges only.
- v2: Updated to handle both directed and undirected edges.
11 changes: 3 additions & 8 deletions spras/mincostflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generate_inputs(data, filename_map):
edges = convert_undirected_to_directed(edges)

# creates the edges files that contains the head and tail nodes and the weights after them
edges.to_csv(filename_map['edges'], sep='\t', index=False, columns=["Interactor1", "Interactor2", "Weight"],
edges.to_csv(filename_map['edges'], sep='\t', index=False, columns=["Interactor1", "Interactor2", "Weight", "Direction"],
header=False)

@staticmethod
Expand Down Expand Up @@ -112,7 +112,7 @@ def run(sources=None, targets=None, edges=None, output_file=None, flow=None, cap
command.extend(['--capacity', str(capacity)])

# choosing to run in docker or singularity container
container_suffix = "mincostflow"
container_suffix = "mincostflow:v2"

# constructs a docker run call
out = run_container(container_framework,
Expand Down Expand Up @@ -140,9 +140,7 @@ def parse_output(raw_pathway_file, standardized_pathway_file):
"""
Convert a predicted pathway into the universal format

Although the algorithm constructs a directed network, the resulting network is treated as undirected.
This is because the flow within the network doesn't imply causal relationships between nodes.
The primary goal of the algorithm is node identification, not the identification of directional edges.
The algorithm constructs a mixed directional network, the resulting network is treated as mixed directional.

@param raw_pathway_file: pathway file produced by an algorithm's run function
@param standardized_pathway_file: the same pathway written in the universal format
Expand All @@ -151,8 +149,5 @@ def parse_output(raw_pathway_file, standardized_pathway_file):
df = raw_pathway_df(raw_pathway_file, sep='\t', header=None)
if not df.empty:
df = add_rank_column(df)
# TODO update MinCostFlow version to support mixed graphs
# Currently directed edges in the input will be converted to undirected edges in the output
df = reinsert_direction_col_undirected(df)
df.columns = ['Node1', 'Node2', 'Rank', "Direction"]
df.to_csv(standardized_pathway_file, header=True, index=False, sep='\t')
Loading