I want to find all *.fq.gz files using nextflow. My dir has four .gf.gz files (BF1_1.fg.gz,BF1_2.fg.gz,BF2_1.fg.gz and BF2_2.fg.gz). I use following command but nextflow only recognizes * as a character, not a special command
That's because params.reads is just a regular java.lang.String
. What you want is a Channel. If you need a channel emitting file pairs, you can use the fromFilePairs factory method to get a tuple containing the group key as the first element, and a list of files matching the glob pattern as the second element:
params.reads = "/home/tzfeng/test_files/*_{1,2}.fq.gz"
workflow {
reads = Channel.fromFilePairs( params.reads )
reads.view()
}
Results:
$ touch /home/tzfeng/test_files/{A,B,C}_{1,2}.fq.gz
$ nextflow run main.nf
N E X T F L O W ~ version 22.10.0
Launching `main.nf` [sharp_borg] DSL2 - revision: 3461b43146
[A, [/home/tzfeng/test_files/A_1.fq.gz, /home/tzfeng/test_files/A_2.fq.gz]]
[B, [/home/tzfeng/test_files/B_1.fq.gz, /home/tzfeng/test_files/B_2.fq.gz]]
[C, [/home/tzfeng/test_files/C_1.fq.gz, /home/tzfeng/test_files/C_2.fq.gz]]