Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new valid_algorithms command (#1106) #1108

Merged
merged 11 commits into from
Jun 5, 2024
12 changes: 12 additions & 0 deletions docs/pvacbind/additional_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ List Valid Alleles

.. program-output:: pvacbind valid_alleles -h

.. _valid_algorithms:

List Valid Algorithms
---------------------

.. program-output:: pvacbind valid_algorithms -h

.. .. argparse::
:module: lib.valid_algorithms
:func: define_parser
:prog: pvacbind valid_algorithms

List Allele-Specific Cutoffs
----------------------------

Expand Down
12 changes: 12 additions & 0 deletions docs/pvacfuse/additional_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ List Valid Alleles
:func: define_parser
:prog: pvacfuse valid_alleles

.. _valid_algorithms:

List Valid Algorithms
---------------------

.. program-output:: pvacfuse valid_algorithms -h

.. .. argparse::
:module: lib.valid_algorithms
:func: define_parser
:prog: pvacfuse valid_algorithms

List Allele-Specific Cutoffs
----------------------------

Expand Down
12 changes: 12 additions & 0 deletions docs/pvacseq/additional_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ List Valid Alleles
:func: define_parser
:prog: pvacseq valid_alleles

.. _valid_algorithms:

List Valid Algorithms
---------------------

.. program-output:: pvacseq valid_algorithms -h

.. .. argparse::
:module: lib.valid_algorithms
:func: define_parser
:prog: pvacseq valid_algorithms

List Allele-Specific Cutoffs
----------------------------

Expand Down
12 changes: 12 additions & 0 deletions docs/pvacvector/additional_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ List Valid Alleles
:func: define_parser
:prog: pvacfuse valid_alleles

.. _valid_algorithms:

List Valid Algorithms
---------------------

.. program-output:: pvacvector valid_algorithms -h

.. .. argparse::
:module: lib.valid_algorithms
:func: define_parser
:prog: pvacvector valid_algorithms

List Allele-Specific Cutoffs
----------------------------

Expand Down
1 change: 1 addition & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Release Notes
releases/3_1
releases/4_0
releases/4_1
releases/4_2
19 changes: 19 additions & 0 deletions docs/releases/4_2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Version 4.2
===========

Version 4.2.0
-------------

This is a minor feature release. It adds the following features:

- We added two new modules to pVACview: a :ref:`neofox_module` to visualize
NeoFox neoantigen annotations and a :ref:`custom_module` to visualize
neoantigen data in a TSV file, for example output files from VaxRank,
NeoPredPipe, or antigen.garnish.2.
- We added a :ref:`vignette <pvacseq_vignette>` to our documentation to provide
an extended tutorial on how evaluate neoantigen candidates using pVACview.

This release also fixes the following bug(s):

- When running pVACfuse with Arriba input data, the 3' transcript was not
being parsed correctly. This release fixes this issue.
1 change: 1 addition & 0 deletions pvactools/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"fasta_generator",
"output_parser",
"valid_alleles",
'valid_algorithms',
'net_chop',
"netmhc_stab",
"filter",
Expand Down
58 changes: 58 additions & 0 deletions pvactools/lib/valid_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import sys
import argparse

from pvactools.lib.prediction_class import *

class ValidAlgorithms:
def __init__(self, allele, species):
self.allele = allele
self.species = species

def print_valid_algorithms(self):
if self.allele is None:
valid_algorithms = []
if self.species is None:
valid_algorithms = PredictionClass.prediction_methods()
else:
prediction_algorithms = PredictionClass.prediction_methods()
for algorithm in prediction_algorithms:
cls = globals()[algorithm]
alleles = cls().valid_allele_names()
for allele in alleles:
if cls.species_for_allele(allele) == self.species:
valid_algorithms.append(algorithm)
break
else:
PredictionClass.check_alleles_valid([self.allele])
if (self.species != None and PredictionClass.species_for_allele(self.allele) != self.species):
raise Exception("Given species does not match given allele.")
return
valid_algorithms = []
prediction_algorithms = PredictionClass.prediction_methods()
for algorithm in prediction_algorithms:
cls = globals()[algorithm]
alleles = cls().valid_allele_names()
if (self.allele in alleles) \
and (PredictionClass.species_for_allele(self.allele) == self.species \
or self.species == None):
valid_algorithms.append(algorithm)
print('\n'.join([a for a in valid_algorithms]))

@classmethod
def parser(cls, tool="pvacseq"):
parser = argparse.ArgumentParser(
"%s valid_algorithms" % tool,
description="Show a list of algorithms supported given the specified species and/or allele",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"-a", "--allele",
help="Show valid algorithms for the selected allele. "
+ "For a list of available alleles, use: `{} valid_alleles`.".format(tool),
)
parser.add_argument(
"-s", "--species",
choices=sorted(set(list(PredictionClass.allele_to_species_map().values())), key=str.casefold),
help="Show valid algorithms for the selected species only",
)
return parser
1 change: 1 addition & 0 deletions pvactools/tools/pvacbind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'run',
'binding_filter',
'valid_alleles',
'valid_algorithms',
'allele_specific_cutoffs',
'download_example_data',
'top_score_filter',
Expand Down
7 changes: 7 additions & 0 deletions pvactools/tools/pvacbind/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ def main():
)
valid_alleles_parser.set_defaults(func=valid_alleles)

