Skip to content

Cut run inode/disk footprint: build only the selected search DB, temp() blast intermediates - #129

Draft
conchoecia wants to merge 1 commit into
mainfrom
inode-reduction-main
Draft

Cut run inode/disk footprint: build only the selected search DB, temp() blast intermediates#129
conchoecia wants to merge 1 commit into
mainfrom
inode-reduction-main

Conversation

@conchoecia

Copy link
Copy Markdown
Owner

Problem

A macrosynteny run accumulates a very large number of files. On a ~5,800-genome focal run the output tree reached ~354k inodes / ~300 GB. Two structural issues, neither intrinsic to the analysis:

  1. A full BLAST database is built for every genome even when diamond_or_blastp: "diamond". make_diamond_and_blast_db ran both diamond makedb and makeblastdb unconditionally, so ~8 BLAST index files/genome (.pdb/.phr/.pin/.pjs/.pot/.psq/.ptf/.pto, ~46.5k inodes) were written and never read in diamond mode. diamond_blast even listed .phr/.pin/.psq as ancient inputs, forcing them into the DAG.
  2. Per-pair intermediates are never temp(). diamond_blast .blastp (~177 GB), reciprocal_best_hits *_recip.temp.blastp (named "temp" but persisted), n_ways_reciprocal_best _acceptable_prots.txt/_edges.txt (read by nothing downstream), and get_chromsize_of_analysis_pair analyses/*.chromsize (a per-pair cat) all lived forever.

Changes (scripts/odp)

  • Split make_diamond_and_blast_db into make_diamond_db and make_blast_db; diamond_blast now depends (via an input function) only on the DB its method reads. Because Snakemake is pull-based, the unneeded builder never runs — no BLAST index files in diamond mode, no .dmnd in blastp mode. make_blast_db declares every index file with multiext() so none leak untracked.
  • temp() on the true intermediates listed above. Finals — step1-rbh/*.rbh and *.D.FET.rbh, step1-rbh-filtered/*, and all step2-figures/ outputs (incl. the .plotted.rbh sidecars consumed downstream) — are untouched.

Validation

  • Parses under snakemake 9.14.5; dry-run of tests/test_odp_basic: diamond mode → make_diamond_db only (no make_blast_db), blastp mode → make_blast_db only.
  • Under snakemake 8.30.0, confirmed temp() removes the intermediate after its consumer runs.

Rerun safety

Deploying a Snakefile edit would, under Snakemake's default --rerun-triggers (which include code/params), mark every output of the changed rules out of date and — with temp() — recompute completed work. Runs must pass --rerun-triggers mtime (verified: with it, an edited rule + existing outputs reports "Nothing to be done"). Reused .pep.gz/DB inputs keep their ancient() markers so DB rebuilds don't cascade.

Draft pending a full end-to-end run in a cluster module environment (DIAMOND/BLAST+/HMMER) confirming db/ has no BLAST index files and step0-blastp_results/*.blastp is gone post-run while finals remain.

Two changes to scripts/odp that sharply cut the inode/disk footprint of a run
without altering any final result:

1. Build only the database the chosen search method reads. make_diamond_and_blast_db
   always ran both `diamond makedb` and `makeblastdb`, so a diamond run (the default)
   emitted ~8 BLAST index files per genome that are never read (~46k inodes in a
   ~5.8k-genome run). Split into make_diamond_db and make_blast_db, and make
   diamond_blast depend (via an input function) only on the DB its method uses.
   Snakemake is pull-based, so the unneeded builder never runs. make_blast_db now
   declares all index files via multiext() so none leak untracked.

2. Mark true intermediates temp() so Snakemake removes them once their consumer
   finishes: diamond_blast .blastp (177 GB / ~35k files in the reference run),
   reciprocal_best_hits *_recip.temp.blastp (was misnamed "temp" but persisted),
   n_ways_reciprocal_best _acceptable_prots.txt/_edges.txt (dead byproducts), and
   get_chromsize_of_analysis_pair analyses/*.chromsize (a cheap per-pair cat).
   The step1-rbh/*.rbh and *.D.FET.rbh, filtered rbh, and figures remain untouched.

Runs should pass `--rerun-triggers mtime` so that deploying this edit does not
mark existing outputs out of date via the code/params provenance triggers.
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