Skip to content

Commit

Permalink
added tests for version specification
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhtnp committed Jan 23, 2025
1 parent 3aeb360 commit 7b2897d
Show file tree
Hide file tree
Showing 3 changed files with 6,293 additions and 1 deletion.
58 changes: 57 additions & 1 deletion tests/test_call_iedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mock import patch

import pvactools.lib.call_iedb
from pvactools.lib.prediction_class import PredictionClass, IEDB
from pvactools.lib.prediction_class import PredictionClass, IEDB, NetMHCIIpan, NetMHCIIpanEL, NetMHCIIVersion

from tests.utils import *

Expand Down Expand Up @@ -213,5 +213,61 @@ def test_mhcnuggetsii_method_generates_expected_files(self):
actual_df = pd.read_csv(call_iedb_output_file.name, sep="\t", index_col=[0,2,3])
pd.testing.assert_frame_equal(expected_df, actual_df, check_like=True, check_exact=False)

def test_netmhciipan_method_with_version(self):
temp_dir = tempfile.TemporaryDirectory()
log_dir = tempfile.TemporaryDirectory()

prediction_class = getattr(sys.modules[__name__], "NetMHCIIpan")
prediction_class_object = prediction_class()
NetMHCIIVersion.netmhcii_pan_version = '4.2'

(response_text, output_mode) = prediction_class_object.predict(
self.input_file,
'DRB1*01:01',
12,
None,
'5',
temp_dir.name,
log_dir.name
)

with tempfile.NamedTemporaryFile(mode='w+', delete=False) as output_file:
output_file.write(response_text)
output_file.seek(0)
actual_df = pd.read_csv(output_file.name, sep="\t", index_col=[0, 2, 3])

expected_output_file = os.path.join(self.test_data_dir, 'output_netmhciipan-4.2.tsv')
expected_df = pd.read_csv(expected_output_file, sep="\t", index_col=[0,2,3])

pd.testing.assert_frame_equal(expected_df, actual_df, check_like=True, check_exact=False)

def test_netmhciipan_el_method_with_version(self):
temp_dir = tempfile.TemporaryDirectory()
log_dir = tempfile.TemporaryDirectory()

prediction_class = getattr(sys.modules[__name__], "NetMHCIIpanEL")
prediction_class_object = prediction_class()
NetMHCIIVersion.netmhcii_pan_version = '4.2'

(response_text, output_mode) = prediction_class_object.predict(
self.input_file,
'DRB1*01:01',
12,
None,
'5',
temp_dir.name,
log_dir.name
)

with tempfile.NamedTemporaryFile(mode='w+', delete=False) as output_file:
output_file.write(response_text)
output_file.seek(0)
actual_df = pd.read_csv(output_file.name, sep="\t", index_col=[0, 2, 3])

expected_output_file = os.path.join(self.test_data_dir, 'output_netmhciipan_el-4.2.tsv')
expected_df = pd.read_csv(expected_output_file, sep="\t", index_col=[0,2,3])

pd.testing.assert_frame_equal(expected_df, actual_df, check_like=True, check_exact=False)

if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 7b2897d

Please sign in to comment.