英文:
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()
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论