Moshpit: Megahit co-assembly File Not Found Error

Hello,

I have version 2025.4.0 of moshpit. I’m working with metagenomic data and wanting to co-assemble my reads into contigs, but I encountered an error after running the assemble-megahit action with the coassemble option.

It looks like contig assembly finished, but I get a File Not Found Error. Here is a part of the log:

...
2026-03-25 08:25:59 - Build graph for k = 141 
2026-03-25 08:26:08 - Assemble contigs from SdBG for k = 141
2026-03-25 08:27:19 - Merging to output final contigs 
2026-03-25 08:27:19 - 130616 contigs, total 97707540 bp, min 500 bp, max 16128 bp, avg 748 bp, N50 709 bp
2026-03-25 08:27:20 - ALL DONE. Time elapsed: 5522.986334 seconds 
Traceback (most recent call last):
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2cli/commands.py", line 529, in __call__
    results = self._execute_action(
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2cli/commands.py", line 607, in _execute_action
    results = action(**arguments)
  File "<decorator-gen-333>", line 2, in assemble_megahit
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/action.py", line 221, in bound_callable
    outputs = self._callable_executor_(
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/action.py", line 440, in _callable_executor_
    outputs = self._callable(ctx, **view_args)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2_assembly/megahit/megahit.py", line 156, in assemble_megahit
    (contig,) = _assemble_megahit(reads, **kwargs)
  File "<decorator-gen-1130>", line 2, in _assemble_megahit
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/context/base.py", line 90, in _callable_action_
    return self._dispatch_(args, kwargs)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/context/base.py", line 45, in _dispatch_
    results = exe(*args, **kwargs)
  File "<decorator-gen-1133>", line 2, in _assemble_megahit
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/action.py", line 221, in bound_callable
    outputs = self._callable_executor_(
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/qiime2/sdk/action.py", line 359, in _callable_executor_
    output_views = self._callable(**view_args)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2_assembly/megahit/megahit.py", line 219, in _assemble_megahit
    return assemble_megahit_helper(
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2_assembly/megahit/megahit.py", line 255, in assemble_megahit_helper
    modify_contig_ids(
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/q2_assembly/_utils.py", line 197, in modify_contig_ids
    for contig in io.read(contig_file, format="fasta"):
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/registry.py", line 1177, in read
    return io_registry.read(file, format=format, into=into, verify=verify, **kwargs)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/registry.py", line 493, in read
    return (x for x in itertools.chain([next(gen)], gen))
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/registry.py", line 516, in _read_gen
    with _resolve_file(file, **io_kwargs) as (file, _, _):
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/util.py", line 221, in _resolve_file
    file, source, is_binary_file = _resolve(file, **kwargs)
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/util.py", line 69, in _resolve
    newfile = source.get_reader()
  File "/home/cwoo3/.conda/envs/qiime2-moshpit/lib/python3.10/site-packages/skbio/io/_iosources.py", line 92, in get_reader
    return io.open(self.file, mode="rb")
FileNotFoundError: [Errno 2] No such file or directory: '/scratch/cwoo3/moshpit-WGS-analysis/new/neg_con_test/cache/processes/3951980-1774446869.21@cwoo3/tmp/q2-OutPath-sfpybu84/all_contigs.fa'

Plugin error from assembly:
  [Errno 2] No such file or directory: '/scratch/cwoo3/moshpit-WGS-analysis/new/neg_con_test/cache/processes/3951980-1774446869.21@cwoo3/tmp/q2-OutPath-sfpybu84/all_contigs.fa'

See above for debug info.

Here is the command I ran:

mosh assembly assemble-megahit \
        --i-reads cache:neg_con_data \
        --p-presets "meta-sensitive" \
        --p-num-cpu-threads 8 \
        --p-min-contig-len 500 \
        --p-coassemble True \
        --o-contigs cache:neg_con_contigs \
        --use-cache cache \
        --verbose

Thank you!
Cindy

1 Like

Hello @Cindy,

It looks like you are running this on an HPC. Can you please put the following at the top of the script you are using to submit this job, then rerun it?

export TMPDIR=<a directory in your scratch folder "/scratch/cwoo3/tmp" or similar>

Thank you

1 Like

Hi @Oddant1,

Thank you for responding. You are right that I am running this on an HPC. I tried your suggestion and unfortunately still got the same error. Let me know if you have any other ideas, thanks!

Hello @Cindy,

Please try adding --no-recycle to your command and rerunning it.

By default, QIIME 2 caches and attempts to reuse results from failed pipeline runs. This is intended to allow pipelines that fail for reasons like "Not enough memory requested, not enough walltime requested, etc. etc." to resume from where they were when they timed out without redoing the work they did previously. It is possible for this to cause problems when something actually goes wrong.

Thank you

Thanks @Oddant1. It looks like I get the same error using the --no-recycle option too.

Hello @Cindy,

I'm sorry this has been such a sticking point. Can you please post the entirety of your job submission file? It seems like something is causing QIIME 2 to either write things to the wrong location or to delete files prematurely, and I'm not sure what.

In the meantime, it is possible that updating QIIME 2, if that is an option for you, would resolve this issue.

EDIT: Another idea, can you try running the command with --p-num-cpu-threads 1

Thank you