From 7bacaa49035a9a16f400f34aeda6cf10dd0f0cfc Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Mon, 21 Jul 2025 14:42:23 -0700 Subject: [PATCH 01/11] test(evaluate): dynamically serialize data.pickle --- test/evaluate/input/data.pickle | Bin 3171 -> 0 bytes test/evaluate/input/input-interactome.txt | 25 ++++++++++++++++++++ test/evaluate/input/input-nodes.txt | 27 ++++++++++++++++++++++ test/evaluate/test_evaluate.py | 23 ++++++++++++++---- 4 files changed, 70 insertions(+), 5 deletions(-) delete mode 100644 test/evaluate/input/data.pickle create mode 100644 test/evaluate/input/input-interactome.txt create mode 100644 test/evaluate/input/input-nodes.txt diff --git a/test/evaluate/input/data.pickle b/test/evaluate/input/data.pickle deleted file mode 100644 index ad2fee27fb2b27d0f7cf4baa9b040e6d2da459bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3171 zcmeHKO>7%Q6!to{^ViUpwn@`U0SOL)gH;e9eo~yq&hI8p6MkB%Myp+W;BK}+?7%n?+KfM9pdTR=pMoKG15eCh~1B%-3z-uCX8#eAkHA zsGONe?!|`Sz4{5ubDc21^@!lRt=Mn6l`|f*9QlkiKH$go=2GHJJ@z8k4gz}#vswYG zH2g3M;z}e9v&s<5h4ac}Lzt=aqG&kcqL>$hrh!-g1wnmSceK=G@}czNi(-8(`M!-C zL!w+RPyLBYy_u;4A}w>nQ=^TV+1GyC14a71IB>~U=o-D zOkf(A0m{HEa2%Ke=7HCM*MT>HH-QttN#HF(FVibDL`UgWD$p<;qY)}niAHIR#%Y2k zX^KpmrWq>JEFGsgZk!Ux2#20FQ&{p{7Mz@x=aa?AAOClu9cwc)t&Uw3GL{E#&#@|d zmxXx;=`DDd<+HQaq>sj8JXc?`(|dav&qW3CpU9Hcm|c=*4?v$=T0!U zMkpbjB^TKixeZ^%k7s;Y70U4ic~(|=|4!}&wqKL}%}Z|ai7u6K@FF{ike@sgMvbO0 z`{jUPV5m8noS0`Uq$z$}u3@tdS#=iKYEcU~zjhR%!mPkkYtgf7YS?FcUgK{ok?nX)P*+k9sfYILbm9&35X!|9>&5Sr1ira?ul(J&^6DMF zSNjKRml~FZ07+onJqa=@2I{Dcuii}jysyF9eOdn}#t(su|1d89uTY)b?NNM~0;2^Y zZRT19;?9LjB`u_I8p1daF`R%{jzb9NAc`eO=MZGE2(cW7Ku$p(N3@W>v?Y<~m~Qn1 zN{MKd&Ouk`!|jri+me)AdA2k<3CYhk19ur3kV9+fzJo!w8rSP+-rB=P98?%ukah?` zjYVOi%a^t!@0wr&2~z-%@GK zZJINhvzl|7+ckG+?$q3+xm&aD%u_x3{t?Z)HSf{9SM#Hq_i5g*`GDqL&3&2=YVOyp z%DaxGl2ZDZKA}(P3VpUB=yTv|B8IG5+Z4kx?@-bx|1w-gBhZM51=gbLVV4#}?BxFf DA49p9 diff --git a/test/evaluate/input/input-interactome.txt b/test/evaluate/input/input-interactome.txt new file mode 100644 index 000000000..f112dc958 --- /dev/null +++ b/test/evaluate/input/input-interactome.txt @@ -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 diff --git a/test/evaluate/input/input-nodes.txt b/test/evaluate/input/input-nodes.txt new file mode 100644 index 000000000..3878fc521 --- /dev/null +++ b/test/evaluate/input/input-nodes.txt @@ -0,0 +1,27 @@ +NODEID prize active dummy sources targets +N NaN NaN NaN NaN NaN +T NaN NaN NaN NaN NaN +I NaN NaN NaN NaN NaN +Z NaN NaN NaN NaN NaN +Q NaN NaN NaN NaN NaN +P NaN NaN NaN NaN NaN +C 5.7 True NaN NaN True +O NaN NaN NaN NaN NaN +W NaN NaN NaN NaN NaN +Y NaN NaN NaN NaN NaN +1S NaN NaN NaN NaN NaN +1L NaN NaN NaN NaN NaN +1B NaN NaN NaN NaN NaN +1D NaN NaN NaN NaN NaN +1V NaN NaN NaN NaN NaN +1K NaN NaN NaN NaN NaN +1M NaN NaN NaN NaN NaN +1H NaN NaN NaN NaN NaN +1U NaN NaN NaN NaN NaN +1R NaN NaN NaN NaN NaN +2X NaN NaN NaN NaN NaN +2J NaN NaN NaN NaN NaN +2E NaN NaN NaN NaN NaN +2F NaN NaN NaN NaN NaN +2G NaN NaN NaN NaN NaN +2A 2.0 True True True NaN \ No newline at end of file diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 93df61a06..214c50a94 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -1,8 +1,9 @@ import filecmp from pathlib import Path - import pandas as pd +import pickle +from spras.dataset import Dataset from spras.evaluation import Evaluation INPUT_DIR = 'test/evaluate/input/' @@ -15,15 +16,27 @@ 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) @@ -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) @@ -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) From 11cff8b98971150d532b45ebdcb904b0663953e8 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Mon, 21 Jul 2025 21:43:27 +0000 Subject: [PATCH 02/11] style: fmt --- test/evaluate/test_evaluate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 214c50a94..a915c611a 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -1,7 +1,8 @@ import filecmp +import pickle from pathlib import Path + import pandas as pd -import pickle from spras.dataset import Dataset from spras.evaluation import Evaluation @@ -27,10 +28,10 @@ def setup_class(cls): "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') From 69bde87d5fd39bb7f9141d290b3aa93e46e3443f Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Tue, 22 Jul 2025 20:51:59 +0000 Subject: [PATCH 03/11] chore: drop NaN from input-nodes.txt --- test/evaluate/input/input-nodes.txt | 52 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/test/evaluate/input/input-nodes.txt b/test/evaluate/input/input-nodes.txt index 3878fc521..3a340d635 100644 --- a/test/evaluate/input/input-nodes.txt +++ b/test/evaluate/input/input-nodes.txt @@ -1,27 +1,27 @@ NODEID prize active dummy sources targets -N NaN NaN NaN NaN NaN -T NaN NaN NaN NaN NaN -I NaN NaN NaN NaN NaN -Z NaN NaN NaN NaN NaN -Q NaN NaN NaN NaN NaN -P NaN NaN NaN NaN NaN -C 5.7 True NaN NaN True -O NaN NaN NaN NaN NaN -W NaN NaN NaN NaN NaN -Y NaN NaN NaN NaN NaN -1S NaN NaN NaN NaN NaN -1L NaN NaN NaN NaN NaN -1B NaN NaN NaN NaN NaN -1D NaN NaN NaN NaN NaN -1V NaN NaN NaN NaN NaN -1K NaN NaN NaN NaN NaN -1M NaN NaN NaN NaN NaN -1H NaN NaN NaN NaN NaN -1U NaN NaN NaN NaN NaN -1R NaN NaN NaN NaN NaN -2X NaN NaN NaN NaN NaN -2J NaN NaN NaN NaN NaN -2E NaN NaN NaN NaN NaN -2F NaN NaN NaN NaN NaN -2G NaN NaN NaN NaN NaN -2A 2.0 True True True NaN \ No newline at end of file +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 \ No newline at end of file From cd06b5f0bc3b53ddac255e4fe831267370cb9a62 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Tue, 22 Jul 2025 20:52:19 +0000 Subject: [PATCH 04/11] style: mt --- test/evaluate/test_evaluate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index a915c611a..9d4b39eea 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -32,7 +32,6 @@ def setup_class(cls): 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) From 7e675d14e19abf009dde57e092794bfe2ba10ee4 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 08:59:58 -0700 Subject: [PATCH 05/11] style: use constants and naming convention Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 9d4b39eea..b6783faac 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -29,7 +29,7 @@ def setup_class(cls): "other_files": [] }) - with open("test/evaluate/output/data.pickle", "wb") as handle: + with open(out_dataset, "wb") as f: pickle.dump(dataset, handle) def test_node_ensemble(self): From f63b7441348e404b3b61501fd13cc18f19b2783b Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 09:00:05 -0700 Subject: [PATCH 06/11] style: use naming convention Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index b6783faac..6dfc5352d 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -30,7 +30,7 @@ def setup_class(cls): }) with open(out_dataset, "wb") as f: - pickle.dump(dataset, handle) + pickle.dump(dataset, f) def test_node_ensemble(self): out_path_file = Path(OUT_DIR + 'node-ensemble.csv') From 23a77beb13028e93b405fd317e2113209424e6ca Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 09:00:21 -0700 Subject: [PATCH 07/11] docs: clarify what pickled file is Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 6dfc5352d..49d845434 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -17,7 +17,7 @@ class TestEvaluate: @classmethod def setup_class(cls): """ - Create the expected output directory and pickled file + Create the expected output directory and pickled toy dataset file """ Path(OUT_DIR).mkdir(parents=True, exist_ok=True) From 40614b201ed1cd137a2b6969671ac85140b69a72 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 09:00:36 -0700 Subject: [PATCH 08/11] docs: clarify dataset usecase Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 49d845434..1968207cf 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -22,7 +22,7 @@ def setup_class(cls): Path(OUT_DIR).mkdir(parents=True, exist_ok=True) dataset = Dataset({ - "label": 'data0', + "label": 'toy', "edge_files": ["input-interactome.txt"], "node_files": ["input-nodes.txt"], "data_dir": "test/evaluate/input", From 397dc00de21df979dbe4f320c18b04f9321ac278 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 09:00:50 -0700 Subject: [PATCH 09/11] style: use constant (thanks for this!!) Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 1968207cf..198bb9fb8 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -25,7 +25,7 @@ def setup_class(cls): "label": 'toy', "edge_files": ["input-interactome.txt"], "node_files": ["input-nodes.txt"], - "data_dir": "test/evaluate/input", + "data_dir": INPUT_DIR, "other_files": [] }) From f169d55c306c917117b6aa919d78d0b6035b69c6 Mon Sep 17 00:00:00 2001 From: "Tristan F." Date: Wed, 23 Jul 2025 09:16:29 -0700 Subject: [PATCH 10/11] apply suggestions Co-Authored-By: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/input/input-nodes.txt | 26 +------------------------- test/evaluate/test_evaluate.py | 5 ++++- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/test/evaluate/input/input-nodes.txt b/test/evaluate/input/input-nodes.txt index 3a340d635..1ffd8bdff 100644 --- a/test/evaluate/input/input-nodes.txt +++ b/test/evaluate/input/input-nodes.txt @@ -1,27 +1,3 @@ NODEID prize active dummy sources targets -N -T -I -Z -Q -P +N 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 \ No newline at end of file diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index 198bb9fb8..c75d4e64a 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -21,10 +21,13 @@ def setup_class(cls): """ 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"], + "node_files": [], "data_dir": INPUT_DIR, "other_files": [] }) From 8bdbe39129dc6685d0be5bdbcf0e35ac5e116925 Mon Sep 17 00:00:00 2001 From: "Tristan F.-R." Date: Wed, 23 Jul 2025 09:54:43 -0700 Subject: [PATCH 11/11] re-add file Co-authored-by: Neha Talluri <78840540+ntalluri@users.noreply.github.com> --- test/evaluate/test_evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/evaluate/test_evaluate.py b/test/evaluate/test_evaluate.py index b94dc3091..4ad4d5f7b 100644 --- a/test/evaluate/test_evaluate.py +++ b/test/evaluate/test_evaluate.py @@ -29,7 +29,7 @@ def setup_class(cls): dataset = Dataset({ "label": 'toy', "edge_files": ["input-interactome.txt"], - "node_files": [], + "node_files": ["input-nodes.txt"], "data_dir": INPUT_DIR, "other_files": [] })