Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvhonorato committed Apr 18, 2024
1 parent fe175aa commit 1dc4367
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 53 deletions.
25 changes: 16 additions & 9 deletions tests/test_consadjust_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import subprocess
from pathlib import Path
import sys
import os

import pytest

from . import GOLDEN_DATA_PATH, WHISCY_PATH
from . import GOLDEN_DATA_PATH
from libwhiscy import PARAM_PATH

env = os.environ.copy()
env["PYTHONPATH"] = str(Path(__file__).parent.parent)

CONSADJUST_BIN = Path(Path(__file__).parent.parent, "bin", "consadjust.py")


@pytest.fixture
Expand All @@ -15,39 +22,39 @@ def cons_file():

@pytest.fixture
def weight_ma_file():
return Path(WHISCY_PATH, "param", "weight_ma.txt")
return Path(PARAM_PATH, "weight_ma.txt")


@pytest.fixture
def ztable_file():
return Path(WHISCY_PATH, "param", "ztable.txt")
return Path(PARAM_PATH, "ztable.txt")


@pytest.fixture
def acons_file():
return Path(GOLDEN_DATA_PATH, "regression_consadjust", "2SNIE.acons")


@pytest.fixture
def consadjust_bin():
return Path(WHISCY_PATH, "bin", "consadjust.py")
# @pytest.fixture
# def consadjust_bin():
# return Path(WHISCY_PATH, "bin", "consadjust.py")


@pytest.mark.regression
@pytest.mark.parametrize(
"scratch_path", ["scratch_regression_consadjust"], indirect=True
)
def test_regression_consadjust2SNIE(
scratch_path, consadjust_bin, cons_file, weight_ma_file, ztable_file, acons_file
scratch_path, cons_file, weight_ma_file, ztable_file, acons_file
):

test_prediction_output = Path(scratch_path, "test.prediction")
cmd_line = f"{sys.executable} {consadjust_bin} {cons_file} {weight_ma_file} {ztable_file} -o {test_prediction_output}"
cmd_line = f"{sys.executable} {CONSADJUST_BIN} {cons_file} {weight_ma_file} {ztable_file} -o {test_prediction_output}"

result = subprocess.run(
cmd_line.split(),
capture_output=True,
env={"PYTHONPATH": WHISCY_PATH},
env=env,
)

assert result.returncode == 0
Expand Down
21 changes: 11 additions & 10 deletions tests/test_parasmooth_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import sys
import subprocess
from pathlib import Path
import os

import pytest

from . import GOLDEN_DATA_PATH, WHISCY_PATH
from . import GOLDEN_DATA_PATH
from libwhiscy import PARAM_PATH

PARASMOOTH_BIN = Path(Path(__file__).parent.parent, "bin", "parasmooth.py")

env = os.environ.copy()
env["PYTHONPATH"] = str(Path(__file__).parent.parent)


@pytest.fixture
Expand All @@ -25,19 +32,14 @@ def rd_file():

@pytest.fixture
def par_file():
return Path(WHISCY_PATH, "param", "parasmooth.par")
return Path(PARAM_PATH, "parasmooth.par")


@pytest.fixture
def prediction_file():
return Path(GOLDEN_DATA_PATH, "regression_parasmooth", "2SNIE.parasmooth")


@pytest.fixture
def parasmooth_bin():
return Path(WHISCY_PATH, "bin", "parasmooth.py")


