From 3798872e94bd0f311aeceacdcca8cdf0f2350d3f Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Tue, 19 May 2026 11:19:44 +0100 Subject: [PATCH] prepare_transcripts: build pyfasta index eagerly When `prepare_transcripts` writes `transcripts_sequence.fa` but doesn't build its pyfasta index, downstream RiboCode steps (`RiboCode`, `RiboCode_onestep`) trigger pyfasta's lazy first-read index build, which writes `transcripts_sequence.fa.gdx` and `transcripts_sequence.fa.flat` *next to the FASTA*. That breaks any deployment where the annotation directory is not the consumer's own writable working directory: - read-only `/mnt` or NFS mounts on shared HPC infrastructure - container bind mounts published `:ro` - workflow engines that stage the annotation as a symlink into each consumer task (writes follow the symlink back to the producer; parallel consumers then race) Building the indexes once in the producing call makes the published annotation set complete and removes the lazy-write path. The `GenomeSeq` constructor uses the same `get_chrom` key_fn downstream readers use, so the `.gdx`/`.flat` produced are byte-identical to what pyfasta would otherwise write lazily (verified md5-equal on the nf-core/test-datasets chr20 fixture). Closes #70. --- RiboCode/prepare_transcripts.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RiboCode/prepare_transcripts.py b/RiboCode/prepare_transcripts.py index f44b5fe..4a54631 100644 --- a/RiboCode/prepare_transcripts.py +++ b/RiboCode/prepare_transcripts.py @@ -369,6 +369,9 @@ def processTranscripts(genomeFasta,gtfFile,out_dir): transcript_seq_file.close() transcript_cds_file.close() + sys.stderr.write("\tBuilding the transcripts_sequence.fa pyfasta index\n") + GenomeSeq(os.path.join(out_dir,"transcripts_sequence.fa")) + ## dump the pickle sys.stderr.write("\tSaving the transcripts.pickle\n") with open(pickle_file,"wb") as fout: