Search code examples
python-3.xworkflownextflow

How to run Python Script in Nextflow


I'm new to Nextflow and I tried to run a Python Script in Nextflow. So I stored the Python Script in the same Folder as the Nextflow Pipeline and tried to run it but I always get this error: .command.sh: line 2: ./example.py: No such file or directory. Does anybody encountered the same problem and was capable to solve it?

My Process looks like this:

#!/usr/bin/env nextflow

input_ch = Channel.fromPath('data/*.txt')

process foo {

    input:
    file x from input_ch

    output:
    file "$x" into outputt_ch

    """
    ./example.py ${x}
    """

}

P.S.:My Python Script is executable from the Terminal!

Thank you in advance!


Solution

  • Nextflow runs each task in a separate working directory. Therefore ./example.py won't work. You have to use example.py and make the script accessible through the system PATH or copy it into the project bin/ directory.