获取目录通道 nexflow 的文件列表。

huangapple go评论68阅读模式
英文:

Get file list from directory channel nexflow

问题

有没有办法指定文件夹名称,然后在Nextflow中创建一个包含文件名称的通道?

是的,我可以创建一个包含目录内容的文件,但这不是我想要的。

谢谢

英文:

Is there a way to specify the folder name and then create a channel with the file names inside it in nextflow?

And yes I could make a file with the contents of the directory, that's not what i'm asking.

Thanks

答案1

得分: 3

我认为你可以只使用 fromPath 工厂方法来实现这个。如果你想获取目录中以及所有子目录中的所有文件,你可以使用双星号来跨越目录边界:

params.search_dir = './directory';

workflow {

    Channel
        .fromPath("${params.search_dir}/**")
        .view()
}

否则,单个星号将仅匹配顶层目录中的文件。如果你需要包括隐藏文件在你的输出中,可以附加 hidden: true。请注意,还可以使用列表指定多个路径或通配符模式,例如:

params.search_dir = './directory';
params.another_dir = './another/directory';

workflow {

    Channel
        .fromPath([ "${params.search_dir}/**", "${params.another_dir}/*" ])
        .view()
}
英文:

I think you can just use the fromPath factory method for this. If you want all files in the directory and in all sub-directories, you can use the double asterisk to cross directory boundaries:

params.search_dir = './directory'


workflow {

    Channel
        .fromPath( "${params.search_dir}/**" )
        .view()
}

Otherwise, a single asterisk will match only files in the top-level directory. Append hidden: true if you also need your output to include hidden files. Note that multiple paths or glob patterns can also be specified using a list, for example:

params.search_dir = './directory'
params.another_dir = './another/directory'


workflow {

    Channel
        .fromPath( [ "${params.search_dir}/**", "${params.another_dir}/*" ) ]
        .view()
}

huangapple
  • 本文由 发表于 2023年3月31日 01:58:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75891504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定