shovill icon indicating copy to clipboard operation
shovill copied to clipboard

--tmpdir with relative path may fail

Open hmontenegro opened this issue 3 years ago • 2 comments

When using MEGAHIT as assembler and using a relative path with --tmpdir, Shovill will fail at the assembly step. Here is the snippet from shovill.log:

[shovill] Assembling reads with 'megahit'
[shovill] Running: megahit -1 flash.notCombined_1.fastq.gz -2 flash.notCombined_2.fastq.gz --k-list 31,51,71,91,111 -m 16000000000 -t 8 -o megahit --tmp-dir ../d/assembly/shovill/tmp --min-contig-len 1  -r flash.extendedFrags.fastq.gz 2>&1 | sed 's/^/[megahit] /' | tee -a shovill.log
[megahit] Traceback (most recent call last):
[megahit]   File "/home/banana/bin/MEGAHIT/1.2.9/bin/megahit", line 1038, in <module>
[megahit]     main()
[megahit]   File "/home/banana/bin/MEGAHIT/1.2.9/bin/megahit", line 978, in main
[megahit]     setup_output_dir()
[megahit]   File "/home/banana/bin/MEGAHIT/1.2.9/bin/megahit", line 462, in setup_output_dir
[megahit]     opt.temp_dir = tempfile.mkdtemp(dir=opt.temp_dir, prefix='megahit_tmp_')
[megahit]   File "/usr/lib/python2.7/tempfile.py", line 339, in mkdtemp
[megahit]     _os.mkdir(file, 0700)
[megahit] OSError: [Errno 2] No such file or directory: '/home/banana/d/assembly/d/assembly/shovill/tmp/megahit_tmp_qRrSIQ'
[shovill] Generating genome graph from K=111
[shovill] Running: megahit_toolkit contig2fastg 111 megahit/intermediate_contigs/k111.contigs.fa > megahit/contigs.fastg 2>&1 | sed 's/^/[megahit_toolkit] /' | tee -a shovill.log
[shovill] Assembly failed - megahit.fasta has zero contigs!

As shovill first creates $tmpdir, then moves into $outdir, $tmpdir won't be found when looked for from $outdir. I think the issue can be fixed by a call to abs_path() as done for other paths in the pipeline:

$tmpdir ||= File::Temp->newdir(CLEANUP=>1);
$tmpdir = abs_path($tmpdir);
msg("Using tempdir: $tmpdir");

hmontenegro avatar Jul 17 '20 20:07 hmontenegro

Sorry, forgot to mention:

  • Shovill 1.1.0
  • MEGAHIT 1.2.9

hmontenegro avatar Jul 17 '20 20:07 hmontenegro

Well, I'll be damned, I should have checked things more carefully. The problem is not with --tmpdir and relative paths, as Shovill with --assembler megahit fails with the same error even when leaving --tmpdir at the default value.

I will have to investigate more, but so far, Shovill+SPAdes and Shovill+SKESA worked with --tmpdirand relative paths or default value, but Shovill+MEGAHIT failed with both.

hmontenegro avatar Jul 18 '20 06:07 hmontenegro