I was wondering if someone can help me figure out this error message. I’m at the end of my Nextflow pipeline and I want to change the header in a FASTA file and it works when I use this command:
sed -i "s/^>/>${assembly_id}_${gene_id}_/g" "${assembly_id}/${gene_id}/${assembly_id}_${gene_id}.fasta"
but it prints out much more than I actually need (i.e., “goodID_extra_extra_extra”). That’s just part of the file name (it includes what assembler was used) but I only want it to add “goodID_” to the header.
I tried using this command:
sed -i "s/^>/>${assembly_id%%_*}_${gene_id}_/g" "${assembly_id}/${gene_id}/${assembly_id}_${gene_id}.fasta"
but I get this error message:
N E X T F L O W ~ version 21.10.6
Launching `geneTargets.nf` [amazing_elion] - revision: b875027a52
Script compilation error
- file : /Users/rimo/Desktop/AWS/nextflow_work/PROJECTS/gene_targets/geneTargets.nf
- cause: Unexpected input: '{' @ line 94, column 32.
process publish_gene_sequences {
^
1 error
Can someone explain why this is happening? If this is something I can’t do without breaking the script that’s okay the header will still do it’s purpose I just wanted it to be clearer/less noise.
EDIT: this is the process block
process publish_gene_sequences {
publishDir params.publish_dir
input:
tuple val(assembly_id), val(gene_id), path("gene.fasta")
output:
path("${gene_id}/${assembly_id}_${gene_id}.fasta")
script:
"""
mkdir -p ${gene_id}
cp gene.fasta "${gene_id}/${assembly_id}_${gene_id}.fasta"
sed -i "s/^>/>${assembly_id}_${gene_id}_/g" "${gene_id}/${assembly_id}_${gene_id}.fasta"
"""
}
-e
to the sed line after-i
gave me no errors but it's guess work unless I can try to reproduce what you're finding in your machine :-\ $\endgroup$