bhattlab / MGEfinder

A toolbox for identifying mobile genetic element (MGE) insertions from short-read sequencing data of bacterial isolates.
MIT License
105 stars 16 forks source link

Calling mgefinder from a different workflow #17

Closed nongiga closed 3 years ago

nongiga commented 3 years ago

I created a snakemake workflow to make the necessary files and organize them for mgefinder, but I am having difficulties merging mgefinder, which has its own environment and configfile, as a part of my workflow

  1. I tried using subworkflowbut then mgefinder runs first when I need it to run last
  2. I was considering usinginclude but it prevents me from using a unique environment or config file.
  3. I was considering creating a third workflow to call both subworkflows but didn't try it yet and it would complicate my debugging
  4. I was considering modifying your original code to include 'env' in each call but it is (a) time-consuming and (b) not ideal in terms of best practices
  5. Finally, I exported the mgefinder environment and made a rule that calls it. It works but my workflow sees it as one job and it is certainly far from best practices:
    rule mgefinder:
        input:
            lambda wildcards: 
                expand("mgefinder/{group}/00.bam/{sample2}.{sample1}.bam.bai",
                    sample1=GROUPS.get(int(wildcards.group)), 
                    sample2=GROUPS.get(int(wildcards.group)), 
                    allow_missing=True),
            lambda wildcards: 
                expand("mgefinder/{group}/00.{dirname}/{sample}.fna",
                    sample=GROUPS.get(int(wildcards.group)), 
                    dirname=["assembly","genome"],allow_missing=True),
        output:
            "mgefinder/{group}/dummy.txt"
        params:
            prefix="mgefinder/{group}/"
        conda:
            "database/mgefinder.yaml"
        shell:
            "mgefinder workflow denovo {params.prefix}; touch `{params.prefix}/dummy.txt"

I was wondering if you have any suggestions as to how to do it?

durrantmm commented 3 years ago

Hello, thank you for your question.

Have you considered adding in the additional rules to the existing mgefinder snakemake workflow, and then installing your software in the mgefinder conda environment?

nongiga commented 3 years ago

Great idea thank you! I didn't think about it before but in that case, actually, I could add the additional rules as a sub-workflow so they'd take only a few lines without interfering with your code, and will only be executed if the files weren't placed in the directory manually.