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
3 changes: 3 additions & 0 deletions test/evaluate/input/input-nodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODEID prize active dummy sources targets
N
C 5.7 True True
24 changes: 20 additions & 4 deletions test/evaluate/test_evaluate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import filecmp
import pickle
from pathlib import Path

import pandas as pd

import spras.analysis.ml as ml
from spras.dataset import Dataset
from spras.evaluation import Evaluation

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

out_dataset = Path(OUT_DIR, 'data.pickle')
out_dataset.unlink(missing_ok=True)

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

with open(out_dataset, "wb") as f:
pickle.dump(dataset, f)

def test_precision_recall_pca_chosen_pathway(self):
output_file = Path(OUT_DIR + "test-pr-per-pathway-pca-chosen.txt")
output_file.unlink(missing_ok=True)
Expand Down Expand Up @@ -63,7 +79,7 @@ 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 @@ -72,7 +88,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 @@ -84,7 +100,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