Hi :wave: TLDR; I have this: [[id:Sample1-Projec...
# random
s
Hi 👋 TLDR; I have this: [[id:Sample1-Projectname],[/some path/to/reads]] I want this: [[id:Sample1],[/some path/to/reads]] Full version; I'm wondering if there's a way to update metadata within a process. I know I can update metadata with something like ch.map { meta,files -> doTheEditing} outside the process but I'm thinking about within. For example, I have a process which has meta [[id:Sample1-Projectname],[/some path/to/reads]] I then have a process which does the following
Process BASESPACE {
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("*gz"), emiti reads
script:
def args task.ext.args?: "
def prefix = task.ext.prefix ?: "$(meta.id)"
def sample_id meta.id.split('-')[0]
"""
~/tools/basespace download biosample -n ${prefix}
#Grab R1, R2 names
R1=$(1s ${prefix}*ds*/*R1* | head -n1) R2=$(1s ${prefix}*ds*/*R2* | head -n1)
#Rename output files
mv \$R1 ${sample_id}.R1.fastq.gz mv \$R2 ${sample_id}.R2.fastq.gz
"""
}
I'm going to update the file name
sample_id meta.id.split('-')[0]
and my question is, can I update the meta.id within this process to match? So the output is: [[id:Sample1],[/some path/to/reads]]
m
I recommend that you copy the meta and do not modify it in place. Other than that, yes, I have done so. Do you experience some problem with it?
s
Hey - I'm not sure what you mean by "copy the meta"? Can you help me understand?