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

Fix pVACvector logic for deleting tmp files #1186

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pvactools/tools/pvacvector/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ def create_dna_backtranslation(results_file, dna_results_file):
output_record = SeqRecord(Seq(dna_sequence), id=str(seq_num), description=str(seq_num))
SeqIO.write([output_record], dna_results_file, 'fasta')

def delete_tmp_files(keep_tmp_files, base_output_dir, max_clip_length, spacers):
if not keep_tmp_files:
for subdirectory in range(max_clip_length):
for spacer in spacers:
shutil.rmtree(os.path.join(base_output_dir, str(subdirectory), spacer, 'MHC_Class_I'), ignore_errors=True)
shutil.rmtree(os.path.join(base_output_dir, str(subdirectory), spacer, 'MHC_Class_II'), ignore_errors=True)

def main(args_input=sys.argv[1:]):
parser = define_parser()
args = parser.parse_args(args_input)
Expand Down Expand Up @@ -463,13 +470,7 @@ def main(args_input=sys.argv[1:]):

dna_results_file = os.path.join(base_output_dir, args.sample_name + '_results.dna.fa')
create_dna_backtranslation(results_file, dna_results_file)

if not args.keep_tmp_files:
for subdirectory in range(tries):
for spacer in processed_spacers:
shutil.rmtree(os.path.join(base_output_dir, str(subdirectory), spacer, 'MHC_Class_I'), ignore_errors=True)
shutil.rmtree(os.path.join(base_output_dir, str(subdirectory), spacer, 'MHC_Class_II'), ignore_errors=True)

delete_tmp_files(args.keep_tmp_files, base_output_dir, args.max_clip_length, args.spacers)
change_permissions_recursive(base_output_dir, 0o755, 0o644)
return

Expand Down Expand Up @@ -528,6 +529,7 @@ def main(args_input=sys.argv[1:]):
'4) increase the number of peptides that can be excluded from the vector (--allow-n-peptide-exclusion parameter)'
)

delete_tmp_files(args.keep_tmp_files, base_output_dir, args.max_clip_length, args.spacers)
change_permissions_recursive(base_output_dir, 0o755, 0o644)

if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion tests/test_pvacvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ def test_prevent_clipping_best_peptide(self):
output_dir.name,
'-e1', self.epitope_length,
'-n', self.input_n_mer,
'-k',
'-b', '22000',
'--spacers', 'None',
])
Expand Down