nextflow-io / patterns

A curated collection of Nextflow implementation patterns
http://nextflow-io.github.io/patterns/
MIT License
329 stars 72 forks source link

Parsing from initial run argument into process scripts #15

Closed DolapoA closed 5 years ago

DolapoA commented 5 years ago

How do I parse an argument from the initiation command into one of my process scripts that's in another language like Python.

Initiation cmd: nextflow run /Path/to/myscript.nf --in '/Path/to/MyData'

process dataDirectories {

"""
#!/usr/bin/env python2.7

import os
import getpass

currentUser=getpass.getuser()

dataPath="/home/" + currentUser + "/WGS_Data/" + MyData
resultsPath="/home/" + currentUser + "/WGS_Results/" + MyData

try:
    os.makedirs(dataPath, 0o777)    
    os.makedirs(resultsPath, 0o777)

except:
    pass
"""

}

I would like to get the string 'MyData' from the path (which is in my '--in' argument) into my python script. Can this be done?

pditommaso commented 5 years ago

It's just a matter of string interpolation e.g. "/WGS_Data/${params.in}"

DolapoA commented 5 years ago

Ah yes that works thanks bro.

pditommaso commented 5 years ago

Enjoy