valid_algorithms_parser = subparsers.add_parser(
"valid_algorithms",
help="Show a list of algorithms supported given the specified species and/or allele",
add_help=False
)
valid_algorithms_parser.set_defaults(func=valid_algorithms)

allele_specific_cutoffs_parser = subparsers.add_parser(
"allele_specific_cutoffs",
help="Show the allele specific cutoffs",
Expand Down
15 changes: 15 additions & 0 deletions pvactools/tools/pvacbind/valid_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from pvactools.lib.valid_algorithms import ValidAlgorithms

def define_parser():
return ValidAlgorithms.parser('pvacbind')

def main(args_input = sys.argv[1:]):
parser = define_parser()
args = parser.parse_args(args_input)

ValidAlgorithms(args.allele, args.species).print_valid_algorithms()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions pvactools/tools/pvacfuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'binding_filter',
'coverage_filter',
'valid_alleles',
'valid_algorithms',
'allele_specific_cutoffs',
'download_example_data',
'top_score_filter',
Expand Down
7 changes: 7 additions & 0 deletions pvactools/tools/pvacfuse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def define_parser():
)
valid_alleles_parser.set_defaults(func=valid_alleles)

valid_algorithms_parser = subparsers.add_parser(
"valid_algorithms",
help="Show a list of algorithms supported given the specified species and/or allele",
add_help=False
)
valid_algorithms_parser.set_defaults(func=valid_algorithms)

identify_problematic_amino_acids_parser = subparsers.add_parser(
"identify_problematic_amino_acids",
help="Mark problematic amino acid positions in each epitope or filter entries that have problematic amino acids.",
Expand Down
15 changes: 15 additions & 0 deletions pvactools/tools/pvacfuse/valid_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from pvactools.lib.valid_algorithms import ValidAlgorithms

def define_parser():
return ValidAlgorithms.parser('pvacfuse')

def main(args_input = sys.argv[1:]):
parser = define_parser()
args = parser.parse_args(args_input)

ValidAlgorithms(args.allele, args.species).print_valid_algorithms()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions pvactools/tools/pvacseq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'run',
'binding_filter',
'valid_alleles',
'valid_algorithms',
'allele_specific_cutoffs',
'download_example_data',
'coverage_filter',
Expand Down
7 changes: 7 additions & 0 deletions pvactools/tools/pvacseq/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def define_parser():
)
valid_alleles_parser.set_defaults(func=valid_alleles)

valid_algorithms_parser = subparsers.add_parser(
"valid_algorithms",
help="Show a list of algorithms supported given the specified species and/or allele",
add_help=False
)
valid_algorithms_parser.set_defaults(func=valid_algorithms)

