Skip to content

Commit

Permalink
removed need for specifying pvactools or immuno release
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhtnp committed Jan 24, 2025
1 parent c26c31a commit 1de1b2e
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions pvaccompare/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compare_tools import *
import argparse
import logging
import os

logging.basicConfig(level=logging.DEBUG, format="%(message)s")

Expand Down Expand Up @@ -148,21 +149,29 @@ def define_parser():
help=f"Comma-separated columns to include in the reference match TSV comparison, choices: {', '.join(valid_reference_match_columns)}",
)

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--immuno_release",
action="store_true",
help="Use this flag if you are comparing results from immuno releases.",
)
group.add_argument(
"--pvactools_release",
action="store_true",
help="Use this flag if you are comparing results from pvactools releases.",
)

return parser


def determine_release_type(folder):
"""
Purpose: Determines the release type based on the presence of specific subdirectories
Modifies: Nothing
Returns: String, release type
"""
if os.path.exists(os.path.join(folder, "MHC_Class_I")) or os.path.exists(
os.path.join(folder, "MHC_Class_II")
):
return "immuno_release"
elif os.path.exists(os.path.join(folder, "pVACseq/mhc_i")) or os.path.exists(
os.path.join(folder, "pVACseq/mhc_ii")
):
return "pvactools_release"
else:
raise FileNotFoundError(
f"Could not determine release type for folder: {folder}"
)


def main():
"""
Purpose: Control function for the whole tool, calls run_comparison which calls all of the comparisons
Expand All @@ -176,21 +185,25 @@ def main():
validate_unaggregated_columns(args.unaggregated_columns, parser)
validate_reference_match_columns(args.reference_match_columns, parser)

release_type1 = determine_release_type(args.results_folder1)
release_type2 = determine_release_type(args.results_folder2)

if release_type1 != release_type2:
raise ValueError(
"ERROR: You are trying to compare a pVACtools release with an immuno release"
)

release_type = release_type1

classes_to_run = [args.mhc_class] if args.mhc_class else ["1", "2"]

output_dir = prepare_results_folder(classes_to_run, args.output_dir)

for class_type in classes_to_run:
if args.pvactools_release:
if class_type == "1":
prefix = "MHC_Class_I"
elif class_type == "2":
prefix = "MHC_Class_II"
if release_type == "immuno_release":
prefix = "MHC_Class_I" if class_type == "1" else "MHC_Class_II"
else:
if class_type == "1":
prefix = "pVACseq/mhc_i"
elif class_type == "2":
prefix = "pVACseq/mhc_ii"
prefix = "pVACseq/mhc_i" if class_type == "1" else "pVACseq/mhc_ii"
run_comparison(
class_type,
prefix,
Expand Down

0 comments on commit 1de1b2e

Please sign in to comment.