From 8ed26ccf561e323dba0899c35effb87d56e350fa Mon Sep 17 00:00:00 2001 From: Pablo Riesgo Ferreiro Date: Thu, 27 Oct 2022 07:17:38 +0200 Subject: [PATCH 1/3] update sphinx dependencies to fix documentation build --- docs/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index c48a7928..dc359cb9 100755 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,9 +2,9 @@ Sphinx==4.2.0 m2r2==0.3.1 nbsphinx==0.8.7 pandoc==1.1.0 -ipython==8.0.1 -ipykernel==5.3.4 +ipython==7.27.0 +ipykernel==6.4.1 #sphinx_rtd_theme==0.5.0 #insipid_sphinx_theme==0.2.1 pydata-sphinx-theme==0.7.1 -Jinja2==3.0.3 +Jinja2==3.0.1 From 8bb86659765ce360a5bda2c0450d8a3cb551e507 Mon Sep 17 00:00:00 2001 From: Pablo Riesgo Ferreiro Date: Thu, 27 Oct 2022 07:24:46 +0200 Subject: [PATCH 2/3] update sphinx dependencies to fix documentation build... second try --- docs/requirements.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index dc359cb9..67342ba7 100755 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,10 +1,11 @@ -Sphinx==4.2.0 -m2r2==0.3.1 -nbsphinx==0.8.7 -pandoc==1.1.0 +Sphinx==5.3.0 +m2r2==0.3.3 +nbsphinx==0.8.9 +pandoc==2.2 ipython==7.27.0 ipykernel==6.4.1 #sphinx_rtd_theme==0.5.0 #insipid_sphinx_theme==0.2.1 -pydata-sphinx-theme==0.7.1 -Jinja2==3.0.1 +pydata-sphinx-theme==0.11.0 +Jinja2==3.1.2 +markupsafe==2.1.1 \ No newline at end of file From 907bf12eb08b839622af7c8555ca6193931ac2dc Mon Sep 17 00:00:00 2001 From: Pablo Riesgo Ferreiro Date: Thu, 27 Oct 2022 07:44:29 +0200 Subject: [PATCH 3/3] avoids writing neoepitope table if missing epitopes of one MHC --- neofox/__init__.py | 2 +- neofox/command_line.py | 41 +++++++------ .../integration_tests/test_neofox_epitope.py | 61 ++++++++++++++++++- 3 files changed, 83 insertions(+), 21 deletions(-) diff --git a/neofox/__init__.py b/neofox/__init__.py index 4898d33d..f3d27234 100755 --- a/neofox/__init__.py +++ b/neofox/__init__.py @@ -18,7 +18,7 @@ # along with this program. If not, see .# -VERSION = "1.0.0" +VERSION = "1.0.1" REFERENCE_FOLDER_ENV = "NEOFOX_REFERENCE_FOLDER" diff --git a/neofox/command_line.py b/neofox/command_line.py index d2728306..cd84df4a 100755 --- a/neofox/command_line.py +++ b/neofox/command_line.py @@ -406,23 +406,26 @@ def _write_results_epitopes(neoepitopes: List[PredictedEpitope], output_folder, mhci_neoepitopes = [n for n in neoepitopes if ModelValidator.is_mhci_epitope(n)] mhcii_neoepitopes = [n for n in neoepitopes if ModelValidator.is_mhcii_epitope(n)] - ModelConverter.annotated_neoepitopes2epitopes_table(mhci_neoepitopes, mhc=neofox.MHC_I).to_csv( - os.path.join( - output_folder, - "{}_mhcI_epitope_candidates_annotated.tsv".format(output_prefix), - ), - sep="\t", - index=False, - ) - ModelConverter.annotated_neoepitopes2epitopes_table(mhcii_neoepitopes, mhc=neofox.MHC_II).to_csv( - os.path.join( - output_folder, - "{}_mhcII_epitope_candidates_annotated.tsv".format(output_prefix), - ), - sep="\t", - index=False, - ) + if mhci_neoepitopes: + ModelConverter.annotated_neoepitopes2epitopes_table(mhci_neoepitopes, mhc=neofox.MHC_I).to_csv( + os.path.join( + output_folder, + "{}_mhcI_epitope_candidates_annotated.tsv".format(output_prefix), + ), + sep="\t", + index=False, + ) + if mhcii_neoepitopes: + ModelConverter.annotated_neoepitopes2epitopes_table(mhcii_neoepitopes, mhc=neofox.MHC_II).to_csv( + os.path.join( + output_folder, + "{}_mhcII_epitope_candidates_annotated.tsv".format(output_prefix), + ), + sep="\t", + index=False, + ) - output_features = os.path.join(output_folder, "{}_neoepitope_candidates_annotated.json".format(output_prefix)) - with open(output_features, "wb") as f: - f.write(json.dumps(ModelConverter.objects2json(neoepitopes))) + if neoepitopes: + output_features = os.path.join(output_folder, "{}_neoepitope_candidates_annotated.json".format(output_prefix)) + with open(output_features, "wb") as f: + f.write(json.dumps(ModelConverter.objects2json(neoepitopes))) diff --git a/neofox/tests/integration_tests/test_neofox_epitope.py b/neofox/tests/integration_tests/test_neofox_epitope.py index 7bb11e30..2316c3d5 100755 --- a/neofox/tests/integration_tests/test_neofox_epitope.py +++ b/neofox/tests/integration_tests/test_neofox_epitope.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see .# import os -import unittest import pkg_resources import neofox.tests from neofox.command_line import _write_results_epitopes @@ -145,6 +144,66 @@ def test_neofox_epitope_writing_output_table(self): self.assertTrue(os.path.exists(pkg_resources.resource_filename( neofox.tests.__name__, "resources/test_neoepitopes_mhcII_epitope_candidates_annotated.tsv"))) + def test_neofox_epitope_writing_output_table_only_mhci(self): + + neoepitopes = [ + PredictedEpitope( + mutated_peptide="DEVLGEPSQDILVTDQTR", + wild_type_peptide="DEVLGEPSQDILVIDQTR", + isoform_mhc_i_i=self._get_test_mhcii_isoform("HLA-DRB1*01:01") + ), + PredictedEpitope( + mutated_peptide="DEVLGEPSQTILVTDQTR", + wild_type_peptide="DEVLGEPSQDILVIDQTR", + isoform_mhc_i_i=self._get_test_mhcii_isoform("HLA-DRB1*01:01") + ), + ] + + annotated_neoepitopes = NeoFoxEpitope( + neoepitopes=neoepitopes, + num_cpus=4, + ).get_annotations() + + _write_results_epitopes( + annotated_neoepitopes, + output_folder=pkg_resources.resource_filename(neofox.tests.__name__, "resources"), + output_prefix="test_neoepitopes_only_mhcii") + + self.assertFalse(os.path.exists(pkg_resources.resource_filename( + neofox.tests.__name__, "resources/test_neoepitopes_only_mhcii_mhcI_epitope_candidates_annotated.tsv"))) + self.assertTrue(os.path.exists(pkg_resources.resource_filename( + neofox.tests.__name__, "resources/test_neoepitopes_only_mhcii_mhcII_epitope_candidates_annotated.tsv"))) + + def test_neofox_epitope_writing_output_table_only_mhcii(self): + + neoepitopes = [ + PredictedEpitope( + mutated_peptide="DILVTDQTR", + wild_type_peptide="DILVIDQTR", + allele_mhc_i=self._get_test_mhci_allele('HLA-A*01:01'), + ), + PredictedEpitope( + mutated_peptide="DILVPDQTR", + wild_type_peptide="DILVIDQTR", + allele_mhc_i=self._get_test_mhci_allele('HLA-A*01:01'), + ), + ] + + annotated_neoepitopes = NeoFoxEpitope( + neoepitopes=neoepitopes, + num_cpus=4, + ).get_annotations() + + _write_results_epitopes( + annotated_neoepitopes, + output_folder=pkg_resources.resource_filename(neofox.tests.__name__, "resources"), + output_prefix="test_neoepitopes_only_mhci") + + self.assertTrue(os.path.exists(pkg_resources.resource_filename( + neofox.tests.__name__, "resources/test_neoepitopes_only_mhci_mhcI_epitope_candidates_annotated.tsv"))) + self.assertFalse(os.path.exists(pkg_resources.resource_filename( + neofox.tests.__name__, "resources/test_neoepitopes_only_mhci_mhcII_epitope_candidates_annotated.tsv"))) + def test_neofox_epitope_writing_output_table_with_patients(self): neoepitopes = [