# q2-assembly assemble-megahit error:

**URL:** https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114
**Category:** Ideas and Suggestions
**Tags:** q2-assembly, import
**Created:** [August 13, 2024, 11:19am UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114 "2024-08-13T11:19:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pietervanveelen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/pietervanveelen/32/19014_2.png) [@pietervanveelen](https://forum.qiime2.org/u/pietervanveelen)
#### Post date: [August 13, 2024, 11:19am UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/1 "2024-08-13T11:19:04Z")

</div>

Hi [@Caporaso\_Bokulich](https://forum.qiime2.org/groups/caporaso_bokulich) groups,

When paired end data have been successfully imported into a qza artifact, an issue is raised in stdout when the input read files are gzipped. In all my QIIME2 endeavors, this has never been a problem, but it seems that q2-assembly is not able to cope properly. Previous trials with decompressed files ran fine, when imported to and accessed from qiime cache by q2-assembly. Megahit thus requires decompressed fastq files to properly run.  
Perhaps you may want to incorporate an internal decompression of fastq.gz files when the reads.qza artifact was created from .gz files.

Cheers,  
Pieter

---

<div class="post-metadata">

### Author: ![colinvwood](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinvwood/32/17303_2.png) [@colinvwood](https://forum.qiime2.org/u/colinvwood)
#### Post date: [August 14, 2024, 5:04pm UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/2 "2024-08-14T17:04:26Z")

</div>

Hello @pietervanveelen,

Could you share a log of the error that you encountered?

---

<div class="post-metadata">

### Author: ![pietervanveelen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/pietervanveelen/32/19014_2.png) [@pietervanveelen](https://forum.qiime2.org/u/pietervanveelen)
#### Post date: [August 15, 2024, 1:27pm UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/3 "2024-08-15T13:27:51Z")

</div>

Hi Colin,

I've been digging in the meantime and realize that the issue I raised was nonsense.  
The issue had to do with a yet not identified issue of cleaned raw data by Trimmomatic (as wrapped by the Kneaddata function of Biobakery3.  
It appears that the just adapter and quality trimmed PE data works properly when2- input as reads.qza into q2 assembly assemble-megahit.  
However, after subsequent removal of repeats, which is output also created by Kneaddata, the problem arises. To be clear, the import itself works fine:  
qiime tools import   
--type 'SampleData[PairedEndSequencesWithQuality]'   
--input-path "$sample\_dir/sample/{sample}\_manifest.tsv"   
--input-format PairedEndFastqManifestPhred33V2   
--output-path "$output\_file"

But the internal stdout of q2 assembly assemble-megahit is where problems are encountered when reading in sequences:

/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/megahit.py:100: UserWarning: The presets parameter overrides settings for the min\_count and k\_list parameters. The settings of  
min\_count and k\_list registered in provenance may not reflect the actual settings used by the presets parameter. Re  
fer to the megahit documentation for more details, and refer to the presets values of these parameters when interpre  
ting or reporting your results.  
warnings.warn(warning, UserWarning)  
2024-08-13 16:38:26 - MEGAHIT v1.2.9  
2024-08-13 16:38:26 - Using megahit\_core with POPCNT and BMI2 support  
2024-08-13 16:38:27 - Convert reads to binary library  
2024-08-13 16:39:03 - b'INFO sequence/io/sequence\_lib.cpp : 75 - Lib 0 (/export/microlab/temp/temp\_354/qiime2/mi  
crolab/data/f67e5fda-04da-411a-8a03-33fcd04eb6be/data/IDIN03\_0\_L001\_R1\_001.fastq.gz,/export/microlab/temp/temp\_354/q  
iime2/microlab/data/f67e5fda-04da-411a-8a03-33fcd04eb6be/data/IDIN03\_1\_L001\_R2\_001.fastq.gz): pe, 27970432 reads, 15  
0 max length'  
2024-08-13 16:39:35 - b'INFO utils/utils.h : 152 - Real: 67.8597\tuser: 25.0557\tsys: 3.6088\tmaxr  
ss: 246808'  
2024-08-13 16:39:35 - Error occurs when reading inputs  
Traceback (most recent call last):  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/me  
gahit.py", line 78, in \_process\_sample  
run\_command(cmd, verbose=True)  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/\_utils.py"  
, line 32, in run\_command  
subprocess.run(cmd, check=True)  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/subprocess.py", line 528, in run  
raise CalledProcessError(retcode, process.args,  
subprocess.CalledProcessError: Command '['megahit', '-1', '/export/microlab/temp/temp\_354/qiime2/microlab/data/f67e5  
fda-04da-411a-8a03-33fcd04eb6be/data/IDIN03\_0\_L001\_R1\_001.fastq.gz', '-2', '/export/microlab/temp/temp\_354/qiime2/mi  
crolab/data/f67e5fda-04da-411a-8a03-33fcd04eb6be/data/IDIN03\_1\_L001\_R2\_001.fastq.gz', '-o', '/export/microlab/temp/t  
emp\_354/tmpjoku9vdv/results', '--presets', 'meta-sensitive', '--min-count', '2', '--k-list', '21,29,39,59,79,99,119,  
141', '--bubble-level', '2', '--prune-level', '2', '--prune-depth', '2', '--disconnect-ratio', '0.1', '--low-local-r  
atio', '0.2', '--cleaning-rounds', '5', '--memory', '0.9', '--mem-flag', '1', '--num-cpu-threads', '16', '--min-cont  
ig-len', '200']' returned non-zero exit status 141.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2cli/commands.py", li  
ne 520, in **call**  
results = self.\_execute\_action(  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2cli/commands.py", li  
ne 586, in \_execute\_action  
results = action(\*\*arguments)  
File "", line 2, in assemble\_megahit  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py",  
line 342, in bound\_callable  
outputs = self._callable\_executor_(  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py",  
line 657, in _callable\_executor_  
outputs = self.\_callable(scope.ctx, \*\*view\_args)  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/megahit.py", line 157, in assemble\_megahit  
(contig,) = \_assemble\_megahit(seq, \*\*kwargs)  
File "", line 2, in \_assemble\_megahit  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/qiime2/sdk/context.py", line 143, in deferred\_action  
return action\_obj.\_bind(  
File "", line 2, in \_assemble\_megahit  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py", line 342, in bound\_callable  
outputs = self._callable\_executor_(  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py", line 576, in _callable\_executor_  
output\_views = self.\_callable(\*\*view\_args)  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/megahit.py", line 208, in \_assemble\_megahit  
return assemble\_megahit\_helper(  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/megahit.py", line 246, in assemble\_megahit\_helper  
\_process\_sample(samp, fwd, rev, common\_args, result)  
File "/export/microlab/miniconda3/envs/qiime2-metagenome-2024.5/lib/python3.9/site-packages/q2\_assembly/megahit/megahit.py", line 80, in \_process\_sample  
raise Exception(  
Exception: An error was encountered while running MEGAHIT, (return code 141), please inspect stdout and stderr to learn more.

Sorry for changing the subject, but I think still useful to understand.  
Thanks in advance.

Best,  
Pieter

---

<div class="post-metadata">

### Author: ![jphagen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jphagen/32/17133_2.png) [@jphagen](https://forum.qiime2.org/u/jphagen)
#### Post date: [August 15, 2024, 4:42pm UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/4 "2024-08-15T16:42:18Z")

</div>



---

<div class="post-metadata">

### Author: ![colinvwood](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinvwood/32/17303_2.png) [@colinvwood](https://forum.qiime2.org/u/colinvwood)
#### Post date: [August 16, 2024, 9:57pm UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/5 "2024-08-16T21:57:00Z")

</div>

Hello @pietervanveelen,

Can you post the exact `qiime assembly assemble-megahit` command than you ran? If you did not include the `--verbose` flag could you please re-run with that flag and post the log from that? I'm not seeing much useful information here beyond "exit status 141".

---

<div class="post-metadata">

### Author: ![colinvwood](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinvwood/32/17303_2.png) [@colinvwood](https://forum.qiime2.org/u/colinvwood)
#### Post date: [September 13, 2024, 4:53pm UTC](https://forum.qiime2.org/t/q2-assembly-assemble-megahit-error/31114/6 "2024-09-13T16:53:15Z")

</div>


