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
6 changes: 3 additions & 3 deletions spras/rwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spras/strwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'

Expand Down
10 changes: 5 additions & 5 deletions test/RWR/input/rwr-bad-network.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions test/RWR/input/rwr-network.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions test/ST_RWR/input/strwr-bad-network.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions test/ST_RWR/input/strwr-network.txt
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions test/generate-inputs/expected/rwr-network-expected.txt
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions test/generate-inputs/expected/strwr-network-expected.txt
Original file line number Diff line number Diff line change
@@ -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
Loading