voutcn / megahit

Ultra-fast and memory-efficient (meta-)genome assembler
http://www.ncbi.nlm.nih.gov/pubmed/25609793
GNU General Public License v3.0
588 stars 134 forks source link

Feature request: --force option #308

Closed mw55309 closed 2 years ago

mw55309 commented 3 years ago

Hello

As we all know, megahit will fail if the directory given to -o exists.

This can be overcome by using --continue, but this still fails if options.json is missing

Here's the thing. We use megahit within Snakemake, and in Snakemake you tell it what the output directory is, and Snakemake creates that directory before running megahit

The result is that megahit then doesn't run because the output directory is empty

I also cannot use --continue because the empty directory doesn't contain options.json

What would be really good would be a --force option which just makes megahit run no matter what, and clobber the output even if there is something already there

Cheers Mick

b-brankovics commented 3 years ago

You can use a workaround by running it with a different folder and moving it to the right spot at the end. I have found it here. Looks very ugly, but works.

     shell:
        """                                                                                                                                                                                   
        mkdir assemblies/{wildcards.sample}                                                                                                                                                   
        touch assemblies/{wildcards.sample}/final.contigs.fa                                                                                                                                  
        megahit {params} -o assemblies/tmp                                                                                                                                                    
        rm -r assemblies/{wildcards.sample}                                                                                                                                                   
        mv assemblies/tmp assemblies/{wildcards.sample}                                                                                                                                       
        """
voutcn commented 2 years ago

In fact --force or -f exist. I did not realize that it is missing from the helping message...