Skip to content

- fixed bug where rBlast temporary files were left inside working dir… - #59

Open
kaozkai wants to merge 2 commits into
mainfrom
patch_rblast_index_file_cleanup
Open

- fixed bug where rBlast temporary files were left inside working dir…#59
kaozkai wants to merge 2 commits into
mainfrom
patch_rblast_index_file_cleanup

Conversation

@kaozkai

@kaozkai kaozkai commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Bug description

When running ClustIRR::clustirr(), multiple database index files (.pdb, .phd, .phi, .phr, .pin, .pog, .pot, .psq, .ptf, .pto) are left behind in the user's current working directory ( getwd() ).

Supposed cause of bug

This is caused by the BLAST calling logic in blast_utils.R using basename(), which causes unlink to fail somehow.

Proposed solution

Create sandbox folders to manage tmp files and on.exit() logic to clean them up.

Summary by CodeRabbit

  • Bug Fixes

    • Improved cleanup of temporary files created during BLAST-based scoring.
    • Prevented temporary artifacts from being left behind after processing.
  • Tests

    • Added coverage to verify temporary files are removed.
    • Updated test data to use the current ClustIRR dataset.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

get_score now stores BLAST intermediates in a dedicated temporary sandbox and removes it on exit. Tests use D1 data and verify that rBLAST temporary files do not remain in the working directory.

Changes

BLAST temporary-file cleanup

Layer / File(s) Summary
Sandboxed BLAST artifacts and cleanup validation
R/blast_utils.R, tests/testthat/test-cdr3_na.R
get_score creates and recursively removes a temporary sandbox for FASTA and BLAST database files. Tests use D1$s input and check for leftover rBLAST-style files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: snaketron

Poem

A bunny tucked the BLAST files away,
In a sandbox snug for the day.
They ran, scored, and hopped,
Then the sandbox was dropped—
No stray little files left to stay.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: fixing rBlast temporary files left in the working directory.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch patch_rblast_index_file_cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@R/blast_utils.R`:
- Around line 57-63: Update get_score_pair() in R/blast_utils.R to create a
per-call sandbox for its FASTA and BLAST database artifacts, register top-level
on.exit() cleanup, and stop writing tmp.fasta or db/tmp in the caller’s working
directory; extend tests/testthat/test-cdr3_na.R at lines 37-40 to run this path
in an isolated working directory and recursively verify no artifacts remain.

In `@tests/testthat/test-cdr3_na.R`:
- Around line 37-40: Update the cleanup assertion in test-cdr3_na.R to execute
within a fresh temporary working directory, isolating it from pre-existing
files, and make list.files scan recursively so nested rBlast artifacts are
detected. Preserve the existing BLAST-extension filter while asserting that no
matching files remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9d348dd-59ec-4990-b8f4-ade6dd40dda5

📥 Commits

Reviewing files that changed from the base of the PR and between a562a19 and 0ec83f1.

📒 Files selected for processing (2)
  • R/blast_utils.R
  • tests/testthat/test-cdr3_na.R

Comment thread R/blast_utils.R
Comment thread tests/testthat/test-cdr3_na.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant