Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert committed Sep 26, 2023
2 parents c78667b + 2d2c7df commit 60dcec2
Show file tree
Hide file tree
Showing 7 changed files with 2,836 additions and 2,818 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# The short X.Y version.
version = '4.0'
# The full version, including alpha/beta/rc tags.
release = '4.0.4'
release = '4.0.5'


# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
11 changes: 9 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ New in Release |release|

This is a bugfix release. It fixes the following problem(s):

- This release makes various fixes to allow pVACtools to run with non-human
data.
- In recent releases, users have noticed that at some point during pipeline
runs, predictions to MHCflurry would hang or get killed. We were able to
determine that the cause was related to
`PR 988 <https://github.com/griffithlab/pVACtools/pull/988>`_.
This PR originally updated calls to MHCflurry to happen by instantiating
their predictor within Python instead of calling it on the command line.
However, we suspect that this causes a substantial increase in memory usage
resulting in the observed behavior. This release reverts the change from PR
988.

New in Version |version|
------------------------
Expand Down
15 changes: 15 additions & 0 deletions docs/releases/4_0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,18 @@ This is a bugfix release. It fixes the following problem(s):

- This release makes various fixes to allow pVACtools to run with non-human
data.

New in Version 4.0.5
--------------------

This is a bugfix release. It fixes the following problem(s):

- In recent releases, users have noticed that at some point during pipeline
runs, predictions to MHCflurry would hang or get killed. We were able to
determine that the cause was related to
`PR 988 <https://github.com/griffithlab/pVACtools/pull/988>`_.
This PR originally updated calls to MHCflurry to happen by instantiating
their predictor within Python instead of calling it on the command line.
However, we suspect that this causes a substantial increase in memory usage
resulting in the observed behavior. This release reverts the change from PR
988.
46 changes: 21 additions & 25 deletions pvactools/lib/prediction_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
from Bio import SeqIO
import random
import uuid
from mhcflurry.downloads import get_default_class1_presentation_models_dir
from mhcflurry.class1_presentation_predictor import Class1PresentationPredictor
import numpy

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

class IEDB(metaclass=ABCMeta):
@classmethod
Expand Down Expand Up @@ -323,28 +318,29 @@ def predict(self, input_file, allele, epitope_length, iedb_executable_path, iedb

all_epitopes = list(set(all_epitopes))
if len(all_epitopes) > 0:
models_dir = get_default_class1_presentation_models_dir(test_exists=True)
predictor = Class1PresentationPredictor.load(models_dir)
df = predictor.predict(
peptides=numpy.array(all_epitopes, dtype='object'),
n_flanks=None,
c_flanks=None,
alleles={allele: [allele]},
throw=True,
include_affinity_percentile=True,
verbose=0
)
tmp_output_file = tempfile.NamedTemporaryFile('r', dir=tmp_dir, delete=False)
arguments = ["mhcflurry-predict", "--alleles", allele, "--out", tmp_output_file.name, "--peptides"]
arguments.extend(all_epitopes)
stderr_fh = tempfile.NamedTemporaryFile('w', dir=tmp_dir, delete=False)
try:
response = run(arguments, check=True, stdout=DEVNULL, stderr=stderr_fh)
except:
stderr_fh.close()
with open(stderr_fh.name, 'r') as fh:
err = fh.read()
os.unlink(stderr_fh.name)
raise Exception("An error occurred while calling MHCflurry:\n{}".format(err))
stderr_fh.close()
os.unlink(stderr_fh.name)
tmp_output_file.close()
df = pd.read_csv(tmp_output_file.name)
os.unlink(tmp_output_file.name)
df.rename(columns={
'prediction': 'ic50',
'affinity': 'ic50',
'prediction_percentile': 'percentile',
'affinity_percentile': 'percentile',
'processing_score': 'mhcflurry_processing_score',
'presentation_score': 'mhcflurry_presentation_score',
'presentation_percentile': 'mhcflurry_presentation_percentile',
'best_allele': 'allele',
'mhcflurry_prediction': 'ic50',
'mhcflurry_affinity': 'ic50',
'mhcflurry_prediction_percentile': 'percentile',
'mhcflurry_affinity_percentile': 'percentile'
}, inplace=True)
df.drop(labels='peptide_num', axis=1, inplace=True)
for record in SeqIO.parse(input_file, "fasta"):
seq_num = record.id
peptide = str(record.seq)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

setup(
name="pvactools",
version="4.0.4",
version="4.0.5",
packages=[
"pvactools.tools",
"pvactools.tools.pvacbind",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_call_iedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def test_mhcflurry_method_generates_expected_files(self):
])
if sys.platform == 'darwin':
expected_output_file = os.path.join(self.test_data_dir, 'output_mhcflurry_osx.tsv')
expected_df = pd.read_csv(expected_output_file, sep="\t", index_col=[0,8,9])
actual_df = pd.read_csv(call_iedb_output_file.name, sep="\t", index_col=[0,8,9])
expected_df = pd.read_csv(expected_output_file, sep="\t", index_col=[1,7,8])
actual_df = pd.read_csv(call_iedb_output_file.name, sep="\t", index_col=[1,7,8])
pd.testing.assert_frame_equal(expected_df, actual_df, check_like=True, check_exact=False, rtol=0.05)

def test_mhcnuggetsi_method_generates_expected_files(self):
Expand Down
Loading

0 comments on commit 60dcec2

Please sign in to comment.