我是 nextflow/groovy/java 的新手,我在一个简单的正则表达式任务中遇到了一些困难。
我正在尝试更改某些文件对的标签。我的理解是fromFilePairs
返回表单的数据结构:
[
[common_prefix, [file1, file2]],
[common_prefix, [file3, file4]]
]
我进一步认为:
- 对该列表中的项目调用时的
.name
方法将给出名称,我在上面标记为common_prefix
fromFilePairs
与设置文件对的名称一起使用的闭包返回的值。it
与使用的闭包中的值fromFilePairs
是文件对列表中的单个项目。
但是,我在以下方面尝试了许多变体,但均未成功:
params.fastq = "$baseDir/data/fastqs/*_{1,2}_*.fq.gz"
Channel
.fromFilePairs(params.fastq, checkIfExists:true) {
file ->
// println file.name // returned the common file prefix as I expected
mt = file.name =~ /(common)_(prefix)/
// println mt
// # java.util.regex.Matcher[pattern=(common)_(prefix) region=0,47 lastmatch=]
// match objects appear empty despite testing with regexs I know to work correctly including simple stuff like (.*) to rule out issues with my regex
// println mt.group(0) // #No match found
mt.group(0) // or a composition like mt.group(0) + "-" + mt.group(1)
}
.view()
我还使用该replaceAll
方法尝试了一些变体。
我已经查阅了 nextflow、groovy 和 java 的文档,但我仍然无法弄清楚我缺少什么。我希望这是一些愚蠢的语法问题或对数据结构的误解,但是当对于更了解该语言的人来说可能很明显时,我已经厌倦了用头撞它-我会很感激任何能启发我了解它的工作原理的人.