allele_specific_cutoffs_parser = subparsers.add_parser(
"allele_specific_cutoffs",
help="Show the allele specific cutoffs.",
Expand Down
15 changes: 15 additions & 0 deletions pvactools/tools/pvacseq/valid_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from pvactools.lib.valid_algorithms import ValidAlgorithms

def define_parser():
return ValidAlgorithms.parser('pvacseq')

def main(args_input = sys.argv[1:]):
parser = define_parser()
args = parser.parse_args(args_input)

ValidAlgorithms(args.allele, args.species).print_valid_algorithms()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions pvactools/tools/pvacvector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'run',
'visualize',
'valid_alleles',
'valid_algorithms',
'allele_specific_cutoffs',
'download_example_data',
]
Expand Down
7 changes: 7 additions & 0 deletions pvactools/tools/pvacvector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def define_parser():
)
valid_alleles_parser.set_defaults(func=valid_alleles)

valid_algorithms_parser = subparsers.add_parser(
"valid_algorithms",
help="Show a list of algorithms supported given the specified species and/or allele",
add_help=False
)
valid_algorithms_parser.set_defaults(func=valid_algorithms)

allele_specific_cutoffs_parser = subparsers.add_parser(
"allele_specific_cutoffs",
help="Show the allele specific cutoffs",
Expand Down
15 changes: 15 additions & 0 deletions pvactools/tools/pvacvector/valid_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from pvactools.lib.valid_algorithms import ValidAlgorithms

def define_parser():
return ValidAlgorithms.parser('pvacvector')

def main(args_input = sys.argv[1:]):
parser = define_parser()
args = parser.parse_args(args_input)

ValidAlgorithms(args.allele, args.species).print_valid_algorithms()

if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion pvactools/tools/pvacview/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ RUN R -e "install.packages(c('shiny',\
'shinydashboardPlus', \
'shinycssloaders', \
'fresh', \
'RCurl' ), repos='https://cran.rstudio.com/')"
'RCurl', \
'shinyWidgets', \
'colourpicker'), repos='https://cran.rstudio.com/')"

RUN R -e "devtools::install_github('eclarke/ggbeeswarm', ref='v0.6.1')"

Expand Down
14 changes: 14 additions & 0 deletions tests/test_pvacbind.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_pvacbind_commands(self):
"run",
'binding_filter',
'valid_alleles',
'valid_algorithms',
'allele_specific_cutoffs',
'download_example_data',
"net_chop",
Expand Down Expand Up @@ -363,3 +364,16 @@ def test_pvacbind_combine_and_condense_steps(self):
output_file = os.path.join(output_dir.name, 'combined', file_name)
expected_file = os.path.join(self.test_data_directory, 'combine_and_condense', 'combined', file_name)
self.assertTrue(compare(output_file, expected_file))

def test_valid_algorithms_compiles(self):
compiled_run_path = py_compile.compile(os.path.join(
self.pvactools_directory,
'pvactools',
"tools",
"pvacbind",
"valid_algorithms.py"
))
self.assertTrue(compiled_run_path)

def test_valid_algorithms_runs(self):
valid_algorithms.main("")
14 changes: 14 additions & 0 deletions tests/test_pvacfuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_pvacfuse_commands(self):
"binding_filter",
"coverage_filter",
"valid_alleles",
"valid_algorithms",
"download_example_data",
"net_chop",
"netmhc_stab",
Expand Down Expand Up @@ -205,6 +206,19 @@ def test_valid_alleles_compiles(self):

def test_valid_alleles_runs(self):
valid_alleles.main(["-p", "SMM"])

def test_valid_algorithms_compiles(self):
compiled_run_path = py_compile.compile(os.path.join(
self.pvactools_directory,
'pvactools',
"tools",
"pvacfuse",
"valid_algorithms.py"
))
self.assertTrue(compiled_run_path)

def test_valid_algorithms_runs(self):
valid_algorithms.main("")

def test_pvacfuse_pipeline(self):
with patch('requests.post', unittest.mock.Mock(side_effect = lambda url, data, files=None: make_response(
Expand Down
Loading
Loading