Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use multiple conda environments in the nextflow config?

I'm writing a pipeline in Nextflow and want to use multiple different conda (existing) environments to avoid inconsistencies in tool installation and for sharing specific modules of the pipeline. The Nextflow docs state that the best practise is to specify the conda environment in the nextflow.config - see here.. However, the declaration is just process.conda and seems to apply to all processes rather than being process specific.

I know I can just specify an existing conda environment in each process but I'm trying to adhere to the best practises for portability.

As I haven't been able to find any documentation online for this specific issue, I have tried the following declarations in the config file:

profiles {
    conda {
        process.conda = "something" // works but single env for all processes
        fastqc.conda = "something" // where fastqc is the name of the process - FAILS
        process.fastqc.conda = "something" // FAILS
    }
}

I have also tried:

profiles {
    conda {
        process {
            withName: fastqc {
                 process.conda = "something"
            }
        }
    }
}

which also fails with the error: unknown config attribute withName

Interestingly,

process {
        conda {
            withName: fastqc {
                 process.conda = "something"
            }
        }
    }

does allow me to run different conda environments for each process but cannot be turned on and off by the -profile option (because specifying a profile block breaks it).

like image 804
Ryan Avatar asked Oct 17 '25 06:10

Ryan


1 Answers

You were very close with your second fenced code block, here's what works for me (version 22.10.6 build 5843):

profiles {
    conda {
        conda.enabled = true
        process {
            withName: fastqc{
                conda = "location/of/env/fastqc"
            }
        }
    }
}
like image 188
bricoletc Avatar answered Oct 22 '25 22:10

bricoletc