I have the following simplified task and get some errors when doing it.
I'm trying to get 4 letters from a string by Python and use that as a name of a new folder. My code is as follows:
#!/usr/bin/env nextflow
params.string="abcdefg"
process PYTHON{
    input:
    val string
    
    output:
    val substring
    
    """
    #!/usr/bin/env python
    
    substring="$string"[0:4]
    """
}
process CREAT_FOLDER{
    input:
    val name
    
    """
    mkdir $name
    """
}
workflow{
    name = PYTHON(params.string)
    CREAT_FOLDER(name)
}
The error shows up.
N E X T F L O W  ~  version 23.04.1
Launching `python.nf` [shrivelled_kay] DSL2 - revision: 0e01fd9b95
executor >  local (1)
executor >  local (1)
[33/e827c9] process > PYTHON       [100%] 1 of 1, failed: 1 ✘
[-        ] process > CREAT_FOLDER -
ERROR ~ Error executing process > 'PYTHON'
Caused by:
  Missing value declared as output parameter: substring
The variable "substring" clearly couldn't pass through channels. So how can I pass a Python variable into channels?
 
    