Skip to content

Commit

Permalink
Fix pVACvector logic for deleting tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert committed Jan 30, 2025
1 parent e899319 commit 968eb61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 968eb61

Please sign in to comment.