Include external tools in the Nextstrain Snakemake workflow

Hi,

I’m using the nextstrain build Docker-based workflow. And I want to include the tool “Treemmer” to reduce a phylogenetic tree afte the initial “augur tree”. Treemmer can be installed locally, but is also available as a Singularity image. If I understand correctly, all the needed augur tools for the nextstrain workflow are included in a Docker image? Must this image be extended if one wants to include new tools? Or how can new tools be added to the Snakemake workflow?

Thanks,

Jon

Hi @jonr,

Nextstrain CLI does not provide direct support for adding additional tools like Treemmer to the Docker image (such plans are in early stages). You will have to extend one of the existing runtimes with Treemmer_v0.3.py and its dependencies.

You can continue to use the Docker runtime by creating a custom Docker image, but I only suggest doing this if you are already comfortable with creating Docker images.

As an easier option, you can use the ambient runtime with a custom conda environment. Here are the steps:

  1. Create the environment with Nextstrain tools + Treemmer dependencies.

    # you can change "treemmer-env" to another name
    conda create -n treemmer-env \
      -c conda-forge -c bioconda -c nextstrain --strict-channel-priority \
      nextstrain-base \
      ete3 joblib numpy matplotlib
    
  2. Activate the environment.

    conda activate treemmer-env
    
  3. Download Treemmer_v0.3.py to somewhere accessible by your workflow. Update your workflow to call python <path/to/Treemmer_v0.3.py> as needed.

  4. Run nextstrain build as you normally would, but with the --ambient option before the directory argument. This uses the conda environment activated in step 2.

    nextstrain build --ambient . <snakemake options>
    

Unfortunately this means the analysis not easily reproducible for others, but I hope it’s a good starting point. Let me know if you run into any issues!

– Victor

Thanks Victor!

I got it working by creating a custom conda environment with all the nextstrain tools and treemmer as you suggested. Instead of nextstrain build I invoke the workflow with snakemake but it works well.

Great, glad to hear!