New feature
Hi! I'm starting to use records extensively, and I think a very nice feature would be to have a rename method that can rename the record keys easily using a map as input.
Use case
nextflow.enable.types = true
process A_TYPED_PROCESS {
input:
record(id: String, foo: String, bar: Integer)
output:
record(id: id, baz: file("*.out"))
script:
def prefix = "$id"
"""
echo ${id}_${bar} > ${prefix}.out
echo $foo >> ${prefix}.out
"""
}
workflow {
main:
ch_records = channel.of(
record(id: "a", foofoo: "hello", barbar: 0),
record(id: "b", foofoo: "world", barbar: 1)
)
ch_out = A_TYPED_PROCESS(
ch_records.map{ rec -> record(id: rec.id, foo: rec.foofoo, bar: rec.barbar) }
)
ch_out.view()
}
Suggested implementation
ch_records.map { rec -> rec.rename( [foofoo: 'foo', barbar: 'bar'] ) }
This is just a slight improvement at first sight, but it would make big pipelines much more readable.
If rename does not look explicit enough, it could be renameKeys too.
This would be in line with existing methods in modern data frameworks:
Thanks a lot!
New feature
Hi! I'm starting to use records extensively, and I think a very nice feature would be to have a
renamemethod that can rename the record keys easily using a map as input.Use case
Suggested implementation
This is just a slight improvement at first sight, but it would make big pipelines much more readable.
If
renamedoes not look explicit enough, it could berenameKeystoo.This would be in line with existing methods in modern data frameworks:
Thanks a lot!