@pytest.mark.regression
@pytest.mark.parametrize(
"scratch_path", ["scratch_regression_parasmooth"], indirect=True
Expand All @@ -49,16 +51,15 @@ def test_regression_2SNIE(
rd_file,
par_file,
prediction_file,
parasmooth_bin,
):

test_prediction_output = Path(scratch_path, "test.prediction")
cmd_line = f"{sys.executable} {parasmooth_bin} {acons_file} {lcons_file} {rd_file} {par_file} -o {test_prediction_output}"
cmd_line = f"{sys.executable} {PARASMOOTH_BIN} {acons_file} {lcons_file} {rd_file} {par_file} -o {test_prediction_output}"

result = subprocess.run(
cmd_line.split(),
capture_output=True,
env={"PYTHONPATH": WHISCY_PATH},
env=env,
)

assert result.returncode == 0
Expand Down
20 changes: 11 additions & 9 deletions tests/test_residue_distance_regression.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import subprocess
import sys
import os
from pathlib import Path

import pytest

from . import GOLDEN_DATA_PATH, WHISCY_PATH
from . import GOLDEN_DATA_PATH


env = os.environ.copy()
env["PYTHONPATH"] = str(Path(__file__).parent.parent)

RESIDUE_DISTANCE_BIN = Path(Path(__file__).parent.parent, "bin", "residue_distance.py")


@pytest.fixture
Expand All @@ -22,24 +29,19 @@ def rd_file():
return Path(GOLDEN_DATA_PATH, "regression_residue_distance", "1ppe_I.rd")


@pytest.fixture
def rd_bin():
return Path(WHISCY_PATH, "bin", "residue_distance.py")


@pytest.mark.regression
@pytest.mark.parametrize(
"scratch_path", ["scratch_regression_residue_distance"], indirect=True
)
def test_rd_regression_1PPEI(scratch_path, pdb_file, conversion_file, rd_file, rd_bin):
def test_rd_regression_1PPEI(scratch_path, pdb_file, conversion_file, rd_file):

test_prediction_output = Path(scratch_path, "test.prediction")
cmd_line = f"{sys.executable} {rd_bin} {pdb_file} {conversion_file} {test_prediction_output}"
cmd_line = f"{sys.executable} {RESIDUE_DISTANCE_BIN} {pdb_file} {conversion_file} {test_prediction_output}"

result = subprocess.run(
cmd_line.split(),
capture_output=True,
env={"PYTHONPATH": WHISCY_PATH},
env=env,
)

assert result.returncode == 0
Expand Down
23 changes: 11 additions & 12 deletions tests/test_whiscy_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
import os
import shutil
import subprocess
import os
import sys
from pathlib import Path

import pytest

from . import GOLDEN_DATA_PATH, WHISCY_BIN, WHISCY_PATH
from . import GOLDEN_DATA_PATH

env = os.environ.copy()
env["PYTHONPATH"] = str(Path(__file__).parent.parent)

WHISCY_BIN = Path(Path(__file__).parent.parent, "whiscy.py")


@pytest.fixture
Expand Down Expand Up @@ -60,18 +66,12 @@ def prediction_file_3qi0_c():
return Path(GOLDEN_DATA_PATH, "regression_whiscy", "3qi0_C.cons")


@pytest.fixture
def whiscy_bin():
return Path(WHISCY_BIN)


@pytest.mark.regression
@pytest.mark.parametrize(
"scratch_path", ["scratch_regression_whiscy_2snie"], indirect=True
)
def test_regression_2SNIE(
scratch_path,
whiscy_bin,
surface_file_2snie,
conversion_file_2snie,
alignment_file_2snie,
Expand All @@ -80,12 +80,12 @@ def test_regression_2SNIE(
):

test_prediction_output = Path(scratch_path, "test.prediction")
cmd_line = f"{sys.executable} {whiscy_bin} {surface_file_2snie} {conversion_file_2snie} {alignment_file_2snie} {distance_file_2snie} -o {test_prediction_output}"
cmd_line = f"{sys.executable} {WHISCY_BIN} {surface_file_2snie} {conversion_file_2snie} {alignment_file_2snie} {distance_file_2snie} -o {test_prediction_output}"

result = subprocess.run(
cmd_line.split(),
capture_output=True,
env={"PYTHONPATH": WHISCY_PATH},
env=env,
)

assert result.returncode == 0
Expand All @@ -104,16 +104,15 @@ def test_regression_3QI0C(
alignment_file_3qi0_c,
distance_file_3qi0_c,
prediction_file_3qi0_c,
whiscy_bin,
):

test_prediction_output = Path(scratch_path, "test.prediction")
cmd_line = f"{sys.executable} {whiscy_bin} {surface_file_3qi0_c} {conversion_file_3qi0_c} {alignment_file_3qi0_c} {distance_file_3qi0_c} -o {test_prediction_output}"
cmd_line = f"{sys.executable} {WHISCY_BIN} {surface_file_3qi0_c} {conversion_file_3qi0_c} {alignment_file_3qi0_c} {distance_file_3qi0_c} -o {test_prediction_output}"

result = subprocess.run(
cmd_line.split(),
capture_output=True,
env={"PYTHONPATH": WHISCY_PATH},
env=env,
)

assert result.returncode == 0
Expand Down
19 changes: 6 additions & 13 deletions tests/test_whiscy_setup_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import pytest

from . import FREESASA_PATH, GOLDEN_DATA_PATH, MUSCLE_BIN, WHISCY_PATH
from . import GOLDEN_DATA_PATH

env = os.environ.copy()
env["PATH"] += os.pathsep + str(FREESASA_PATH)
env["WHISCY_PATH"] = str(WHISCY_PATH)
env["MUSCLE_BIN"] = str(MUSCLE_BIN)
env["PYTHONPATH"] = str(Path(__file__).parent.parent)

WHISCY_SETUP_BIN = Path(Path(__file__).parent.parent, "whiscy_setup.py")


@pytest.fixture
Expand Down Expand Up @@ -135,11 +135,6 @@ def blast_file_3qi0():
return Path(GOLDEN_DATA_PATH, "regression_whiscy_setup", "3qi0_C_blast.xml")


@pytest.fixture
def whiscy_setup_bin():
return Path(WHISCY_PATH, "whiscy_setup.py")


@pytest.mark.regression
@pytest.mark.parametrize(
"scratch_path", ["scratch_regression_whiscy_setup_1ppe"], indirect=True
Expand All @@ -156,7 +151,6 @@ def test_regression_1PPEI(
rsa_file_1ppe,
surface_file_1ppe,
suract_file_1ppe,
whiscy_setup_bin,
blast_file_1ppe,
):
# All the files produced by the whiscy_setup protocol:
Expand All @@ -177,7 +171,7 @@ def test_regression_1PPEI(
# Put the blast file in the scratch path to skip blasting it via ncbi
shutil.copy(blast_file_1ppe, scratch_path)

cmd_line = f"{sys.executable} {whiscy_setup_bin} 1ppe i"
cmd_line = f"{sys.executable} {WHISCY_SETUP_BIN} 1ppe i"
result = subprocess.run(
cmd_line.split(),
capture_output=True,
Expand Down Expand Up @@ -216,7 +210,6 @@ def test_regression_3QI0(
rsa_file_3qi0,
surface_file_3qi0,
suract_file_3qi0,
whiscy_setup_bin,
blast_file_3qi0,
):

Expand All @@ -234,7 +227,7 @@ def test_regression_3QI0(
# Put the blast file in the scratch path to skip blasting it via ncbi
shutil.copy(blast_file_3qi0, scratch_path)

cmd_line = f"{sys.executable} {whiscy_setup_bin} 3qi0 C"
cmd_line = f"{sys.executable} {WHISCY_SETUP_BIN} 3qi0 C"
result = subprocess.run(
cmd_line.split(),
capture_output=True,
Expand Down

0 comments on commit 1dc4367

Please sign in to comment.