diff --git a/spras/rwr.py b/spras/rwr.py index e7691f160..49bc89ba3 100644 --- a/spras/rwr.py +++ b/spras/rwr.py @@ -35,7 +35,7 @@ def generate_inputs(data, filename_map): edges = data.get_interactome() edges = convert_undirected_to_directed(edges) - edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1','Interactor2'],header=False) + edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1', 'Interactor2', 'Weight'],header=False) @staticmethod def run(network=None, nodes=None, alpha=None, output_file=None, container_settings=None, threshold=None): @@ -47,8 +47,8 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_settin for line in network_f: line = line.strip() endpoints = line.split("|") - if len(endpoints) != 2: - raise ValueError(f"Edge {line} does not contain 2 nodes separated by '|'") + if len(endpoints) != 3: + raise ValueError(f"Edge {line} does not contain 2 nodes and 1 weight separated by '|'") work_dir = '/spras' # Each volume is a tuple (src, dest) diff --git a/spras/strwr.py b/spras/strwr.py index c99b39830..b44af5cee 100644 --- a/spras/strwr.py +++ b/spras/strwr.py @@ -35,7 +35,7 @@ def generate_inputs(data, filename_map): edges = data.get_interactome() edges = convert_undirected_to_directed(edges) - edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1','Interactor2'],header=False) + edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1', 'Interactor2', 'Weight'],header=False) @staticmethod def run(network=None, sources=None, targets=None, alpha=None, output_file=None, container_settings=None, threshold=None): @@ -47,8 +47,8 @@ def run(network=None, sources=None, targets=None, alpha=None, output_file=None, for line in network_f: line = line.strip() endpoints = line.split("|") - if len(endpoints) != 2: - raise ValueError(f"Edge {line} does not contain 2 nodes separated by '|'") + if len(endpoints) != 3: + raise ValueError(f"Edge {line} does not contain 2 nodes and 1 weight separated by '|'") work_dir = '/spras' diff --git a/test/RWR/input/rwr-bad-network.txt b/test/RWR/input/rwr-bad-network.txt index 8f774c46c..f54d26a17 100644 --- a/test/RWR/input/rwr-bad-network.txt +++ b/test/RWR/input/rwr-bad-network.txt @@ -1,5 +1,5 @@ -A|B|F -A|C -B|D -C|B -C|E +A|B|1|F +A|C|1 +B|D|1 +C|B|1 +C|E|1 diff --git a/test/RWR/input/rwr-network.txt b/test/RWR/input/rwr-network.txt index 4b33b37d4..1449f6afe 100644 --- a/test/RWR/input/rwr-network.txt +++ b/test/RWR/input/rwr-network.txt @@ -1,5 +1,5 @@ -A|B -A|C -B|D -C|B -C|E +A|B|1 +A|C|1 +B|D|1 +C|B|1 +C|E|1 diff --git a/test/ST_RWR/input/strwr-bad-network.txt b/test/ST_RWR/input/strwr-bad-network.txt index 8f774c46c..f54d26a17 100644 --- a/test/ST_RWR/input/strwr-bad-network.txt +++ b/test/ST_RWR/input/strwr-bad-network.txt @@ -1,5 +1,5 @@ -A|B|F -A|C -B|D -C|B -C|E +A|B|1|F +A|C|1 +B|D|1 +C|B|1 +C|E|1 diff --git a/test/ST_RWR/input/strwr-network.txt b/test/ST_RWR/input/strwr-network.txt index 4b33b37d4..1449f6afe 100644 --- a/test/ST_RWR/input/strwr-network.txt +++ b/test/ST_RWR/input/strwr-network.txt @@ -1,5 +1,5 @@ -A|B -A|C -B|D -C|B -C|E +A|B|1 +A|C|1 +B|D|1 +C|B|1 +C|E|1 diff --git a/test/generate-inputs/expected/rwr-network-expected.txt b/test/generate-inputs/expected/rwr-network-expected.txt index 721390f8c..fe622dde5 100644 --- a/test/generate-inputs/expected/rwr-network-expected.txt +++ b/test/generate-inputs/expected/rwr-network-expected.txt @@ -1,4 +1,4 @@ -test_A|B -B|C -B|test_A -C|B +test_A|B|0.98 +B|C|0.77 +B|test_A|0.98 +C|B|0.77 diff --git a/test/generate-inputs/expected/strwr-network-expected.txt b/test/generate-inputs/expected/strwr-network-expected.txt index 721390f8c..fe622dde5 100644 --- a/test/generate-inputs/expected/strwr-network-expected.txt +++ b/test/generate-inputs/expected/strwr-network-expected.txt @@ -1,4 +1,4 @@ -test_A|B -B|C -B|test_A -C|B +test_A|B|0.98 +B|C|0.77 +B|test_A|0.98 +C|B|0.77