Skip to content
Binary file removed test/evaluate/input/data.pickle
Binary file not shown.
25 changes: 25 additions & 0 deletions test/evaluate/input/input-interactome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
A B 0.98 U
B C 0.77 U
C D 0.77 U
D E 0.77 U
E F 0.77 U
F G 0.12 U
G H 0.89 U
H I 0.59 U
I J 0.50 U
J K 0.76 U
K L 0.92 U
L M 0.66 U
M N 0.66 U
N O 0.66 U
O P 0.66 U
P Q 0.66 U
Q R 0.66 U
R S 0.66 U
S T 0.66 U
T U 0.66 U
U V 0.66 U
V W 0.66 U
W X 0.66 U
X Y 0.66 U
Y Z 0.66 U
27 changes: 27 additions & 0 deletions test/evaluate/input/input-nodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
NODEID prize active dummy sources targets
N
T
I
Z
Q
P
C 5.7 True True
O
W
Y
1S
1L
1B
1D
1V
1K
1M
1H
1U
1R
2X
2J
2E
2F
2G
2A 2.0 True True True
21 changes: 17 additions & 4 deletions test/evaluate/test_evaluate.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import filecmp
import pickle
from pathlib import Path

import pandas as pd

from spras.dataset import Dataset
from spras.evaluation import Evaluation

INPUT_DIR = 'test/evaluate/input/'
Expand All @@ -15,15 +17,26 @@ class TestEvaluate:
@classmethod
def setup_class(cls):
"""
Create the expected output directory
Create the expected output directory and pickled file
"""
Path(OUT_DIR).mkdir(parents=True, exist_ok=True)

dataset = Dataset({
"label": 'data0',
"edge_files": ["input-interactome.txt"],
"node_files": ["input-nodes.txt"],
"data_dir": "test/evaluate/input",
"other_files": []
})

with open("test/evaluate/output/data.pickle", "wb") as handle:
pickle.dump(dataset, handle)

def test_node_ensemble(self):
out_path_file = Path(OUT_DIR + 'node-ensemble.csv')
out_path_file.unlink(missing_ok=True)
ensemble_network = [INPUT_DIR + 'ensemble-network.tsv']
input_network = INPUT_DIR + 'data.pickle'
input_network = OUT_DIR + 'data.pickle'
node_ensemble_dict = Evaluation.edge_frequency_node_ensemble(GS_NODE_TABLE, ensemble_network, input_network)
node_ensemble_dict['ensemble'].to_csv(out_path_file, sep='\t', index=False)
assert filecmp.cmp(out_path_file, EXPECT_DIR + 'expected-node-ensemble.csv', shallow=False)
Expand All @@ -32,7 +45,7 @@ def test_empty_node_ensemble(self):
out_path_file = Path(OUT_DIR + 'empty-node-ensemble.csv')
out_path_file.unlink(missing_ok=True)
empty_ensemble_network = [INPUT_DIR + 'empty-ensemble-network.tsv']
input_network = INPUT_DIR + 'data.pickle'
input_network = OUT_DIR + 'data.pickle'
node_ensemble_dict = Evaluation.edge_frequency_node_ensemble(GS_NODE_TABLE, empty_ensemble_network,
input_network)
node_ensemble_dict['empty'].to_csv(out_path_file, sep='\t', index=False)
Expand All @@ -44,7 +57,7 @@ def test_multiple_node_ensemble(self):
out_path_empty_file = Path(OUT_DIR + 'empty-node-ensemble.csv')
out_path_empty_file.unlink(missing_ok=True)
ensemble_networks = [INPUT_DIR + 'ensemble-network.tsv', INPUT_DIR + 'empty-ensemble-network.tsv']
input_network = INPUT_DIR + 'data.pickle'
input_network = OUT_DIR + 'data.pickle'
node_ensemble_dict = Evaluation.edge_frequency_node_ensemble(GS_NODE_TABLE, ensemble_networks, input_network)
node_ensemble_dict['ensemble'].to_csv(out_path_file, sep='\t', index=False)
assert filecmp.cmp(out_path_file, EXPECT_DIR + 'expected-node-ensemble.csv', shallow=False)
Expand Down
Loading