当我运行以下脚本时,我得到了一个java.nio.file.ProviderMismatchException
:
process a {
output:
file _biosample_id optional true into biosample_id
script:
"""
touch _biosample_id
"""
}
process b {
input:
file _biosample_id from biosample_id.ifEmpty{file("_biosample_id")}
script:
def biosample_id_option = _biosample_id.isEmpty() ? '' : "--biosample_id \$(cat _biosample_id)"
"""
echo \$(cat ${_biosample_id})
"""
}
我使用的是稍微修改过的可选输入模式。
对我为什么要得到java.nio.file.ProviderMismatchException
有什么想法吗
发布于 2022-01-21 01:47:10
在脚本块中,_biosample_id
实际上是nextflow.processor.TaskPath类的一个实例。因此,要检查文件(或目录)是否为空,只需调用它的.empty()
方法即可。例如:
script:
def biosample_id_option = _biosample_id.empty() ? '' : "--biosample_id \$(< _biosample_id)"
我喜欢你的解决方案-我觉得很好。我认为它应该是健壮的(但我还没有测试它)。建议的可选输入模式在尝试将丢失的输入文件逐步放置到远程文件系统/对象存储区时将失败。但是有一个解决方案,它将一个空文件保存在您的$baseDir
中,并在脚本中指向它。例如:
params.inputs = 'prots/*{1,2,3}.fa'
params.filter = "${baseDir}/assets/null/NO_FILE"
prots_ch = Channel.fromPath(params.inputs)
opt_file = file(params.filter)
process foo {
input:
file seq from prots_ch
file opt from opt_file
script:
def filter = opt.name != 'NO_FILE' ? "--filter $opt" : ''
"""
your_commad --input $seq $filter
"""
}
https://stackoverflow.com/questions/70789318
复制相似问题