Skip to content

Commit

Permalink
added parse_output tests and still fixing generate inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ntalluri committed Oct 4, 2023
1 parent 57599f7 commit e991e0a
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 15 deletions.
14 changes: 0 additions & 14 deletions test/DOMINO/test_domino.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
TEST_DIR = 'test/DOMINO/'
OUT_FILE_DEFAULT = TEST_DIR+'output/domino-output.txt'
OUT_FILE_OPTIONAL = TEST_DIR+'output/domino-output-thresholds.txt'
OUT_FILE_PARSE = TEST_DIR+'output/domino-parse-output.txt'
OUT_FILE_PARSE_EXP = TEST_DIR+'expected_output/domino-parse-output.txt'


class TestDOMINO:
Expand Down Expand Up @@ -63,18 +61,6 @@ def test_domino_missing_network(self):
active_genes=TEST_DIR+'input/domino-active-genes.txt',
output_file=OUT_FILE_DEFAULT)

def test_domino_parse_output(self):
# Input is the concatenated module_0.html and module_1.html file from
# the DOMINO output of the network dip.sif and the nodes tnfa_active_genes_file.txt
# from https://github.com/Shamir-Lab/DOMINO/tree/master/examples
# Confirms the generated output matches the expected output
out_path = Path(OUT_FILE_PARSE)
out_path.unlink(missing_ok=True)
DOMINO.parse_output(
TEST_DIR+'input/domino-concat-modules.txt',
OUT_FILE_PARSE)
assert filecmp.cmp(OUT_FILE_PARSE, OUT_FILE_PARSE_EXP, shallow=False)

# Only run Singularity test if the binary is available on the system
# spython is only available on Unix, but do not explicitly skip non-Unix platforms
@pytest.mark.skipif(not shutil.which('singularity'), reason='Singularity not found on system')
Expand Down
2 changes: 1 addition & 1 deletion test/GenerateInputs/test_generate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_prepare_inputs_networks(self):
for algo in algorithms:
inputs = runner.get_required_inputs(algo)
runner.merge_input(data0_dataset, test_file)
filename_map = {input_str: os.path.join("test", "PrepareInputs", "output", f"{algo}-{input_str}.txt") for input_str in inputs}
filename_map = {input_str: os.path.join("test", "GenerateInputs", "output", f"{algo}-{input_str}.txt") for input_str in inputs}
runner.prepare_inputs(algo, test_file, filename_map)
exp_file_name = algo_exp_file[algo]
assert filecmp.cmp(OUTDIR +f"{algo}-{exp_file_name}.txt", EXPDIR + f"{algo}-{exp_file_name}-expected.txt")
10 changes: 10 additions & 0 deletions test/ParseOutputs/expected/allpairs-pathway-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
S1 A 1 U
S1 B 1 U
A E 1 U
A F 1 U
E T1 1 U
T1 F 1 U
F T2 1 U
F B 1 U
B S2 1 U
S2 T3 1 U
2 changes: 2 additions & 0 deletions test/ParseOutputs/expected/meo-pathway-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GENEA GENEC 1 U
GENEC GENEB 1 U
2 changes: 2 additions & 0 deletions test/ParseOutputs/expected/mincostflow-pathway-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
B A 1 D
D B 1 D
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A C 1 U
C D 1 U
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
B A 1 U
B C 1 U
17 changes: 17 additions & 0 deletions test/ParseOutputs/expected/pathlinker-pathway-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
S2 T3 1 D
A E 2 D
S1 A 2 D
E T1 2 D
B F 3 D
F T2 3 D
S2 B 3 D
C F 4 D
S2 C 4 D
C G 5 D
G T2 5 D
G T3 6 D
E F 7 D
B C 8 D
F E 11 D
G F 13 D
F A 16 D
10 changes: 10 additions & 0 deletions test/ParseOutputs/input/allpairs-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
S1 A
S1 B
A E
A F
E T1
T1 F
F T2
F B
B S2
S2 T3
File renamed without changes.
3 changes: 3 additions & 0 deletions test/ParseOutputs/input/meo-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Source Type Target Oriented Weight
GENEA pp GENEC true 0.5
GENEC pp GENEB true 0.5
2 changes: 2 additions & 0 deletions test/ParseOutputs/input/mincostflow-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
B A
D B
2 changes: 2 additions & 0 deletions test/ParseOutputs/input/omicsintegrator1-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A pp C
C pp D
3 changes: 3 additions & 0 deletions test/ParseOutputs/input/omicsintegrator2-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
protein1 protein2 cost in_solution
B A 0.52 True
B C 0.73 True
18 changes: 18 additions & 0 deletions test/ParseOutputs/input/pathlinker-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#tail head KSP index path cost
S2 T3 1 5.00000e-01
A E 2 1.25000e-01
S1 A 2 1.25000e-01
E T1 2 1.25000e-01
B F 3 1.25000e-01
F T2 3 1.25000e-01
S2 B 3 1.25000e-01
C F 4 1.25000e-01
S2 C 4 1.25000e-01
C G 5 1.25000e-01
G T2 5 1.25000e-01
G T3 6 1.25000e-01
E F 7 6.25000e-02
B C 8 6.25000e-02
F E 11 6.25000e-02
G F 13 6.25000e-02
F A 16 3.12500e-02
47 changes: 47 additions & 0 deletions test/ParseOutputs/test_parse_outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import filecmp
import os
import shutil
from pathlib import Path

import yaml

from src import runner
from src.domino import DOMINO, post_domino_id_transform, pre_domino_id_transform
INDIR = "test/ParseOutputs/input/"
OUTDIR = "test/ParseOutputs/output/"
EXPDIR = "test/ParseOutputs/expected/"

# for domino
OUT_FILE_PARSE = OUTDIR+'/domino-parse-output.txt'
OUT_FILE_PARSE_EXP = EXPDIR + '/domino-parse-output.txt'

algorithms = ['mincostflow', 'meo', 'omicsintegrator1', "omicsintegrator2", "pathlinker", "allpairs"]
class TestParseOutputs:
def setup_class(cls):
"""
Create the expected output directory
"""
Path(OUTDIR).mkdir(parents=True, exist_ok=True)

def test_parse_outputs(self):

# skip domino
for algo in algorithms:
# inputs = runner.get_required_inputs(algo)
test_file = INDIR + f"{algo}-raw-pathway.txt"
out_file = OUTDIR + f"{algo}-pathway.txt"
print(out_file)
runner.parse_output(algo, test_file, out_file)
assert filecmp.cmp(OUTDIR +f"{algo}-pathway.txt", EXPDIR + f"{algo}-pathway-expected.txt")

def test_domino_parse_output(self):
# Input is the concatenated module_0.html and module_1.html file from
# the DOMINO output of the network dip.sif and the nodes tnfa_active_genes_file.txt
# from https://github.com/Shamir-Lab/DOMINO/tree/master/examples
# Confirms the generated output matches the expected output
out_path = Path(OUT_FILE_PARSE)
out_path.unlink(missing_ok=True)
DOMINO.parse_output(
INDIR+ 'domino-concat-modules.txt',
OUT_FILE_PARSE)
assert filecmp.cmp(OUT_FILE_PARSE, OUT_FILE_PARSE_EXP, shallow=False)

0 comments on commit e991e0a

Please sign in to comment.