diff --git a/docker-wrappers/MinCostFlow/README.md b/docker-wrappers/MinCostFlow/README.md index 014a3d75..5d585eea 100644 --- a/docker-wrappers/MinCostFlow/README.md +++ b/docker-wrappers/MinCostFlow/README.md @@ -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. \ No newline at end of file diff --git a/spras/mincostflow.py b/spras/mincostflow.py index b0a47cc7..3b25fdc6 100644 --- a/spras/mincostflow.py +++ b/spras/mincostflow.py @@ -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 @@ -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, @@ -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 @@ -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')